Post-image script feature and other related fixes
PATCH v2 1/1 Post-image script feature and other related fixes
Hello,
As discussed during the Buildroot meeting, here is a new version of the post-image thing and the removal of the customize package.
The number of changes is fairly light:
* Fixed a few typos in the documentation
* Added BR2_PACKAGE_CUSTOMIZE in Config.in.legacy
* Removed the special handling of the customize package from pkg-stats.
Best regards,
Thomas
PATCH v2 1/5 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.
--- Makefile | 9 +++++++++ system/Config.in | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+)
Makefile +9 -0
@@ -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
@@ -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 script 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
PATCH v2 1/5 Add a post-image script mechanism
Hi Thomas,
2013/2/6 Thomas Petazzoni <[email protected]>:
Quoted 51 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.
Signed-off-by Thomas Petazzoni <[email protected]>Tested-by "Yann E. MORIN" <[email protected]>Acked-by "Yann E. MORIN" <[email protected]>Acked-by Luca Ceresoli <[email protected]>--- Makefile | 9 +++++++++ system/Config.in | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+)Makefile +9
-0@@ -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 +0
-0
system/Config.in config BR2_ROOTFS_POST_BUILD_SCRIPT · line 279
Quoted 4 lines
system/Config.in +1
-0@@ -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
well, it's a bit weird to have singular here since it stores a list of scripts...
anyway, it's the same for BR2_ROOTFS_POST_BUILD_SCRIPT.
system/Config.in config BR2_ROOTFS_POST_BUILD_SCRIPT · line 280
Quoted 1 line
system/Config.in +1
-0+ string "Custom script to run after creating filesystem images"
s/Custom script/Custom scripts/
Quoted 8 lines
system/Config.in +8
-0+ 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,
system/Config.in config BR2_ROOTFS_POST_BUILD_SCRIPT
Quoted 10 lines
system/Config.in +8
-1+ 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 --
Regards,
Signature · 1 line
Samuel
PATCH v2 2/5 docs/manual: mention the new post-image mechanism
In reply to Thomas Petazzoni---v1->v2:
* Fix typos noticed by Yann.
--- docs/manual/customize-rootfs.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
docs/manual/customize-rootfs.txt +15 -0
@@ -55,3 +55,18 @@ 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. Also, 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
PATCH v2 2/5 docs/manual: mention the new post-image mechanism
Hi Thomas,
2013/2/6 Thomas Petazzoni <[email protected]>:
Quoted 22 lines
Signed-off-by Thomas Petazzoni <[email protected]>Acked-by "Yann E. MORIN" <[email protected]>---
v1->v2:
* Fix typos noticed by Yann.--- docs/manual/customize-rootfs.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+)docs/manual/customize-rootfs.txt +5
-0@@ -55,3 +55,18 @@ 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
docs/manual/customize-rootfs.txt there are a few ways to customize the resulting target filesystem. · line 72
Quoted 10 lines
docs/manual/customize-rootfs.txt +10
-0+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. Also, 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+.
Nothing about how these post-image scripts are run (no fakeroot, and so on).
Regards,
Signature · 1 line
Samuel
PATCH v2 2/5 docs/manual: mention the new post-image mechanism
Dear Samuel Martin,
Quoted 18 lines · Samuel Martin
Quoted 18 lines
(quoted diff) +0
-0
b/docs/manual/customize-rootfs.txtindex fa04d85..f1d336a 100644docs/manual/customize-rootfs.txt +0
-0@@ -55,3 +55,18 @@ there are a few ways to customize the resultingtarget filesystem. target root filesystem in +package/customize/source+, and then enable this special package in the configuration system.
_Thismethod is marked asdeprecated_.docs/manual/customize-rootfs.txt +3
-0+ +Note also that if you want to perform some specific actions *after* +all filesystem images have been created (for example toautomatically +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
Quoted 8 lines
Quoted 5 lines
executed with the main +Buildroot source directory as the current directory. Also, just like +for the _post-build
scripts_mentionned above, you also have access to +the following environment variables from your _post-imagescripts_: ++BUILDROOT_CONFIG+, +HOST_DIR+, +STAGING_DIR+, +TARGET_DIR+, ++BINARIES_DIR+ and +BASE_DIR+.Nothing about how these post-image scripts are run (no fakeroot, and so on).
I am not sure what you would like to see added exactly. Since they are executed outside of fakeroot, then they are just executed after the filesystem images are created, and that's it, no?
Of course, if those scripts were executed inside fakeroot, it should be mentioned clearly. But since it's not the case, is it important to mention that they are executed outside of fakeroot? We could give a lot of things that those scripts do /not/ do, no? My feeling is that it would add confusion, but I don't have a strong feeling about this.
Or maybe you were thinking about something else than just "These scripts are executed outside of the fakeroot environment" ?
Best regards,
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v2 2/5 docs/manual: mention the new post-image mechanism
Thomas,
2013/2/7 Thomas Petazzoni <[email protected]>:
[...]
Quoted 4 lines
I am not sure what you would like to see added exactly. Since they are executed outside of fakeroot, then they are just executed after the filesystem images are created, and that's it, no?
Quoted 8 lines
Of course, if those scripts were executed inside fakeroot, it should be mentioned clearly. But since it's not the case, is it important to mention that they are executed outside of fakeroot? We could give a lot of things that those scripts do /not/ do, no? My feeling is that it would add confusion, but I don't have a strong feeling about this.
Or maybe you were thinking about something else than just "These scripts are executed outside of the fakeroot environment" ?
My point is that these scripts will most likely try to do things that requires root permissions;
so it may be good to warn the user that this should be handled by the scripts themselves.
Regards,
Signature · 1 line
Samuel
PATCH v2 3/5 package/customize: remove
In reply to Thomas PetazzoniThis 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
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
support/scripts/pkg-stats +0 -1
@@ -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
PATCH v2 3/5 package/customize: remove
2013/2/6 Thomas Petazzoni <[email protected]>:
Quoted 7 lines
This mechanism of root filesystem customization has been deprecated since a long time, so let's remove it now.
Signed-off-by Thomas Petazzoni <[email protected]>Acked-by "Yann E. MORIN" <[email protected]>Acked-by Luca Ceresoli <[email protected]>
Signature · 1 line
Samuel
PATCH v2 4/5 docs/manual: no longer mention the package/customize thing
In reply to Thomas Petazzoni--- docs/manual/customize-rootfs.txt | 6 ------ 1 file changed, 6 deletions(-)
docs/manual/customize-rootfs.txt +0 -6
@@ -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
PATCH v2 4/5 docs/manual: no longer mention the package/customize thing
2013/2/6 Thomas Petazzoni <[email protected]>:
Quoted 3 lines
Signed-off-by Thomas Petazzoni <[email protected]>Acked-by "Yann E. MORIN" <[email protected]>Acked-by Luca Ceresoli <[email protected]>
Signature · 1 line
Samuel
PATCH v2 4/5 docs/manual: no longer mention the package/customize thing
2013/2/7 Samuel Martin <[email protected]>:
Quoted 5 lines
2013/2/6 Thomas Petazzoni <[email protected]>:
Quoted 3 lines
Signed-off-by Thomas Petazzoni <[email protected]>Acked-by "Yann E. MORIN" <[email protected]>Acked-by Luca Ceresoli <[email protected]>Acked-by "Samuel Martin" <[email protected]>
Oops, wrong ack!
Please use this one:
Signature · 1 line
Samuel
PATCH v2 5/5 docs/manual: slightly reword the solutions to customize rootfs
In reply to Thomas PetazzoniThe 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
@@ -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