diff mbox series

fix(run-postinsts): exit on error

Message ID GV0P278MB06880222F486E5880988044993A1A@GV0P278MB0688.CHEP278.PROD.OUTLOOK.COM
State New
Headers show
Series fix(run-postinsts): exit on error | expand

Commit Message

Germann, Bastian Dec. 11, 2025, 10:32 a.m. UTC
In case a exec_postinst_scriptlets child process fails during installation we
want indication that the service has a problem. Otherwise the error is
disguised.

Signed-off-by: Bastian Germann <bastian.germann@duagon.com>
---
 .../run-postinsts/run-postinsts/run-postinsts                 | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Alexander Kanavin Dec. 11, 2025, 1:05 p.m. UTC | #1
On Thu, 11 Dec 2025 at 13:23, Germann, Bastian via
lists.openembedded.org
<Bastian.Germann=duagon.com@lists.openembedded.org> wrote:
> +                       if [ $? -ne 0 ]; then
> +                               echo "ERROR: postinst $i failed."
> +                               exit 1
> +                       fi

Indication that there is a problem is probably ok (although there is a
post-install-logging image feature that also covers it), but breaking
the loop most likely isn't. The current, expected behavior is that
execution of all postinsts is at least attempted, and you can't just
change it to 'exit immediately when one of them failed'.

The if..else condition is also strange: check that the file exists and
is executable, and say 'postinst is failed' otherwise? There's a
possibility for improving that too.

Alex
diff mbox series

Patch

diff --git a/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts b/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts
index a94a769b59..f374b05e8e 100755
--- a/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts
+++ b/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts
@@ -68,6 +68,10 @@  exec_postinst_scriptlets() {
                [ "$POSTINST_LOGGING" = "1" ] && eval echo "Running postinst $i..." $append_log
                if [ -x $i ]; then
                        (sh -c $i $append_log)
+                       if [ $? -ne 0 ]; then
+                               echo "ERROR: postinst $i failed."
+                               exit 1
+                       fi
                        rm $i
                else
                        echo "ERROR: postinst $i failed."