[PATCH v2] imagebuilder, sdk: unset BINARY_FOLDER and DOWNLOAD_FOLDER in final archives

Sven Roederer devel-sven at geroedel.de
Sat Apr 24 22:48:24 BST 2021


Using these config-options to customize the folders used at build-time makes these
folder settings appear in generated archives. This causes the archives to be not
portable, as they going to use the build-time folders on the new systems. Errors
look like for the imagebuilder:

  mkdir: cannot create directory '/mnt/build': Permission denied
  Makefile:116: recipe for target '_call_image' failed
  make[2]: *** [_call_image] Error 1
  Makefile:241: recipe for target 'image' failed
  make[1]: *** [image] Error 2

The build-time settings of these folders are passed into the archives via .config
for the imagebuilder and via Config.in and Config.build for the sdk.
The expected behavior is that after unpacking sdk and imagebuilder act like these
settings have the default, using intree folders. So unset or filter out the build-
time settings.

Signed-off-by: Sven Roederer <devel-sven at geroedel.de>
---

This is an rewrite and extension of the patch send on 11. April.


 target/imagebuilder/Makefile | 2 ++
 target/sdk/Makefile          | 1 +
 target/sdk/convert-config.pl | 9 ++++++++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/target/imagebuilder/Makefile b/target/imagebuilder/Makefile
index f9c08776a8..ef7fd3f25e 100644
--- a/target/imagebuilder/Makefile
+++ b/target/imagebuilder/Makefile
@@ -29,6 +29,8 @@ $(BIN_DIR)/$(IB_NAME).tar.xz: clean
 	mkdir -p $(IB_KDIR) $(IB_LDIR) $(PKG_BUILD_DIR)/staging_dir/host/lib \
 		$(PKG_BUILD_DIR)/target $(PKG_BUILD_DIR)/scripts $(IB_DTSDIR)
 	-cp $(TOPDIR)/.config $(PKG_BUILD_DIR)/.config
+	$(SED) 's/^CONFIG_BINARY_FOLDER=.*/# CONFIG_BINARY_FOLDER was reset by Imagebuilder/' $(PKG_BUILD_DIR)/.config
+	$(SED) 's/^CONFIG_DOWNLOAD_FOLDER=.*/# CONFIG_DOWNLOAD_FOLDER was reset by Imagebuilder/' $(PKG_BUILD_DIR)/.config
 	$(CP) -L \
 		$(INCLUDE_DIR) $(SCRIPT_DIR) \
 		$(TOPDIR)/rules.mk \
diff --git a/target/sdk/Makefile b/target/sdk/Makefile
index 0606621192..5330d14955 100644
--- a/target/sdk/Makefile
+++ b/target/sdk/Makefile
@@ -159,6 +159,7 @@ $(BIN_DIR)/$(SDK_NAME).tar.xz: clean
 	$(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(SDK_BUILD_DIR)/include/version.mk
 	$(SED) 's,^# SOURCE_DATE_EPOCH:=.*,SOURCE_DATE_EPOCH:=$(SOURCE_DATE_EPOCH),g' $(SDK_BUILD_DIR)/include/version.mk
 	$(SED) '/LINUX_VERMAGIC:=/ { s,unknown,$(LINUX_VERMAGIC),g }' $(SDK_BUILD_DIR)/include/kernel.mk
+	$(SED) 's,default "$(CONFIG_DOWNLOAD_FOLDER)",default "",' $(SDK_BUILD_DIR)/Config.in
 	find $(SDK_BUILD_DIR) -name .git | $(XARGS) rm -rf
 	find $(SDK_BUILD_DIR) -name .svn | $(XARGS) rm -rf
 	find $(SDK_BUILD_DIR) -name CVS | $(XARGS) rm -rf
diff --git a/target/sdk/convert-config.pl b/target/sdk/convert-config.pl
index f73744af09..f6bc831d3a 100755
--- a/target/sdk/convert-config.pl
+++ b/target/sdk/convert-config.pl
@@ -9,7 +9,14 @@ while (<>) {
 	chomp;
 	next if /^CONFIG_SIGNED_PACKAGES/;
 
-	if (/^CONFIG_([^=]+)=(.*)$/) {
+	if (/^CONFIG_((BINARY)|(DOWNLOAD))_FOLDER=(.*)$/) {
+		# We don't want to preserve the build setting of
+		# BINARY_FOLDER and DOWNLOAD_FOLDER.
+		$var = "$1_FOLDER";
+		$val = '""';
+		$type = "string";
+#		warn "DEBUG: type: $type found for symbol CONFIG_$var=$val\n";
+	} elsif (/^CONFIG_([^=]+)=(.*)$/) {
 		$var = $1;
 		$val = $2;
 
-- 
2.17.1




More information about the openwrt-devel mailing list