Skip to contentSkip to conversation

Post-image addition, and customize removal

PATCH New Thomas Petazzoni 3 participants 14 messages Feb 7, 2013 – Feb 8, 2013 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Post-image addition, and customize removal

Hello,

Here is the third version of the post-image addition and customize removal patch set.

Compared to version 2:

* Slightly adjust the post-image config option prompt to use "Custom scripts" instead of "Custom script"

* Add Acked-by from Samuel Martin

* Slightly improve the documentation as per the suggestion of Samuel.

* Add one patch to change "Custom script" to "Custom scripts" for the post-build scripts config option.

Best regards,

Thomas

#1 lore raw

PATCH v3 1/6 Add a post-image script mechanism

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.

---
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(+)
Makefile +9 -0
index d9e5f24..3996d01 100644
@@ -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)
 
system/Config.in +18 -0
index fa01d91..bdd47c5 100644
@@ -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
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v3 1/6 Add a post-image script mechanism

2013/2/7 Thomas Petazzoni <[email protected]>:

Quoted 10 lines

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.

Quoted 4 lines
Signature · 1 line
Samuel
#3 lore raw

PATCH v3 1/6 Add a post-image script mechanism

In reply to Thomas Petazzoni
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> 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 <[email protected]> Thomas> Tested-by: "Yann E. MORIN" <[email protected]> Thomas> Acked-by: "Yann E. MORIN" <[email protected]> Thomas> Acked-by: Luca Ceresoli <[email protected]>
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.

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

PATCH v3 2/6 docs/manual: mention the new post-image mechanism

In reply to Thomas Petazzoni

---
v1->v2:
* Fix typos noticed by Yann.
v2->v3:
* Mention that the post-image scripts are executed as the user executing Buildroot, i.e generally not the root user. Suggested by Samuel Martin.

---
 docs/manual/customize-rootfs.txt |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
docs/manual/customize-rootfs.txt +22 -0
index fa04d85..97af580 100644
@@ -55,3 +55,25 @@ there are a few ways to customize the resulting target filesystem.
   target root filesystem in +package/customize/source+, and then
   enable this special package in the configuration system. _This
   method is marked as deprecated_.
+
+Note also that if you want to perform some specific actions *after*
+all filesystem images have been created (for example to automatically
+extract your root filesystem tarball in a location exported by your
+NFS server, or to create a special firmware image that bundles your
+root filesystem and kernel image, or any other custom action), you can
+specify a space-separated list of scripts in the
++BR2_ROOTFS_POST_IMAGE_SCRIPT+ configuration option.
+
+Each of those scripts will be called, with the path to the +images+
+output directory as first and unique argument, and will be executed
+with the main Buildroot source directory as the current
+directory. Those scripts will be executed as the user that executes
+Buildroot, which should normally not be the root user. Therefore, any
+action requiring root permissions in one of these post-image script
+will require special handling (usage of fakeroot or sudo), which is
+left to the script developer.
+
+Just like for the _post-build scripts_ mentionned above, you also have
+access to the following environment variables from your _post-image
+scripts_: +BUILDROOT_CONFIG+, +HOST_DIR+, +STAGING_DIR+, +TARGET_DIR+,
++BINARIES_DIR+ and +BASE_DIR+.
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v3 2/6 docs/manual: mention the new post-image mechanism

In reply to Thomas Petazzoni
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Thomas> Signed-off-by: Thomas Petazzoni <[email protected]> Thomas> Acked-by: "Yann E. MORIN" <[email protected]> Thomas> ---
v1-> v2:
Thomas> * Fix typos noticed by Yann.
v2-> v3:
Thomas> * Mention that the post-image scripts are executed as the user
Thomas> executing Buildroot, i.e generally not the root user. Suggested by
Thomas> Samuel Martin.
Thomas> ---

 Thomas>  docs/manual/customize-rootfs.txt |   22 ++++++++++++++++++++++

Thomas> 1 file changed, 22 insertions(+)

Thomas> diff --git a/docs/manual/customize-rootfs.txt b/docs/manual/customize-rootfs.txt Thomas> index fa04d85..97af580 100644
Thomas> --- a/docs/manual/customize-rootfs.txt
Thomas> +++ b/docs/manual/customize-rootfs.txt
Thomas> @@ -55,3 +55,25 @@ there are a few ways to customize the resulting target filesystem.

 Thomas>    target root filesystem in +package/customize/source+, and then
 Thomas>    enable this special package in the configuration system. _This
 Thomas>    method is marked as deprecated_.

Thomas> +
Thomas> +Note also that if you want to perform some specific actions *after* Thomas> +all filesystem images have been created (for example to automatically Thomas> +extract your root filesystem tarball in a location exported by your Thomas> +NFS server, or to create a special firmware image that bundles your Thomas> +root filesystem and kernel image, or any other custom action), you can Thomas> +specify a space-separated list of scripts in the
Thomas> ++BR2_ROOTFS_POST_IMAGE_SCRIPT+ configuration option. Thomas> +
Thomas> +Each of those scripts will be called, with the path to the +images+

I don't think this comma should be here.

Thomas> +output directory as first and unique argument, and will be executed Thomas> +with the main Buildroot source directory as the current Thomas> +directory. Those scripts will be executed as the user that executes Thomas> +Buildroot, which should normally not be the root user. Therefore, any Thomas> +action requiring root permissions in one of these post-image script Thomas> +will require special handling (usage of fakeroot or sudo), which is Thomas> +left to the script developer.
Thomas> +
Thomas> +Just like for the _post-build scripts_ mentionned above, you also have

s/mentionned/mentioned/

Committed with these fixes, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#7 lore raw

PATCH v3 3/6 package/customize: remove

In reply to Thomas Petazzoni

This mechanism of root filesystem customization has been deprecated since a long time, so let's remove it now.

---
Changelog v1 -> v2:
* Add entry in Config.in.legacy
* Remove "customize" from support/scripts/pkg-stats
Changelog v2 -> v3:
* Add Acked-by from Samuel Martin

---
 Config.in.legacy               |    8 ++++++++
 package/Config.in              |    1 -
 package/customize/Config.in    |    7 -------
 package/customize/customize.mk |   32 --------------------------------
 support/scripts/pkg-stats      |    1 -
 5 files changed, 8 insertions(+), 41 deletions(-)
 delete mode 100644 package/customize/Config.in
 delete mode 100644 package/customize/customize.mk
 delete mode 100644 package/customize/source/.empty
Config.in.legacy +8 -0
index 90a7b67..d90132c 100644
@@ -44,6 +44,14 @@ endif
 #
 # Legacy options since 2012.11
 #
+config BR2_PACKAGE_CUSTOMIZE
+	bool "customize package has been removed"
+	select BR2_LEGACY
+	help
+	  The 'customize' special package has been removed. Instead,
+	  we recommend to create either your own packages, or use a
+	  post-build script to customize your root filesystem. See
+	  Buildroot's documentation for more details.
 
 config BR2_PACKAGE_XSERVER_xorg
 	bool "X.org modular server"
package/Config.in +0 -1
index 8588951..2fad94d 100644
@@ -1,7 +1,6 @@
 menu "Package Selection for the target"
 
 source "package/busybox/Config.in"
-source "package/customize/Config.in"
 
 # Audio and video applications
 source "package/multimedia/Config.in"
package/customize/Config.in deleted +0 -7
deleted file mode 100644
index 8f8aaa2..0000000
@@ -1,7 +0,0 @@
-config BR2_PACKAGE_CUSTOMIZE
-	bool "customize"
-	depends on BR2_DEPRECATED
-	help
-	  Add custom stuff to your buildroot.
-
-	  (edit package/customize/customize.mk)
package/customize/customize.mk deleted +0 -32
deleted file mode 100644
index d2b8518..0000000
@@ -1,32 +0,0 @@
-#############################################################
-#
-# Any custom stuff you feel like doing....
-#
-#############################################################
-CUST_DIR:=package/customize/source
-
-$(BUILD_DIR)/.customize:
-	rm -f $(BUILD_DIR)/series
-	(cd $(CUST_DIR); \
-	 /bin/ls -d * > $(BUILD_DIR)/series || \
-	 touch $(BUILD_DIR)/series )
-	for f in `cat $(BUILD_DIR)/series`; do \
-		cp -af $(CUST_DIR)/$$f $(TARGET_DIR); \
-	done
-	rm -f $(BUILD_DIR)/series
-	touch $@
-
-customize: $(BUILD_DIR)/.customize
-
-customize-clean:
-	rm -f $(BUILD_DIR)/.customize
-
-.PHONY: customize
-#############################################################
-#
-# Toplevel Makefile options
-#
-#############################################################
-ifeq ($(BR2_PACKAGE_CUSTOMIZE),y)
-TARGETS+=customize
-endif
package/customize/source/.empty deleted +0 -0
deleted file mode 100644
index e69de29..0000000
support/scripts/pkg-stats +0 -1
index 929b8d1..a65a6ae 100755
@@ -92,7 +92,6 @@ for i in $(find boot/ linux/ package/ -name '*.mk' | sort) ; do
 	$i = "package/games/games.mk" -o \
 	$i = "package/gtk2-themes/gtk2-themes.mk" -o \
 	$i = "package/multimedia/multimedia.mk" -o \
- 	$i = "package/customize/customize.mk" -o \
  	$i = "package/pkg-autotools.mk" -o \
  	$i = "package/pkg-cmake.mk" -o \
  	$i = "package/pkg-generic.mk" -o \
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v3 4/6 docs/manual: no longer mention the package/customize thing

In reply to Thomas Petazzoni

---
Changelog v2 -> v3:
* Add Acked-by from Samuel Martin.

---
 docs/manual/customize-rootfs.txt |    6 ------
 1 file changed, 6 deletions(-)
docs/manual/customize-rootfs.txt +0 -6
index 97af580..95fa91f 100644
@@ -50,12 +50,6 @@ there are a few ways to customize the resulting target filesystem.
       stored
     - +BASE_DIR+: the base output directory
 
-* A special package, 'customize', stored in +package/customize+ can be
-  used. You can put all the files that you want to see in the final
-  target root filesystem in +package/customize/source+, and then
-  enable this special package in the configuration system. _This
-  method is marked as deprecated_.
-
 Note also that if you want to perform some specific actions *after*
 all filesystem images have been created (for example to automatically
 extract your root filesystem tarball in a location exported by your
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v3 4/6 docs/manual: no longer mention the package/customize thing

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Thomas> Signed-off-by: Thomas Petazzoni <[email protected]>

Committed the rest of the series without any comments, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#10 lore raw

PATCH v3 5/6 docs/manual: slightly reword the solutions to customize rootfs

In reply to Thomas Petazzoni

The order of the solutions to customize the root filesystem is
changed: we now mention the post-build script mechanism *before* the custom root filesystem skeleton mechanism, because the former is preferred over the latter.

In addition to this, we give a few more details about direct customization of the root filesystem in output/target, and about the custom target skeleton solution.

---
 docs/manual/customize-rootfs.txt |   29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)
docs/manual/customize-rootfs.txt +18 -11
index 95fa91f..fb0e877 100644
@@ -12,17 +12,11 @@ there are a few ways to customize the resulting target filesystem.
   simply make your changes here and run make afterwards - this will
   rebuild the target filesystem image. This method allows you to do
   anything to the target filesystem, but if you decide to completely
-  rebuild your toolchain and tools, these changes will be lost.
-  _Changes do not survive the +make clean+ command_.
-
-* Create your own 'target skeleton'. You can start with the default
-  skeleton available under +system/skeleton+ and then customize it to
-  suit your needs. The +BR2_ROOTFS_SKELETON_CUSTOM+ and
-  +BR2_ROOTFS_SKELETON_CUSTOM_PATH+ will allow you to specify the
-  location of your custom skeleton. These options can be found in the
-  +System configuration+ menu. At build time, the contents of the
-  skeleton are copied to output/target before any package
-  installation.
+  rebuild your toolchain and tools, these changes will be lost. This
+  solution is therefore only useful for quick tests only: _changes do
+  not survive the +make clean+ command_. Once you have validated your
+  changes, you should make sure that they will persist after a +make
+  clean+ by using one of the following methods.
 
 * Create a filesystem overlay: a tree of files that are copied directly
   over the target filesystem after it has been built.  Set
@@ -50,6 +44,19 @@ there are a few ways to customize the resulting target filesystem.
       stored
     - +BASE_DIR+: the base output directory
 
+* Create your own 'target skeleton'. You can start with the default
+  skeleton available under +system/skeleton+ and then customize it to
+  suit your needs. The +BR2_ROOTFS_SKELETON_CUSTOM+ and
+  +BR2_ROOTFS_SKELETON_CUSTOM_PATH+ will allow you to specify the
+  location of your custom skeleton. These options can be found in the
+  +System configuration+ menu. At build time, the contents of the
+  skeleton are copied to output/target before any package
+  installation. Note that this method is *not recommended*, as it
+  duplicates the entire skeleton, which prevents from taking advantage
+  of the fixes or improvements brought to the default Buildroot
+  skeleton. The recommended method is to use the _post-build script_
+  mechanism described in the previous item.
+
 Note also that if you want to perform some specific actions *after*
 all filesystem images have been created (for example to automatically
 extract your root filesystem tarball in a location exported by your
Signature · 1 line
1.7.9.5
#11 lore raw

PATCH v3 5/6 docs/manual: slightly reword the solutions to customize rootfs

2013/2/7 Thomas Petazzoni <[email protected]>:

Quoted 5 lines

The order of the solutions to customize the root filesystem is
changed: we now mention the post-build script mechanism *before* the custom root filesystem skeleton mechanism, because the former is preferred over the latter.

Quoted 7 lines

In addition to this, we give a few more details about direct customization of the root filesystem in output/target, and about the custom target skeleton solution.

Signature · 1 line
Samuel
#12 lore raw

PATCH v3 6/6 Adjust prompt for the post-build scripts option

In reply to Thomas Petazzoni

Since the post-image config option uses the plural for "Custom scripts", do the same for the post-build config option, for consistency.

---
 system/Config.in |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
system/Config.in +1 -1
index bdd47c5..1e4fff3 100644
@@ -261,7 +261,7 @@ config BR2_ROOTFS_OVERLAY
 	  ~ and .git, .svn and .hg directories.
 
 config BR2_ROOTFS_POST_BUILD_SCRIPT
-	string "Custom script to run before creating filesystem images"
+	string "Custom scripts to run before creating filesystem images"
 	default ""
 	help
 	  Specify a space-separated list of scripts to be run after the build
Signature · 1 line
1.7.9.5