All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] run-postinsts: Fix full execution of scripts at first boot
@ 2019-04-19 21:47 Alejandro Enedino Hernandez Samaniego
  2019-04-26  8:15 ` Richard Purdie
  0 siblings, 1 reply; 2+ messages in thread
From: Alejandro Enedino Hernandez Samaniego @ 2019-04-19 21:47 UTC (permalink / raw)
  To: openembedded-core

run-postinsts runs a given set of scripts during the first boot of the
device, when one of these scripts prints something to stdout (isnt
daemonized correctly), since stdout is not available at that time,
the script execution immediately returns with an error (exit_group()),
this error causes the script to terminate all threads within the process,
causing undesired behavior since the script might still had to execute
some other code.

Replace eval built-in with $(), since $() executes in a different shell,
even if one of the scripts exits, all threads of that process will only
be within that session, this ensures other scripts meant to be run are
still run afterwards.

This was only required on the line that actually executes the scripts:
"eval sh -c $i $append_log", other replacements were put for consistency,
and generally, it is recommended to use $() instead of eval anyway.

[YOCTO #13266]

Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr@xilinx.com>
---
 .../recipes-devtools/run-postinsts/run-postinsts/run-postinsts | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts b/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts
index 95eff04..419796f 100755
--- a/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts
+++ b/meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts
@@ -65,13 +65,13 @@ exec_postinst_scriptlets() {
 	for i in `ls $pi_dir`; do
 		i=$pi_dir/$i
 		echo "Running postinst $i..."
-		[ "$POSTINST_LOGGING" = "1" ] && eval echo "Running postinst $i..." $append_log
+		[ "$POSTINST_LOGGING" = "1" ] && $(echo "Running postinst $i..." $append_log)
 		if [ -x $i ]; then
-			eval sh -c $i $append_log
+			$(sh -c $i $append_log)
 			rm $i
 		else
 			echo "ERROR: postinst $i failed."
-			[ "$POSTINST_LOGGING" = "1" ] && eval echo "ERROR: postinst $i failed." $append_log
+			[ "$POSTINST_LOGGING" = "1" ] && $(echo "ERROR: postinst $i failed." $append_log)
 			remove_pi_dir=0
 		fi
 	done
@@ -81,11 +81,11 @@ remove_pi_dir=1
 if $pm_installed; then
 	case $pm in
 		"ipk")
-			eval opkg configure $append_log
+			$(opkg configure $append_log)
 			;;
 
 		"deb")
-			eval dpkg --configure -a $append_log
+			$(dpkg --configure -a $append_log)
 			;;
 	esac
 else
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] run-postinsts: Fix full execution of scripts at first boot
  2019-04-19 21:47 [PATCH] run-postinsts: Fix full execution of scripts at first boot Alejandro Enedino Hernandez Samaniego
@ 2019-04-26  8:15 ` Richard Purdie
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2019-04-26  8:15 UTC (permalink / raw)
  To: Alejandro Enedino Hernandez Samaniego, openembedded-core

On Fri, 2019-04-19 at 14:47 -0700, Alejandro Enedino Hernandez
Samaniego wrote:
> run-postinsts runs a given set of scripts during the first boot of
> the
> device, when one of these scripts prints something to stdout (isnt
> daemonized correctly), since stdout is not available at that time,
> the script execution immediately returns with an error
> (exit_group()),
> this error causes the script to terminate all threads within the
> process,
> causing undesired behavior since the script might still had to
> execute
> some other code.
> 
> Replace eval built-in with $(), since $() executes in a different
> shell,
> even if one of the scripts exits, all threads of that process will
> only
> be within that session, this ensures other scripts meant to be run
> are
> still run afterwards.
> 
> This was only required on the line that actually executes the
> scripts:
> "eval sh -c $i $append_log", other replacements were put for
> consistency,
> and generally, it is recommended to use $() instead of eval anyway.
> 
> [YOCTO #13266]
> 
> Signed-off-by: Alejandro Enedino Hernandez Samaniego <
> alejandr@xilinx.com>

This seems to cause:

oe-selftest -r runtime_test.Postinst.test_postinst_rootfs_and_boot

to fail:

https://autobuilder.yoctoproject.org/typhoon/#/builders/56/builds/429

(both on the autobuilder and locally)

Cheers,

Richard





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-26  8:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-19 21:47 [PATCH] run-postinsts: Fix full execution of scripts at first boot Alejandro Enedino Hernandez Samaniego
2019-04-26  8:15 ` Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.