Re: [PATCH] make miniconfig (take 2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 22 November 2005 16:54, Pavel Machek wrote:
> Sorry, I did not have time to look what's wrong with miniconfig, yet.

I just tried again and it applied to -git2 cleanly.  Possibly it was 
whitespace damaged?  (I have to jump through hoops to prevent kmail from 
doing stupid things to inline attachments...)

Here it is as an attachment.  Let me know if this applies cleanly for you...

Rob
diff -ru linux-2.6.15-rc2.old/Documentation/00-INDEX linux-2.6.15-rc2/Documentation/00-INDEX
--- linux-2.6.15-rc2.old/Documentation/00-INDEX	2005-11-21 09:28:04.000000000 -0600
+++ linux-2.6.15-rc2/Documentation/00-INDEX	2005-11-21 09:46:35.514090656 -0600
@@ -174,6 +174,8 @@
 	- info on boot arguments for the multiple devices driver.
 memory.txt
 	- info on typical Linux memory problems.
+miniconfig.txt
+	- How to use miniature human-editable configuration files.
 mips/
 	- directory with info about Linux on MIPS architecture.
 mono.txt
diff -ru linux-2.6.15-rc2.old/Documentation/miniconfig.txt linux-2.6.15-rc2/Documentation/miniconfig.txt
--- linux-2.6.15-rc2.old/Documentation/miniconfig.txt	2005-11-21 09:36:38.000000000 -0600
+++ linux-2.6.15-rc2/Documentation/miniconfig.txt	2005-11-21 09:45:23.561029184 -0600
@@ -0,0 +1,105 @@
+Miniconfig documentation
+November 21, 2005
+Rob Landley <[email protected]>
+=============================
+
+What is a miniconfig?
+---------------------
+
+A new feature introduced in 2.6.15 lets you use miniature configuration files,
+listing just the symbols you want to enable and letting the configurator
+enable any dependencies needed to give you a valid configuration.
+
+To use it, create a mini.config file in whatever directory your .config file
+would normally live in, and run "make miniconfig".  (You can specify a
+different file with the argument "KCONFIG_ALLCONFIG=/path/to/mini.config".)
+
+Advantages of miniconfig:
+-------------------------
+
+Miniconfigs have several advantages over conventional configuration files:
+
+ * They're more portable between versions.  A miniconfig from linux 2.6.15 will
+   probably build an equivalent 2.6.16 kernel.
+
+ * It's easy to see exactly what features have been specified.
+
+ * Miniconfigs are human editable, human readable, and provide informative
+   error messages identifying any unrecognized (typoed) symbols.
+
+Creating a mini.config by hand:
+-------------------------------
+
+Run "make allnoconfig", and create an empty mini.config file.  Then go through
+"make menuconfig" enabling the features you want.  For each feature you enable,
+look at the help entry (at the top of which is the symbol name for this
+feature), and add a line to mini.config setting that symbol to the appropriate
+value, such as:
+
+CONFIG_THINGY=y
+
+Creating a mini.config from a full .config file:
+------------------------------------------------
+
+Run scripts/miniconfig.sh to automatically create a mini.conf from a full
+.config file.
+
+The script works via the simple expedient of trying to remove each line from
+.config and keeping only the lines which make a difference in the .config
+generated by "make miniconfig".  (This means it runs "make miniconfig" about
+1300 times, which is very very slow, so it displays a progress indicator.)
+
+To use the script, go into the kernel source directory, create your .config 
+file (via menuconfig or however), rename that .config file to another name
+(like "myconfig"), then run:
+
+scripts/miniconfig.sh myconfig
+
+When the script finishes, you should have a mini.config file containing
+the minimal set of lines necessary to specify that configuration via
+"make miniconfig".
+
+Real-world example:
+-------------------
+
+Here's the mini.config I use to build User Mode Linux:
+
+CONFIG_MODE_SKAS=y
+CONFIG_BINFMT_ELF=y
+CONFIG_HOSTFS=y
+CONFIG_SYSCTL=y
+CONFIG_STDERR_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_UBD=y
+CONFIG_TMPFS=y
+CONFIG_SWAP=y
+CONFIG_LBD=y
+CONFIG_EXT2_FS=y
+CONFIG_PROC_FS=y
+
+And here's how I build and test it (as a normal user, not as root):
+
+# Configure, building in an external directory and using a mini.config file in
+# my home directory.
+
+make KCONFIG_ALLCONFIG=~/uml-config ARCH=um O=../linux-umlbuild miniconfig
+
+# change to build directory and build User Mode Linux
+
+cd ../linux-umlbuild
+make ARCH=um
+
+# Test run
+
+./linux rootfstype=hostfs rw init=/bin/sh
+$ whoami
+$ mount -t proc /proc /proc
+$ cat /proc/cpuinfo
+$ halt -f
+
+# And if I want to regenerate the mini.config from the .config, I do this.
+# Note the syntax for specifying a different architecture:
+
+cp .config myconfig
+ARCH=um scripts/miniconfig.sh myconfig
diff -ru linux-2.6.15-rc2.old/scripts/kconfig/conf.c linux-2.6.15-rc2/scripts/kconfig/conf.c
--- linux-2.6.15-rc2.old/scripts/kconfig/conf.c	2005-11-21 09:28:22.000000000 -0600
+++ linux-2.6.15-rc2/scripts/kconfig/conf.c	2005-11-21 09:23:02.000000000 -0600
@@ -24,7 +24,8 @@
 	set_yes,
 	set_mod,
 	set_no,
-	set_random
+	set_random,
+	set_mini
 } input_mode = ask_all;
 char *defconfig_file;
 
@@ -86,6 +87,7 @@
 	case set_mod:
 	case set_yes:
 	case set_random:
+	case set_mini:
 		if (sym_has_value(sym)) {
 			printf("%s\n", def);
 			return;
@@ -143,6 +145,7 @@
 			}
 		}
 	case set_no:
+	case set_mini:
 		if (sym_tristate_within_range(sym, no)) {
 			line[0] = 'n';
 			line[1] = '\n';
@@ -376,6 +379,7 @@
 		case set_yes:
 		case set_mod:
 		case set_no:
+		case set_mini:
 			cnt = def;
 			printf("%d\n", cnt);
 			break;
@@ -492,7 +496,7 @@
 
 int main(int ac, char **av)
 {
-	int i = 1;
+	int i = 1, minifail = 0;
 	const char *name;
 	struct stat tmpstat;
 
@@ -530,6 +534,9 @@
 			input_mode = set_random;
 			srandom(time(NULL));
 			break;
+		case 'M':
+			input_mode = set_mini;
+			break;
 		case 'h':
 		case '?':
 			printf("%s [-o|-s] config\n", av[0]);
@@ -571,22 +578,32 @@
 	case set_mod:
 	case set_yes:
 	case set_random:
+	case set_mini:
 		name = getenv("KCONFIG_ALLCONFIG");
-		if (name && !stat(name, &tmpstat)) {
-			conf_read_simple(name);
-			break;
+		if (name) {
+			if(!stat(name, &tmpstat)) {
+				conf_read_simple(name);
+				break;
+			} else minifail++;
 		}
 		switch (input_mode) {
 		case set_no:	 name = "allno.config"; break;
 		case set_mod:	 name = "allmod.config"; break;
 		case set_yes:	 name = "allyes.config"; break;
 		case set_random: name = "allrandom.config"; break;
+		case set_mini:	 name = "mini.config"; break;
 		default: break;
 		}
 		if (!stat(name, &tmpstat))
 			conf_read_simple(name);
 		else if (!stat("all.config", &tmpstat))
 			conf_read_simple("all.config");
+		else minifail++;
+
+		if ( input_mode == set_mini && (minifail || conf_warnings)) {
+			fprintf(stderr, _("** Error parsing mini.config\n\n"));
+			return 1;
+		}
 		break;
 	default:
 		break;
diff -ru linux-2.6.15-rc2.old/scripts/kconfig/confdata.c linux-2.6.15-rc2/scripts/kconfig/confdata.c
--- linux-2.6.15-rc2.old/scripts/kconfig/confdata.c	2005-11-21 09:28:22.000000000 -0600
+++ linux-2.6.15-rc2/scripts/kconfig/confdata.c	2005-11-21 09:21:50.000000000 -0600
@@ -18,7 +18,8 @@
 	__attribute__ ((format (printf, 1, 2)));
 
 static const char *conf_filename;
-static int conf_lineno, conf_warnings, conf_unsaved;
+static int conf_lineno, conf_unsaved;
+int conf_warnings;
 
 const char conf_def_filename[] = ".config";
 
diff -ru linux-2.6.15-rc2.old/scripts/kconfig/lkc.h linux-2.6.15-rc2/scripts/kconfig/lkc.h
--- linux-2.6.15-rc2.old/scripts/kconfig/lkc.h	2005-11-21 09:28:22.000000000 -0600
+++ linux-2.6.15-rc2/scripts/kconfig/lkc.h	2005-11-21 09:21:50.000000000 -0600
@@ -61,6 +61,7 @@
 
 /* confdata.c */
 extern const char conf_def_filename[];
+extern int conf_warnings;
 
 char *conf_get_default_confname(void);
 
diff -ru linux-2.6.15-rc2.old/scripts/kconfig/Makefile linux-2.6.15-rc2/scripts/kconfig/Makefile
--- linux-2.6.15-rc2.old/scripts/kconfig/Makefile	2005-11-21 09:28:22.000000000 -0600
+++ linux-2.6.15-rc2/scripts/kconfig/Makefile	2005-11-21 09:21:50.000000000 -0600
@@ -42,7 +42,7 @@
 	$(Q)rm -f arch/um/Kconfig_arch
 	$(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot
 
-.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig
+.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig miniconfig
 
 randconfig: $(obj)/conf
 	$< -r arch/$(ARCH)/Kconfig
@@ -67,6 +67,9 @@
 %_defconfig: $(obj)/conf
 	$(Q)$< -D arch/$(ARCH)/configs/$@ arch/$(ARCH)/Kconfig
 
+miniconfig: $(obj)/conf
+	@ $< -M arch/$(ARCH)/Kconfig > /dev/null
+
 # Help text used by make help
 help:
 	@echo  '  config	  - Update current config utilising a line-oriented program'
@@ -79,6 +82,7 @@
 	@echo  '  allmodconfig	  - New config selecting modules when possible'
 	@echo  '  allyesconfig	  - New config where all options are accepted with yes'
 	@echo  '  allnoconfig	  - New minimal config'
+	@echo  '  miniconfig	  - New config generated from mini.config
 
 # ===========================================================================
 # Shared Makefile for the various kconfig executables:
diff -ru linux-2.6.15-rc2.old/scripts/miniconfig.sh linux-2.6.15-rc2/scripts/miniconfig.sh
--- linux-2.6.15-rc2.old/scripts/miniconfig.sh	2005-11-21 09:36:44.000000000 -0600
+++ linux-2.6.15-rc2/scripts/miniconfig.sh	2005-11-21 09:21:50.000000000 -0600
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# miniconfig.sh copyright 2005 by Rob Landley <[email protected]>
+# Licensed under the GNU General Public License version 2.
+
+if [ $# -ne 1 ] || [ ! -f "$1" ]
+then
+  echo "Usage: miniconfig.sh configfile" 
+  exit 1
+fi
+
+if [ "$1" == ".config" ]
+then
+  echo "It overwrites .config, rename it and try again."
+  exit 1
+fi
+
+cp $1 mini.config
+echo "Calculating mini.config..."
+
+LENGTH=`cat $1 | wc -l`
+
+# Loop through all lines in the file 
+I=1
+while true
+do
+  if [ $I -gt $LENGTH ]
+  then
+    exit
+  fi
+  sed -n "${I}!p" mini.config > .config.test
+  # Do a config with this file
+  make allnoconfig KCONFIG_ALLCONFIG=.config.test > /dev/null
+
+  # Compare.  The date changes so expect a small difference each time.
+  D=`diff .config $1 | wc -l`
+  if [ $D -eq 4 ]
+  then
+    mv .config.test mini.config
+    LENGTH=$[$LENGTH-1]
+  else
+    I=$[$I + 1]
+  fi
+  echo -n -e $I/$LENGTH lines `cat mini.config | wc -c` bytes "\r"
+done
+echo

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux