From: Germann, Bastian Date: Fri, 12 Dec 2025 13:47:07 +0000 (+0000) Subject: run-postinsts: propagate exit state to run-postinsts.service X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f74d88bb628f186309c9228cf01293b046e43ca;p=thirdparty%2Fopenembedded%2Fopenembedded-core.git run-postinsts: propagate exit state to run-postinsts.service In case an exec_postinst_scriptlets child process fails during installation we want indication that the run-postinsts.service had a problem. We still try to install all scriptlets and only run remove_rcsd_link if all postinst scripts ran without error. Otherwise on every following boot a new install attempt of the missing scriptlet(s) is performed. Signed-off-by: Bastian Germann Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- diff --git a/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts b/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts index a94a769b59..b7352aa24d 100755 --- a/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts +++ b/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts @@ -62,22 +62,29 @@ if [ "$POSTINST_LOGGING" = "1" ]; then fi exec_postinst_scriptlets() { - for i in `ls $pi_dir`; do - i=$pi_dir/$i + ret=0 + for i in "$pi_dir"/*; do echo "Running postinst $i..." [ "$POSTINST_LOGGING" = "1" ] && eval echo "Running postinst $i..." $append_log - if [ -x $i ]; then - (sh -c $i $append_log) - rm $i + if [ -x "$i" ]; then + (sh -c "$i" $append_log) + status=$? + if [ $status -ne 0 ]; then + echo "ERROR: postinst $i failed with exit code $status." + [ "$POSTINST_LOGGING" = "1" ] && eval echo "ERROR: postinst $i failed with exit code $status." $append_log + ret=1 + else + rm -f "$i" + fi else - echo "ERROR: postinst $i failed." - [ "$POSTINST_LOGGING" = "1" ] && eval echo "ERROR: postinst $i failed." $append_log - remove_rcsd_link=0 + echo "ERROR: postinst $i is not executable." + [ "$POSTINST_LOGGING" = "1" ] && eval echo "ERROR: postinst $i is not executable." $append_log + ret=1 fi done + return $ret } -remove_rcsd_link=1 if $pm_installed; then case $pm in "ipk") @@ -96,10 +103,9 @@ if $pm_installed; then ;; esac else - exec_postinst_scriptlets -fi - -# since all postinstalls executed successfully, remove the rcS.d link -if [ $remove_rcsd_link = 1 ]; then + if ! exec_postinst_scriptlets; then + exit 1 + fi + # since all postinstalls executed successfully, remove the rcS.d link remove_rcsd_link fi