- Problem description:
In the Yocto project, when executing the rubikpi_build.sh -a
command, the script does not terminate upon errors in critical bitbake commands. This condition prevents the ./rubikpi_build.sh --zip_flat_build
command from packaging images in certain scenarios.
- Problem analysis:
In BASH shell, $?
is commonly used to retrieve the exit code of the last executed command. However, for pipeline commands, $?
only captures the exit code of the last command in the pipeline.
In rubikpi_build.sh, the following function has problems. Even if the bitbake
command fails, the assert
function will not detect it.
assert() {
if [ $? -ne 0 ];then
exit 1;
fi
}
echo "bitbake qcom-multimedia-image" 2>&1 | tee -a $log_file
bitbake qcom-multimedia-image 2>&1 | tee -a $log_file
assert
echo "bitbake qcom-qim-product-sdk" 2>&1 | tee -a $log_file
bitbake qcom-qim-product-sdk
assert
}
- Solution:
2025-06-30T16:00:00Z
Original post: [问题修复][yocoto][rubikpi_build.sh] Linux Shell 返回值之 PIPESTATUS - 技术分享 - RUBIK Pi by Hongyang Zhao