Add BR2_ROOTFS_POST_{PRE_BUILD|POST_BUILD|FAKEROOT|IMAGE}_SCRIPT_ARGS
PATCH v2 1/1 Add BR2_ROOTFS_POST_{PRE_BUILD|POST_BUILD|FAKEROOT|IMAGE}_SCRIPT_ARGS
You only can 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 you have to be careful that the arguments for these scripts do not collide.
To allow specifiying dedicated arguments to each of the script the new config options are introduced. For backward compatibility the value of BR2_ROOTFS_POST_SCRIPT_ARGS is still passed to the scripts. But now you can add specfic arguments from the new config option.
---
v2:
- now add the specific arguments after the ones from BR2_ROOTFS_POST_SCRIPT_ARGS
- reword the docu
- reword the commit message
Makefile | 12 +++++-- docs/manual/customize-post-image.adoc | 5 +++ docs/manual/customize-rootfs.adoc | 6 ++++ fs/common.mk | 2 +- system/Config.in | 52 +++++++++++++++++++++++---- 5 files changed, 67 insertions(+), 10 deletions(-)
Makefile +9 -3
@@ -584,7 +584,9 @@ $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG) prepare: $(BUILD_DIR)/buildroot-config/auto.conf @$(foreach s, $(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT)), \ $(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 world: target-post-image
@@ -801,7 +803,9 @@ endif # merged /usr $(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \ @$(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
@@ -819,7 +823,9 @@ target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize $(Q)mkdir -p $(BINARIES_DIR) @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \ $(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 source: $(foreach p,$(PACKAGES),$(p)-all-source)
docs/manual/customize-post-image.adoc +5 -0
@@ -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 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 the environment variables +BR2_CONFIG+, +HOST_DIR+, +STAGING_DIR+, +TARGET_DIR+, +BUILD_DIR+, +BINARIES_DIR+, +CONFIG_DIR+ and
docs/manual/customize-rootfs.adoc +6 -0
@@ -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 same set of arguments, it is not possible to pass different sets of 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:
fs/common.mk +1 -1
@@ -182,7 +182,7 @@ $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES) $$(call PRINTF,$$($$(hook))) >> $$(FAKEROOT_SCRIPT)$$(sep)) $$(foreach s,$$(call qstrip,$$(BR2_ROOTFS_POST_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),\ $$(call PRINTF,$$($$(hook))) >> $$(FAKEROOT_SCRIPT)$$(sep))
system/Config.in +46 -6
66 lines not on this page · raw message
--
2.39.2
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Yann E. MORIN
AppliedHeiko, All,
On 2024-03-28 15:09 +0100, Heiko Thiery spake thusly:
Quoted 6 lines
You only can 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_SCRIPTandBR2_ROOTFS_POST_IMAGE_SCRIPT_ARGS).So you have to be careful that the arguments for these scripts do not collide.
Quoted 7 lines
To allow specifiying dedicated arguments to each of the script the new config options are introduced. For backward compatibility the value of
BR2_ROOTFS_POST_SCRIPT_ARGSis still passed to the scripts. But now you can add specfic arguments from the new config option.Signed-off-by Heiko Thiery <[email protected]>---
[--SNIP--]
Makefile $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG) · line 589
Quoted 12 lines
Makefile +3
-1@@ -584,7 +584,9 @@ $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG) prepare: $(BUILD_DIR)/buildroot-config/auto.conf @$(foreach s, $(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT)), \ $(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))
I've rewrapped this in a more common way:
$(EXTRA_ENV) $(s) \
$(TARGET_DIR) \
$(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS)) \
$(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT_ARGS))Makefile endif # merged /usr · line 808
Quoted 10 lines
Makefile +3
-1.PHONY: world world: target-post-image@@ -801,7 +803,9 @@ endif # merged /usr $(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \ @$(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))
Ditto.
Makefile target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize · line 828
Quoted 10 lines
Makefile +3
-1touch $(TARGET_DIR)/usr@@ -819,7 +823,9 @@ target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize $(Q)mkdir -p $(BINARIES_DIR) @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \ $(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))
Ditto.
[--SNIP--]
fs/common.mk $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES) · line 185
Quoted 10 lines
fs/common.mk +1
-1@@ -182,7 +182,7 @@ $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES) $$(call PRINTF,$$($$(hook))) >> $$(FAKEROOT_SCRIPT)$$(sep)) $$(foreach s,$$(call qstrip,$$(BR2_ROOTFS_POST_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))
But not here.
[--SNIP--]
fs/common.mk $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES)
Quoted 9 lines
fs/common.mk +9
-0+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. + The arguments in this option will be passed *after* those.
I fixed those help texts to also mention that common args are passed, and thus the specific args are passed after.
Applied to master, thanks.
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Yann E. MORIN
AppliedHeiko, All,
iReply v2, because I'm dumb and too hasty...
On 2024-03-28 15:09 +0100, Heiko Thiery spake thusly:
[--SNIP--]
Quoted 8 lines
system/Config.in +0
-0@@ -695,20 +695,60 @@ config BR2_ROOTFS_POST_IMAGE_SCRIPT config BR2_ROOTFS_POST_SCRIPT_ARGS string "Extra arguments passed to custom scripts"
system/Config.in config BR2_ROOTFS_POST_IMAGE_SCRIPT · line 704
Quoted 10 lines
system/Config.in +4
-3- depends on BR2_ROOTFS_POST_BUILD_SCRIPT != "" \ + depends on BR2_ROOTFS_PRE_BUILD_SCRIPT != "" \ + || BR2_ROOTFS_POST_BUILD_SCRIPT != "" \ || BR2_ROOTFS_POST_FAKEROOT_SCRIPT != "" \ || BR2_ROOTFS_POST_IMAGE_SCRIPT != "" help - Pass these additional arguments to each post-build or - post-image scripts. + Pass these additional arguments to each pre-build, post-build, + post-fakeroot and post-image scripts.
Those two huinks were unrelated to the change: in fact they were a fix for an actual issue that pre-existed.
I've split those into their own commit, wrote a commit log that explains the issue, and applied that commit before adding the new options.
This will make it easier to backport to stable branches.
Applied to master, thanks.
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot