All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Landley <rob@landley.net>
To: Pavel Machek <pavel@suse.cz>
Cc: Roman Zippel <zippel@linux-m68k.org>,
	linux-kernel@vger.kernel.org, Sam Ravnborg <sam@ravnborg.org>
Subject: Re: [PATCH] make miniconfig (take 2)
Date: Wed, 23 Nov 2005 02:58:33 -0600	[thread overview]
Message-ID: <200511230258.33901.rob@landley.net> (raw)
In-Reply-To: <20051122225428.GJ1748@elf.ucw.cz>

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]

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

[-- Attachment #2: miniconfig2.patch --]
[-- Type: text/x-diff, Size: 10203 bytes --]

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 <rob@landley.net>
+=============================
+
+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 <rob@landley.net>
+# 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

  reply	other threads:[~2005-11-23  8:59 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-17 12:29 Quick and dirty miniconfig howto, with feature suggestions Rob Landley
2005-11-20  3:08 ` Roman Zippel
2005-11-20  5:54   ` Rob Landley
2005-11-21  6:15   ` [PATCH] make miniconfig Rob Landley
2005-11-21 16:06     ` [PATCH] make miniconfig (take 2) Rob Landley
2005-11-21 17:26       ` Pavel Machek
2005-11-21 17:46         ` Rob Landley
2005-11-21 17:36       ` Pavel Machek
2005-11-21 17:50         ` Rob Landley
2005-11-21 18:28           ` Pavel Machek
2005-11-21 18:53             ` Rob Landley
2005-11-21 19:24               ` Pavel Machek
2005-11-22  5:14                 ` Rob Landley
2005-11-22 22:54                   ` Pavel Machek
2005-11-23  8:58                     ` Rob Landley [this message]
2005-11-23 13:21                       ` Pavel Machek
2005-11-24  3:19                         ` Rob Landley
2005-11-25 19:45                           ` Pavel Machek
2005-11-25 21:45                             ` Rob Landley
2005-11-25 22:09                               ` Pavel Machek
2005-11-25 22:20                                 ` Rob Landley
2005-11-26  2:34                                   ` Kyle Moffett
2005-11-26 12:25                                     ` Rob Landley
2005-11-26 14:19                                       ` Pavel Machek
2005-11-26 15:51                                         ` Rob Landley
2005-11-24  4:02                         ` Rob Landley
2005-11-25 19:46                           ` Pavel Machek
2005-11-26  1:53                             ` Andre Noll
2005-11-22  5:17                 ` Rob Landley
2005-11-24 13:56       ` Roman Zippel
2005-11-24 17:45         ` Rob Landley
2005-11-25  1:48           ` Roman Zippel
2005-11-25  8:18             ` Rob Landley
2005-11-25 15:02               ` Roman Zippel
2005-11-25 16:47                 ` Rob Landley
2005-11-25 21:12             ` Rob Landley
2005-11-27 23:20               ` Roman Zippel
2005-11-28  0:59                 ` Rob Landley
2005-11-29  1:00                   ` Roman Zippel
2005-11-29  2:26                     ` Rob Landley
2005-11-30  2:29                       ` Roman Zippel
2005-11-20  3:25 ` Quick and dirty miniconfig howto, with feature suggestions Rob Landley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200511230258.33901.rob@landley.net \
    --to=rob@landley.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.cz \
    --cc=sam@ravnborg.org \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.