Thanks, I think this looks fine. If it somehow doesn't make through
yocto CI tests, you'll get a notice.

Alex

On Fri, 12 Dec 2025 at 14:47, Germann, Bastian
<[email protected]> wrote:
>
> 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 <[email protected]>
> ---
>  .../run-postinsts/run-postinsts/run-postinsts | 34 +++++++++++--------
>  1 file changed, 20 insertions(+), 14 deletions(-)
>
> 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
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#227594): 
https://lists.openembedded.org/g/openembedded-core/message/227594
Mute This Topic: https://lists.openembedded.org/mt/116745916/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to