Add BR2_ROOTFS_{PRE_BUILD|POST_{BUILD|FAKEROOT|IMAGE}}_SCRIPT_ARGS

Currently, one may only specify one list of arguments that are passed to
several scripts (BR2_ROOTFS_PRE_BUILD_SCRIPT, BR2_ROOTFS_POST_BUILD_SCRIPT,
BR2_ROOTFS_POST_FAKEROOT_SCRIPT and BR2_ROOTFS_POST_IMAGE_SCRIPT_ARGS).

So one has to be careful that the arguments for these scripts do noti
collide.

To allow specifiying dedicated arguments to each type of scripts, new
config options are introduced. For backward compatibility the value of
BR2_ROOTFS_POST_SCRIPT_ARGS is still passed to the scripts. But now one
can add specific arguments from the new config option.

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
[yann.morin.1998@free.fr:
  - mention common args in help texts
  - slight coding style beautification
  - slight rewording in commit log
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
Heiko Thiery 2024-03-28 15:09:20 +01:00 committed by Yann E. MORIN
parent 96b3295ca1
commit b7cc572208
5 changed files with 75 additions and 7 deletions

View File

@ -584,7 +584,10 @@ $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
prepare: $(BUILD_DIR)/buildroot-config/auto.conf prepare: $(BUILD_DIR)/buildroot-config/auto.conf
@$(foreach s, $(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT)), \ @$(foreach s, $(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT)), \
$(call MESSAGE,"Executing pre-build script $(s)"); \ $(call MESSAGE,"Executing pre-build script $(s)"); \
$(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep)) $(EXTRA_ENV) $(s) \
$(TARGET_DIR) \
$(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS)) \
$(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT_ARGS))$(sep))
.PHONY: world .PHONY: world
world: target-post-image world: target-post-image
@ -801,7 +804,10 @@ endif # merged /usr
$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \ $(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
@$(call MESSAGE,"Executing post-build script $(s)")$(sep) \ @$(call MESSAGE,"Executing post-build script $(s)")$(sep) \
$(Q)$(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep)) $(Q)$(EXTRA_ENV) $(s) \
$(TARGET_DIR) \
$(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS)) \
$(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT_ARGS))$(sep))
touch $(TARGET_DIR)/usr touch $(TARGET_DIR)/usr
@ -819,7 +825,10 @@ target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize
$(Q)mkdir -p $(BINARIES_DIR) $(Q)mkdir -p $(BINARIES_DIR)
@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \ @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
$(call MESSAGE,"Executing post-image script $(s)"); \ $(call MESSAGE,"Executing post-image script $(s)"); \
$(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep)) $(EXTRA_ENV) $(s) \
$(BINARIES_DIR) \
$(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS)) \
$(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT_ARGS))$(sep))
.PHONY: source .PHONY: source
source: $(foreach p,$(PACKAGES),$(p)-all-source) source: $(foreach p,$(PACKAGES),$(p)-all-source)

View File

@ -26,6 +26,11 @@ arguments will be passed to the script too. All the scripts will be
passed the exact same set of arguments, it is not possible to pass passed the exact same set of arguments, it is not possible to pass
different sets of arguments to each script. different sets of arguments to each script.
Note that the arguments from +BR2_ROOTFS_POST_SCRIPT_ARGS+ will also be
passed to post-build and post-fakeroot scripts. If you want to use
arguments that are only used for the post-image scripts you can use
+BR2_ROOTFS_POST_IMAGE_SCRIPT_ARGS+.
Again just like for the post-build scripts, the scripts have access to Again just like for the post-build scripts, the scripts have access to
the environment variables +BR2_CONFIG+, +HOST_DIR+, +STAGING_DIR+, the environment variables +BR2_CONFIG+, +HOST_DIR+, +STAGING_DIR+,
+TARGET_DIR+, +BUILD_DIR+, +BINARIES_DIR+, +CONFIG_DIR+ and +TARGET_DIR+, +BUILD_DIR+, +BINARIES_DIR+, +CONFIG_DIR+ and

View File

@ -56,6 +56,12 @@ The post-build scripts are run with the main Buildroot tree as current
passed to the script too. All the scripts will be passed the exact passed to the script too. All the scripts will be passed the exact
same set of arguments, it is not possible to pass different sets of same set of arguments, it is not possible to pass different sets of
arguments to each script. arguments to each script.
Note that the arguments from +BR2_ROOTFS_POST_SCRIPT_ARGS+ will also be
passed to post-image and post-fakeroot scripts. If you want to use
arguments that are only used for the post-build scripts you can use
+BR2_ROOTFS_POST_BUILD_SCRIPT_ARGS+.
+ +
In addition, you may also use these environment variables: In addition, you may also use these environment variables:

View File

@ -182,7 +182,7 @@ $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES)
$$(call PRINTF,$$($$(hook))) >> $$(FAKEROOT_SCRIPT)$$(sep)) $$(call PRINTF,$$($$(hook))) >> $$(FAKEROOT_SCRIPT)$$(sep))
$$(foreach s,$$(call qstrip,$$(BR2_ROOTFS_POST_FAKEROOT_SCRIPT)),\ $$(foreach s,$$(call qstrip,$$(BR2_ROOTFS_POST_FAKEROOT_SCRIPT)),\
echo "echo '$$(TERM_BOLD)>>> Executing fakeroot script $$(s)$$(TERM_RESET)'" >> $$(FAKEROOT_SCRIPT); \ echo "echo '$$(TERM_BOLD)>>> Executing fakeroot script $$(s)$$(TERM_RESET)'" >> $$(FAKEROOT_SCRIPT); \
echo $$(EXTRA_ENV) $$(s) $$(TARGET_DIR) $$(BR2_ROOTFS_POST_SCRIPT_ARGS) >> $$(FAKEROOT_SCRIPT)$$(sep)) echo $$(EXTRA_ENV) $$(s) $$(TARGET_DIR) $$(BR2_ROOTFS_POST_SCRIPT_ARGS) $$(BR2_ROOTFS_POST_FAKEROOT_SCRIPT_ARGS) >> $$(FAKEROOT_SCRIPT)$$(sep))
$$(foreach hook,$$(ROOTFS_$(2)_PRE_GEN_HOOKS),\ $$(foreach hook,$$(ROOTFS_$(2)_PRE_GEN_HOOKS),\
$$(call PRINTF,$$($$(hook))) >> $$(FAKEROOT_SCRIPT)$$(sep)) $$(call PRINTF,$$($$(hook))) >> $$(FAKEROOT_SCRIPT)$$(sep))

View File

@ -708,8 +708,56 @@ config BR2_ROOTFS_POST_SCRIPT_ARGS
arguments to each script. arguments to each script.
Note also, as stated in their respective help text, that the Note also, as stated in their respective help text, that the
first argument to each post-build or post-image script is the first argument to each script is the target directory / images
target directory / images directory. The arguments in this directory. The arguments in this option will be passed *after*
option will be passed *after* those. those.
config BR2_ROOTFS_PRE_BUILD_SCRIPT_ARGS
string "Extra arguments passed to BR2_ROOTFS_PRE_BUILD_SCRIPT"
depends on BR2_ROOTFS_PRE_BUILD_SCRIPT != ""
help
Pass these additional arguments to the pre-build script.
Note also, as stated in the respective help text, that the
first argument to each script is the target directory, then
the common arguments specified in BR2_ROOTFS_POST_SCRIPT_ARGS
above, and then the arguments in this option will be passed
*after* those.
config BR2_ROOTFS_POST_BUILD_SCRIPT_ARGS
string "Extra arguments passed to BR2_ROOTFS_POST_BUILD_SCRIPT"
depends on BR2_ROOTFS_POST_BUILD_SCRIPT != ""
help
Pass these additional arguments to the post-build script.
Note also, as stated in the respective help text, that the
first argument to each script is the target directory, then
the common arguments specified in BR2_ROOTFS_POST_SCRIPT_ARGS
above, and then the arguments in this option will be passed
*after* those.
config BR2_ROOTFS_POST_FAKEROOT_SCRIPT_ARGS
string "Extra arguments passed to BR2_ROOTFS_POST_FAKEROOT_SCRIPT"
depends on BR2_ROOTFS_POST_FAKEROOT_SCRIPT != ""
help
Pass these additional arguments to the post-fakeroot script.
Note also, as stated in the respective help text, that the
first argument to each script is the target directory, then
the common arguments specified in BR2_ROOTFS_POST_SCRIPT_ARGS
above, and then the arguments in this option will be passed
*after* those.
config BR2_ROOTFS_POST_IMAGE_SCRIPT_ARGS
string "Extra arguments passed to POST_IMAGE_SCRIPT"
depends on BR2_ROOTFS_POST_IMAGE_SCRIPT != ""
help
Pass these additional arguments to the post-image script.
Note also, as stated in the respective help text, that the
first argument to each script is the images directory, then
the common arguments specified in BR2_ROOTFS_POST_SCRIPT_ARGS
above, and then the arguments in this option will be passed
*after* those.
endmenu endmenu