Skip to contentSkip to conversation

Miniconfig revisited (0/3)

PATCH In review Rob Landley 1 participant 4 messages Jul 6, 2006 – Jul 7, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Miniconfig revisited (0/3)

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

Signature · 1 line
Never bet against the cheap plastic solution.
#1 lore raw

PATCH 1/1 Miniconfig revisited (1/3)

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.

scripts/kconfig/Makefile +10 -1
diff -ur linux-2.6.17.1/scripts/kconfig/Makefile linux-2.6.17.new/scripts/kconfig/Makefile
@@ -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:
scripts/shrinkconfig +86 -0

86 lines not on this page · raw message

Signature · 1 line
Never bet against the cheap plastic solution.
#2 lore raw

PATCH 1/1 Miniconfig revisited (2/3)

In reply to Rob Landley

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

scripts/shrinkconfig +86 -0
diff -ur linux-2.6.17.1/scripts/shrinkconfig linux-2.6.17.new/scripts/shrinkconfig
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+# shrinkconfig copyright 2006 by Rob Landley <[email protected]>
+# 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
Signature · 1 line
Never bet against the cheap plastic solution.
#3 lore raw

Re: [PATCH] Miniconfig revisited (3/3)

In reply to Rob Landley

Documentation for miniconfig.

Documentation/kbuild/00-INDEX +2 -0
diff -ur linux-2.6.17.1/Documentation/kbuild/00-INDEX linux-2.6.17.new/Documentation/kbuild/00-INDEX
@@ -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
Documentation/kbuild/miniconfig.txt +103 -0

103 lines not on this page · raw message

Signature · 1 line
Never bet against the cheap plastic solution.