Patchwork [1/5] image.bbclass: run postinst scripts once, at rootfs time

login
register
mail settings
Submitter Laurentiu Palcu
Date Dec. 4, 2012, 1:59 p.m.
Message ID <1636e75017b72bc97347f4cca038a8bc1efdb4ff.1354626535.git.laurentiu.palcu@intel.com>
Download mbox | patch
Permalink /patch/40273/
State Accepted
Commit 6b76f04195911a40d868d988b8223db0f88ac8a9
Headers show

Comments

Laurentiu Palcu - Dec. 4, 2012, 1:59 p.m.
This patch will allow the repeating postinst scriptlets to be run
only once, on host, at do_rootfs time. This will lower the time for
rootfs generation and, also, instead of running some time consuming
scriptlets at target's first boot, we will do on the host.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
---
 meta/classes/image.bbclass |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
Otavio Salvador - Dec. 4, 2012, 2:10 p.m.
On Tue, Dec 4, 2012 at 11:59 AM, Laurentiu Palcu
<laurentiu.palcu@intel.com>wrote:

> This patch will allow the repeating postinst scriptlets to be run
> only once, on host, at do_rootfs time. This will lower the time for
> rootfs generation and, also, instead of running some time consuming
> scriptlets at target's first boot, we will do on the host.
>
> Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
> ---
>  meta/classes/image.bbclass |   20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 7b24e4e..719d871 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -156,7 +156,7 @@ inherit ${IMAGE_CLASSES}
>
>  IMAGE_POSTPROCESS_COMMAND ?= ""
>  MACHINE_POSTPROCESS_COMMAND ?= ""
> -ROOTFS_POSTPROCESS_COMMAND ?= ""
> +ROOTFS_POSTPROCESS_COMMAND_prepend = "run_intercept_scriptlets; "
>
>  # some default locales
>  IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
> @@ -166,15 +166,29 @@ LINGUAS_INSTALL ?= "${@" ".join(map(lambda s:
> "locale-base-%s" % s, d.getVar('IM
>  PSEUDO_PASSWD = "${IMAGE_ROOTFS}"
>
>  do_rootfs[nostamp] = "1"
> -do_rootfs[dirs] = "${TOPDIR}"
> +do_rootfs[dirs] = "${TOPDIR} ${WORKDIR}/intercept_scripts"
>  do_rootfs[lockfiles] += "${IMAGE_ROOTFS}.lock"
> -do_rootfs[cleandirs] += "${S}"
> +do_rootfs[cleandirs] += "${S} ${WORKDIR}/intercept_scripts"
>  do_build[nostamp] = "1"
>
>  # Must call real_do_rootfs() from inside here, rather than as a separate
>  # task, so that we have a single fakeroot context for the whole process.
>  do_rootfs[umask] = "022"
>
> +
> +run_intercept_scriptlets () {
> +       if [ -d ${WORKDIR}/intercept_scripts ]; then
> +               cd ${WORKDIR}/intercept_scripts
> +               echo "Running intercept scripts:"
> +               for script in *; do
> +                       if [ "$script" = "*" ]; then break; fi
>

This is personal choice but I'd use:

if [ ... ]; then
    break
fi

or

[ ... ] && break

The if in a single line seems confusing to read for me.


> +                       echo "> Executing $script"
> +                       chmod +x $script
> +                       ./$script
> +               done
> +       fi
> +}
> +
>  fakeroot do_rootfs () {
>         #set -x
>         # When use the rpm incremental image generation, don't remove the
> rootfs
> --
> 1.7.9.5
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>

Patch

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 7b24e4e..719d871 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -156,7 +156,7 @@  inherit ${IMAGE_CLASSES}
 
 IMAGE_POSTPROCESS_COMMAND ?= ""
 MACHINE_POSTPROCESS_COMMAND ?= ""
-ROOTFS_POSTPROCESS_COMMAND ?= ""
+ROOTFS_POSTPROCESS_COMMAND_prepend = "run_intercept_scriptlets; "
 
 # some default locales
 IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
@@ -166,15 +166,29 @@  LINGUAS_INSTALL ?= "${@" ".join(map(lambda s: "locale-base-%s" % s, d.getVar('IM
 PSEUDO_PASSWD = "${IMAGE_ROOTFS}"
 
 do_rootfs[nostamp] = "1"
-do_rootfs[dirs] = "${TOPDIR}"
+do_rootfs[dirs] = "${TOPDIR} ${WORKDIR}/intercept_scripts"
 do_rootfs[lockfiles] += "${IMAGE_ROOTFS}.lock"
-do_rootfs[cleandirs] += "${S}"
+do_rootfs[cleandirs] += "${S} ${WORKDIR}/intercept_scripts"
 do_build[nostamp] = "1"
 
 # Must call real_do_rootfs() from inside here, rather than as a separate
 # task, so that we have a single fakeroot context for the whole process.
 do_rootfs[umask] = "022"
 
+
+run_intercept_scriptlets () {
+	if [ -d ${WORKDIR}/intercept_scripts ]; then
+		cd ${WORKDIR}/intercept_scripts
+		echo "Running intercept scripts:"
+		for script in *; do
+			if [ "$script" = "*" ]; then break; fi
+			echo "> Executing $script"
+			chmod +x $script
+			./$script
+		done
+	fi
+}
+
 fakeroot do_rootfs () {
 	#set -x
 	# When use the rpm incremental image generation, don't remove the rootfs