[OpenWrt-Devel] [PATCH 11/14] target/imagebuilder: Add ability to menuconfig image options

openwrt at daniel.thecshore.com openwrt at daniel.thecshore.com
Sun Jan 3 01:02:59 EST 2016


From: Daniel Dickinson <openwrt at daniel.thecshore.com>

It is convenient to be able to change image generation options
(including types of images, version information, and things
like squashfs parameters) at the time of image generations,
therefore add ability to do image generation menuconfig in
ImageBuilder.

Signed-off-by: Daniel Dickinson <openwrt at daniel.thecshore.com>
---
 target/convert-config.pl            | 41 +++++++++++++++++++++++++++++++++++++
 target/imagebuilder/Makefile        | 11 +++++++++-
 target/imagebuilder/files/Config.in | 23 +++++++++++++++++++++
 target/imagebuilder/files/Makefile  | 21 +++++++++++++++++++
 target/sdk/Makefile                 |  2 +-
 target/sdk/convert-config.pl        | 41 -------------------------------------
 6 files changed, 96 insertions(+), 43 deletions(-)
 create mode 100755 target/convert-config.pl
 create mode 100644 target/imagebuilder/files/Config.in
 delete mode 100755 target/sdk/convert-config.pl

diff --git a/target/convert-config.pl b/target/convert-config.pl
new file mode 100755
index 0000000..e701b42
--- /dev/null
+++ b/target/convert-config.pl
@@ -0,0 +1,41 @@
+#!/usr/bin/env perl
+use strict;
+
+print <<EOF;
+config ALL
+	bool
+	default y
+
+EOF
+
+while (<>) {
+	chomp;
+	next if /^CONFIG_SIGNED_PACKAGES/;
+	next unless /^CONFIG_([^=]+)=(.*)$/;
+
+	my $var = $1;
+	my $val = $2;
+	my $type;
+
+	next if $var eq 'ALL';
+
+	if ($val eq 'y') {
+		$type = "bool";
+	} elsif ($val eq 'm') {
+		$type = "tristate";
+	} elsif ($val =~ /^".*"$/) {
+		$type = "string";
+	} elsif ($val =~ /^\d+$/) {
+		$type = "int";
+	} else {
+		warn "WARNING: no type found for symbol CONFIG_$var=$val\n";
+		next;
+	}
+
+	print <<EOF;
+config $var
+	$type
+	default $val
+
+EOF
+}
diff --git a/target/imagebuilder/Makefile b/target/imagebuilder/Makefile
index 0f3fc2e..bcde7ff 100644
--- a/target/imagebuilder/Makefile
+++ b/target/imagebuilder/Makefile
@@ -25,11 +25,20 @@ $(BIN_DIR)/$(IB_NAME).tar.bz2: clean
 	rm -rf $(PKG_BUILD_DIR)
 	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
+	cd $(TOPDIR) && find target/linux -name 'Config.in' -print0 | xargs -0 -I\{\} sh -c 'mkdir -p $(PKG_BUILD_DIR)/$$(dirname {}); $(CP) -L {} $(PKG_BUILD_DIR)/'
+	mkdir -p $(PKG_BUILD_DIR)/config
+	$(TOPDIR)/target/convert-config.pl $(TOPDIR)/.config > $(PKG_BUILD_DIR)/config/fromdotconfig.in
+	mkdir -p $(PKG_BUILD_DIR)/target
+	$(CP) $(TOPDIR)/target/Config.in $(PKG_BUILD_DIR)/target/
+	sed -e 's/CONFIG_SIGNED_PACKAGES=y/# CONFIG_SIGNED_PACKAGES is not set/' $(TOPDIR)/.config | \
+		sed -e 's/CONFIG_MAKE_TOOLCHAIN=y/# CONFIG_MAKE_TOOLCHAIN is not set/' \
+		> $(PKG_BUILD_DIR)/.config
 	$(CP) \
 		$(INCLUDE_DIR) $(SCRIPT_DIR) \
 		$(TOPDIR)/rules.mk \
 		./files/Makefile \
+		$(TOPDIR)/config \
+		./files/Config.in \
 		./files/repositories.conf \
 		$(TMP_DIR)/.targetinfo \
 		$(TMP_DIR)/.packageinfo \
diff --git a/target/imagebuilder/files/Config.in b/target/imagebuilder/files/Config.in
new file mode 100644
index 0000000..4fc345f
--- /dev/null
+++ b/target/imagebuilder/files/Config.in
@@ -0,0 +1,23 @@
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+mainmenu "OpenWrt Configuration"
+
+source "config/fromdotconfig.in"
+
+config MODULES
+	option modules
+	bool
+	default y
+
+config HAVE_DOT_CONFIG
+	bool
+	default y
+
+source "config/Config-images.in"
+
+source "config/Config-version.in"
+
diff --git a/target/imagebuilder/files/Makefile b/target/imagebuilder/files/Makefile
index 1056a42..900ed7b 100644
--- a/target/imagebuilder/files/Makefile
+++ b/target/imagebuilder/files/Makefile
@@ -33,6 +33,7 @@ Available Commands:
 	info:	Show a list of available target profiles
 	clean:	Remove images and temporary build files
 	image:	Build an image (see below for more information).
+        menuconfig: Alter image generation configuration
 
 Building images:
 	By default 'make image' will create an image with the default
@@ -201,3 +202,23 @@ endif
 
 .SILENT: help info image
 
+scripts/config/mconf:
+	@$(MAKE) -s -C scripts/config all CC="$(HOSTCC_WRAPPER)"
+
+$(eval $(call rdep,scripts/config,scripts/config/mconf))
+
+scripts/config/conf:
+	@$(MAKE) -s -C scripts/config conf CC="$(HOSTCC_WRAPPER)"
+
+config: scripts/config/conf FORCE
+	$< Config.in
+
+oldconfig: scripts/config/conf FORCE
+	$< --$(if $(confdefault),$(confdefault),old)config Config.in
+
+menuconfig: scripts/config/mconf FORCE
+	if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
+		cp $(HOME)/.openwrt/defconfig .config; \
+	fi
+	$< Config.in
+
diff --git a/target/sdk/Makefile b/target/sdk/Makefile
index 441ffeb..80a87a8 100644
--- a/target/sdk/Makefile
+++ b/target/sdk/Makefile
@@ -91,7 +91,7 @@ $(BIN_DIR)/$(SDK_NAME).tar.bz2: clean
 	rm -rf \
 		$(SDK_BUILD_DIR)/target/linux/*/files* \
 		$(SDK_BUILD_DIR)/target/linux/*/patches*
-	./convert-config.pl $(TOPDIR)/.config > $(SDK_BUILD_DIR)/Config-build.in
+	$(TOPDIR)/target/convert-config.pl $(TOPDIR)/.config > $(SDK_BUILD_DIR)/Config-build.in
 	$(CP) -L \
 		$(TOPDIR)/LICENSE \
 		$(TOPDIR)/rules.mk \
diff --git a/target/sdk/convert-config.pl b/target/sdk/convert-config.pl
deleted file mode 100755
index e701b42..0000000
--- a/target/sdk/convert-config.pl
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-
-print <<EOF;
-config ALL
-	bool
-	default y
-
-EOF
-
-while (<>) {
-	chomp;
-	next if /^CONFIG_SIGNED_PACKAGES/;
-	next unless /^CONFIG_([^=]+)=(.*)$/;
-
-	my $var = $1;
-	my $val = $2;
-	my $type;
-
-	next if $var eq 'ALL';
-
-	if ($val eq 'y') {
-		$type = "bool";
-	} elsif ($val eq 'm') {
-		$type = "tristate";
-	} elsif ($val =~ /^".*"$/) {
-		$type = "string";
-	} elsif ($val =~ /^\d+$/) {
-		$type = "int";
-	} else {
-		warn "WARNING: no type found for symbol CONFIG_$var=$val\n";
-		next;
-	}
-
-	print <<EOF;
-config $var
-	$type
-	default $val
-
-EOF
-}
-- 
2.4.3
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list