linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Miniconfig revisited (0/3)
@ 2006-07-06 21:53 Rob Landley
  2006-07-07  1:43 ` [PATCH] Miniconfig revisited (1/3) Rob Landley
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rob Landley @ 2006-07-06 21:53 UTC (permalink / raw)
  To: linux-kernel, akpm

Ok, here's a rewrite of the mini.config patch that's just a makefile tweak to 
add the "make miniconfig" target, the miniconfig generator script, and some 
documentation.  No C code is touched by this patch series.

At some point I'd like to replace the guts of scripts/shrinkconfig with 
internal changes to kconfig that spit out a mini.config directly.  The script 
shrinks the current defconfig from 1584 lines to 116, but it takes 28 minutes 
to do so on my laptop.  However, in the past six months I haven't gotten 
around to tackling that and it won't creep up my to-do list sitting 
unsubmitted on my hard drive, so...

Rob
-- 
Never bet against the cheap plastic solution.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Miniconfig revisited (1/3)
  2006-07-06 21:53 [PATCH] Miniconfig revisited (0/3) Rob Landley
@ 2006-07-07  1:43 ` Rob Landley
  2006-07-07  1:44 ` [PATCH] Miniconfig revisited (2/3) Rob Landley
  2006-07-07  1:45 ` [PATCH] Miniconfig revisited (3/3) Rob Landley
  2 siblings, 0 replies; 4+ messages in thread
From: Rob Landley @ 2006-07-07  1:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm

My first attempt doesn't seem to have made it through to the list, so...

Add "make miniconfig" target.  Only touches the makefile, no C code.

Signed-off-by: Rob Landley <rob@landley.net>


diff -ur linux-2.6.17.1/scripts/kconfig/Makefile linux-2.6.17.new/scripts/kconfig/Makefile
--- linux-2.6.17.1/scripts/kconfig/Makefile	2006-06-20 05:31:55.000000000 -0400
+++ linux-2.6.17.new/scripts/kconfig/Makefile	2006-07-06 15:51:25.000000000 -0400
@@ -2,7 +2,7 @@
 # Kernel configuration targets
 # These targets are used from top-level makefile
 
-PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
+PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig miniconfig update-po-config
 
 xconfig: $(obj)/qconf
 	$< arch/$(ARCH)/Kconfig
@@ -23,6 +23,14 @@
 silentoldconfig: $(obj)/conf
 	$< -s arch/$(ARCH)/Kconfig
 
+MINICONFIG = mini.config
+miniconfig: $(obj)/conf $(MINICONFIG)
+	$(Q)KCONFIG_ALLCONFIG=$(MINICONFIG) $< -n arch/$(ARCH)/Kconfig > /dev/null 2> .config.result ; \
+	cat .config.result ; \
+	RESULT=`cat .config.result`; \
+	rm .config.result ; \
+	if [ ! -z "${RESULT}" ]; then exit 1; fi
+
 update-po-config: $(obj)/kxgettext
 	xgettext --default-domain=linux \
           --add-comments --keyword=_ --keyword=N_ \
@@ -79,6 +87,7 @@
 	@echo  '  allmodconfig	  - New config selecting modules when possible'
 	@echo  '  allyesconfig	  - New config where all options are accepted with yes'
 	@echo  '  allnoconfig	  - New config where all options are answered with no'
+	@echo  '  miniconfig	  - New config unpacked from mini.config (or MINICONFIG=file)'
 
 # ===========================================================================
 # Shared Makefile for the various kconfig executables:
diff -ur linux-2.6.17.1/scripts/shrinkconfig linux-2.6.17.new/scripts/shrinkconfig
--- linux-2.6.17.1/scripts/shrinkconfig	2006-07-06 16:34:39.000000000 -0400
+++ linux-2.6.17.new/scripts/shrinkconfig	2006-07-06 15:54:40.000000000 -0400
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+# shrinkconfig copyright 2006 by Rob Landley <rob@landley.net>
+# Licensed under the GNU General Public License version 2.
+
+if [ $# -ne 1 ]
+then
+  echo "Turns current .config into a miniconfig file."
+  echo "Usage: shrinkconfig mini.config"
+  exit 1
+fi
+
+if [ ! -f .config ]
+then
+  echo "Need a .config file to shrink."
+  exit 1
+fi
+LENGTH=$(cat .config | wc -l)
+
+OUTPUT="$1"
+cp .config "$OUTPUT"
+if [ $? -ne 0 ]
+then
+  echo "Couldn't create $OUTPUT"
+  exit 1
+fi
+
+# If we get interrupted, clean up the mess
+
+KERNELOUTPUT=""
+
+function cleanup
+{
+  echo
+  echo "Interrupted."
+  [ ! -z "$KERNELOUTPUT" ] && rm -rf "$KERNELOUTPUT"
+  rm "$OUTPUT"
+  exit 1
+}
+
+trap cleanup HUP INT QUIT TERM
+
+# Since the "O=" argument to make doesn't work recursively, we need to jump
+# through a few hoops to avoid overwriting the .config that we're shrinking.
+
+# If we're building out of tree, we'll have absolute paths to source and build
+# directories in the Makefile.
+
+KERNELSRC=$(sed -n -e 's/KERNELSRC[^/]*:=[^/]*//p' Makefile)
+[ -z "$KERNELSRC" ] && KERNELSRC=$(pwd)
+KERNELOUTPUT=`pwd`/.config.minitemp
+
+mkdir -p "$KERNELOUTPUT" || exit 1
+
+echo "Shrinking .config to $OUTPUT..."
+
+# Loop through all lines in the file 
+I=1
+while true
+do
+  if [ $I -gt $LENGTH ]
+  then
+    break
+  fi
+
+  echo -n -e "\r"$I/$LENGTH lines $(cat "$OUTPUT" | wc -c) bytes
+
+  sed -n "${I}!p" "$OUTPUT" > "$KERNELOUTPUT"/.config.test
+  # Do a config with this file
+  make -C "$KERNELSRC" O="$KERNELOUTPUT" allnoconfig KCONFIG_ALLCONFIG="$KERNELOUTPUT"/.config.test > /dev/null
+
+  # Compare.  The date changes, so expect a small difference each time.
+  D=$(diff "$KERNELOUTPUT"/.config .config | wc -l)
+  if [ $D -eq 4 ]
+  then
+    mv "$KERNELOUTPUT"/.config.test "$OUTPUT"
+    LENGTH=$[$LENGTH-1]
+  else
+    I=$[$I + 1]
+  fi
+done
+
+rm -rf "$KERNELOUTPUT"
+
+# One extra echo to preserve status line.
+echo

-- 
Never bet against the cheap plastic solution.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Miniconfig revisited (2/3)
  2006-07-06 21:53 [PATCH] Miniconfig revisited (0/3) Rob Landley
  2006-07-07  1:43 ` [PATCH] Miniconfig revisited (1/3) Rob Landley
@ 2006-07-07  1:44 ` Rob Landley
  2006-07-07  1:45 ` [PATCH] Miniconfig revisited (3/3) Rob Landley
  2 siblings, 0 replies; 4+ messages in thread
From: Rob Landley @ 2006-07-07  1:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm

Add scripts/shrinkconfig to create a miniconfig from an existing .config.

Signed-off-by: Rob Landley <rob@landley.net>

diff -ur linux-2.6.17.1/scripts/shrinkconfig linux-2.6.17.new/scripts/shrinkconfig
--- linux-2.6.17.1/scripts/shrinkconfig	2006-07-06 16:34:39.000000000 -0400
+++ linux-2.6.17.new/scripts/shrinkconfig	2006-07-06 15:54:40.000000000 -0400
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+# shrinkconfig copyright 2006 by Rob Landley <rob@landley.net>
+# Licensed under the GNU General Public License version 2.
+
+if [ $# -ne 1 ]
+then
+  echo "Turns current .config into a miniconfig file."
+  echo "Usage: shrinkconfig mini.config"
+  exit 1
+fi
+
+if [ ! -f .config ]
+then
+  echo "Need a .config file to shrink."
+  exit 1
+fi
+LENGTH=$(cat .config | wc -l)
+
+OUTPUT="$1"
+cp .config "$OUTPUT"
+if [ $? -ne 0 ]
+then
+  echo "Couldn't create $OUTPUT"
+  exit 1
+fi
+
+# If we get interrupted, clean up the mess
+
+KERNELOUTPUT=""
+
+function cleanup
+{
+  echo
+  echo "Interrupted."
+  [ ! -z "$KERNELOUTPUT" ] && rm -rf "$KERNELOUTPUT"
+  rm "$OUTPUT"
+  exit 1
+}
+
+trap cleanup HUP INT QUIT TERM
+
+# Since the "O=" argument to make doesn't work recursively, we need to jump
+# through a few hoops to avoid overwriting the .config that we're shrinking.
+
+# If we're building out of tree, we'll have absolute paths to source and build
+# directories in the Makefile.
+
+KERNELSRC=$(sed -n -e 's/KERNELSRC[^/]*:=[^/]*//p' Makefile)
+[ -z "$KERNELSRC" ] && KERNELSRC=$(pwd)
+KERNELOUTPUT=`pwd`/.config.minitemp
+
+mkdir -p "$KERNELOUTPUT" || exit 1
+
+echo "Shrinking .config to $OUTPUT..."
+
+# Loop through all lines in the file 
+I=1
+while true
+do
+  if [ $I -gt $LENGTH ]
+  then
+    break
+  fi
+
+  echo -n -e "\r"$I/$LENGTH lines $(cat "$OUTPUT" | wc -c) bytes
+
+  sed -n "${I}!p" "$OUTPUT" > "$KERNELOUTPUT"/.config.test
+  # Do a config with this file
+  make -C "$KERNELSRC" O="$KERNELOUTPUT" allnoconfig KCONFIG_ALLCONFIG="$KERNELOUTPUT"/.config.test > /dev/null
+
+  # Compare.  The date changes, so expect a small difference each time.
+  D=$(diff "$KERNELOUTPUT"/.config .config | wc -l)
+  if [ $D -eq 4 ]
+  then
+    mv "$KERNELOUTPUT"/.config.test "$OUTPUT"
+    LENGTH=$[$LENGTH-1]
+  else
+    I=$[$I + 1]
+  fi
+done
+
+rm -rf "$KERNELOUTPUT"
+
+# One extra echo to preserve status line.
+echo

-- 
Never bet against the cheap plastic solution.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Miniconfig revisited (3/3)
  2006-07-06 21:53 [PATCH] Miniconfig revisited (0/3) Rob Landley
  2006-07-07  1:43 ` [PATCH] Miniconfig revisited (1/3) Rob Landley
  2006-07-07  1:44 ` [PATCH] Miniconfig revisited (2/3) Rob Landley
@ 2006-07-07  1:45 ` Rob Landley
  2 siblings, 0 replies; 4+ messages in thread
From: Rob Landley @ 2006-07-07  1:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm

Documentation for miniconfig.

Signed-off-by: Rob Landley <rob@landley.net>

diff -ur linux-2.6.17.1/Documentation/kbuild/00-INDEX linux-2.6.17.new/Documentation/kbuild/00-INDEX
--- linux-2.6.17.1/Documentation/kbuild/00-INDEX	2006-06-20 05:31:55.000000000 -0400
+++ linux-2.6.17.new/Documentation/kbuild/00-INDEX	2006-07-06 13:50:35.000000000 -0400
@@ -4,5 +4,7 @@
 	- specification of Config Language, the language in Kconfig files
 makefiles.txt
 	- developer information for linux kernel makefiles
+miniconfig.txt
+	- how to use miniature configuration files.
 modules.txt
 	- how to build modules and to install them
diff -ur linux-2.6.17.1/Documentation/kbuild/miniconfig.txt linux-2.6.17.new/Documentation/kbuild/miniconfig.txt
--- linux-2.6.17.1/Documentation/kbuild/miniconfig.txt	2006-07-06 16:37:21.000000000 -0400
+++ linux-2.6.17.new/Documentation/kbuild/miniconfig.txt	2006-07-06 13:50:57.000000000 -0400
@@ -0,0 +1,103 @@
+Miniconfig documentation
+June 19, 2006
+Rob Landley <rob@landley.net>
+=============================
+
+What is a miniconfig?
+---------------------
+
+Current Linux kernels support 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.
+
+The "make miniconfig" command will expand a mini.config file into a full-sized
+.config for use by the build process.  By default this expects to read
+configuration data from "mini.config" in the current directory.  Add the
+argument "MINICONFIG=/path/to/filename" to specify a different file.  Either
+way, it creates a new ".config" file.
+
+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
+   most likely build an equivalent 2.6.18 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 automatically:
+-------------------------------------
+
+Configure your kernel as usual, then run "scripts/shrinkconfig filename"
+to create a new miniconfig file (called "filename") from that .config file.
+
+This will take a long time; the current script reloads the config file once
+for each line in the file to determine if that line is needed in the resulting
+output.
+
+To specify an architecture other than x86, set the ARCH environment variable
+before running the script, ala:
+
+  ARCH=arm script/shrinkconfig mini.config
+
+Creating a mini.config by hand:
+-------------------------------
+
+Open your favorite text editor starting with a blank file, and also open a
+command line window.  At the command line run "make allnoconfig" followed by
+"make menuconfig".  Go through menuconfig enabling each feature you want, and
+for each feature you enable look at the help entry to find the symbol name for
+that feature, and add a line to mini.config setting that symbol to the
+appropriate value, such as:
+
+  CONFIG_THINGY=y
+
+When you've got your list of symbols, save the file and run "make miniconfig"
+on it to make sure you get the results you want.
+
+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 miniconfig MINICONFIG=~/uml-config ARCH=um O=../linux-umlbuild
+
+# 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.
+
+  ARCH=um scripts/shrinkconfig uml-config


-- 
Never bet against the cheap plastic solution.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-07-07  1:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-06 21:53 [PATCH] Miniconfig revisited (0/3) Rob Landley
2006-07-07  1:43 ` [PATCH] Miniconfig revisited (1/3) Rob Landley
2006-07-07  1:44 ` [PATCH] Miniconfig revisited (2/3) Rob Landley
2006-07-07  1:45 ` [PATCH] Miniconfig revisited (3/3) Rob Landley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).