3 # miniconfig.sh copyright 2005 by Rob Landley <rob@landley.net>
4 # Licensed under the GNU General Public License version 2.
6 # Run this in the linux kernel build directory with a starting file, and
7 # it creates a file called mini.config with all the redundant lines of that
8 # .config removed. The starting file must match what the kernel outputs.
9 # If it doesn't, then run "make oldconfig" on it to get one that does.
11 export KCONFIG_NOTIMESTAMP
=1
15 echo "Usage: miniconfig.sh configfile"
21 echo "Couldn't find "'"'"$1"'"'
25 if [ "$1" == ".config" ]
27 echo "It overwrites .config, rename it and try again."
31 make allnoconfig KCONFIG_ALLCONFIG
="$1" > /dev
/null
32 # Shouldn't need this, but kconfig goes "boing" at times...
33 yes "" |
make oldconfig
> /dev
/null
36 echo Sanity
test failed
, normalizing starting configuration...
39 cp .config .big.config
41 # Speed heuristic: remove all blank/comment lines
42 grep -v '^[#$]' .config |
grep -v '^$' > mini.config
43 # This should never fail, but kconfig is so broken it does sometimes.
44 make allnoconfig KCONFIG_ALLCONFIG
=mini.config
> /dev
/null
47 echo Insanity
test failed
: reversing blank line removal heuristic.
48 cp .big.config mini.config
50 #cp .config mini.config
52 echo "Calculating mini.config..."
54 LENGTH
=`cat mini.config | wc -l`
57 # Loop through all lines in the file
65 sed -n "${I}!p" mini.config
> .config.
test
66 # Do a config with this file
68 make allnoconfig KCONFIG_ALLCONFIG
=.config.
test |
head -n 1000000 > /dev
/null
69 # Compare. Because we normalized at the start, the files should be identical.
70 if cmp -s .config .big.config
72 mv .config.
test mini.config
77 echo -n -e "\r$[$I-1]/$LENGTH lines $(cat mini.config | wc -c) bytes $[100-((($LENGTH-$I)*100)/$OLDLENGTH)]% "