Patchwork [v3,1/6] Add a post-image script mechanism

login
register
mail settings
Submitter Thomas Petazzoni
Date Feb. 7, 2013, 9:58 p.m.
Message ID <1360274328-14754-2-git-send-email-thomas.petazzoni@free-electrons.com>
Download mbox | patch
Permalink /patch/219004/
State Accepted
Headers show

Comments

Thomas Petazzoni - Feb. 7, 2013, 9:58 p.m.
Just like we have a post-build script mechanism that gets executed
after the build of all packages but before the creation of the
filesystem images, let's introduce a post-image script mechanism, that
gets executed once all filesystem images have been generated.

This can for example be used to call a tool building a firmware image
from different images generated by Buildroot, or automatically extract
the tarball root filesystem image into some location exported by NFS,
or any other custom action.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Acked-by: Luca Ceresoli <luca@lucaceresoli.net>
---
v2 -> v3:
 * Change 'script' -> 'scripts' in the config option prompt, as
   suggested by Samuel Martin.
---
 Makefile         |    9 +++++++++
 system/Config.in |   18 ++++++++++++++++++
 2 files changed, 27 insertions(+)
Samuel Martin - Feb. 8, 2013, 5:28 a.m.
2013/2/7 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>:
> Just like we have a post-build script mechanism that gets executed
> after the build of all packages but before the creation of the
> filesystem images, let's introduce a post-image script mechanism, that
> gets executed once all filesystem images have been generated.
>
> This can for example be used to call a tool building a firmware image
> from different images generated by Buildroot, or automatically extract
> the tarball root filesystem image into some location exported by NFS,
> or any other custom action.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Acked-by: Luca Ceresoli <luca@lucaceresoli.net>
Acked-by: Samuel Martin <s.martin49@gmail.com>
Peter Korsgaard - Feb. 8, 2013, 8:56 p.m.
>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

 Thomas> Just like we have a post-build script mechanism that gets executed
 Thomas> after the build of all packages but before the creation of the
 Thomas> filesystem images, let's introduce a post-image script mechanism, that
 Thomas> gets executed once all filesystem images have been generated.

 Thomas> This can for example be used to call a tool building a firmware image
 Thomas> from different images generated by Buildroot, or automatically extract
 Thomas> the tarball root filesystem image into some location exported by NFS,
 Thomas> or any other custom action.

 Thomas> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
 Thomas> Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
 Thomas> Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
 Thomas> Acked-by: Luca Ceresoli <luca@lucaceresoli.net>
 Thomas> ---
 Thomas> v2 -> v3:
 Thomas>  * Change 'script' -> 'scripts' in the config option prompt, as
 Thomas>    suggested by Samuel Martin.
 Thomas> ---
 Thomas>  Makefile         |    9 +++++++++
 Thomas>  system/Config.in |   18 ++++++++++++++++++
 Thomas>  2 files changed, 27 insertions(+)

 Thomas> diff --git a/Makefile b/Makefile
 Thomas> index d9e5f24..3996d01 100644
 Thomas> --- a/Makefile
 Thomas> +++ b/Makefile
 Thomas> @@ -353,6 +353,8 @@ endif
 
 Thomas>  include fs/common.mk
 
 Thomas> +TARGETS+=target-post-image
 Thomas> +
 Thomas>  TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
 Thomas>  TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
 Thomas>  TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
 Thomas> @@ -555,6 +557,13 @@ target-generatelocales: host-localedef
 Thomas>  	done
 Thomas>  endif
 
 Thomas> +target-post-image:
 Thomas> +ifneq ($(BR2_ROOTFS_POST_IMAGE_SCRIPT),)

This is always true as BR2_ROOTFS_POST_IMAGE_SCRIPT atleast contains "",
so I changed this to check for "" like the post-build script and
committed, thanks.

Patch

diff --git a/Makefile b/Makefile
index d9e5f24..3996d01 100644
--- a/Makefile
+++ b/Makefile
@@ -353,6 +353,8 @@  endif
 
 include fs/common.mk
 
+TARGETS+=target-post-image
+
 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
@@ -555,6 +557,13 @@  target-generatelocales: host-localedef
 	done
 endif
 
+target-post-image:
+ifneq ($(BR2_ROOTFS_POST_IMAGE_SCRIPT),)
+	@$(call MESSAGE,"Executing post-image script\(s\)")
+	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
+		$(s) $(BINARIES_DIR)$(sep))
+endif
+
 toolchain-eclipse-register:
 	./support/scripts/eclipse-register-toolchain `readlink -f $(O)` $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
 
diff --git a/system/Config.in b/system/Config.in
index fa01d91..bdd47c5 100644
--- a/system/Config.in
+++ b/system/Config.in
@@ -276,4 +276,22 @@  config BR2_ROOTFS_POST_BUILD_SCRIPT
 	  only argument. Make sure the exit code of those scripts are 0,
 	  otherwise make will stop after calling them.
 
+config BR2_ROOTFS_POST_IMAGE_SCRIPT
+	string "Custom scripts to run after creating filesystem images"
+	default ""
+	help
+	  Specify a space-separated list of scripts to be run after
+	  the build has finished and after Buildroot has packed the
+	  files into selected filesystem images.
+
+	  This can for example be used to call a tool building a
+	  firmware image from different images generated by Buildroot,
+	  or automatically extract the tarball root filesystem image
+	  into some location exported by NFS, or any other custom
+	  action.
+
+	  These scripts are called with the images directory name as
+	  first and only argument. The script is executed from the
+	  main Buildroot source directory as the current directory.
+
 endmenu