annotate sources/toys/miniconfig.sh @ 1046:14bd42f4a47e

More documentation for miniconfig.sh.
author Rob Landley <rob@landley.net>
date Sat, 01 May 2010 14:15:53 -0500
parents 8de4598dfe46
children e948f92964b5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
194
4bb60ffd0d09 This won't work with dash either.
Rob Landley <rob@landley.net>
parents: 131
diff changeset
1 #!/bin/bash
85
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
2
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
3 # miniconfig.sh copyright 2005 by Rob Landley <rob@landley.net>
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
4 # Licensed under the GNU General Public License version 2.
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
5
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
6 # Run this in the linux kernel build directory with a starting file, and
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
7 # it creates a file called mini.config with all the redundant lines of that
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
8 # .config removed. The starting file must match what the kernel outputs.
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
9 # If it doesn't, then run "make oldconfig" on it to get one that does.
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
10
1046
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
11 # A miniconfig file is essentially the list of symbols you'd have to switch
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
12 # on if you started from "allnoconfig" and then went through menuconfig
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
13 # selecting what you wanted. It's just the list of symbols you're interested
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
14 # in, without including the ones set automatically by dependency checking.
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
15
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
16 # To use a miniconfig: make allnoconfig KCONFIG_ALLCONFIG=/path/to/mini.conf
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
17
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
18 # Miniconfig is more easily human-readable than a full .config file, and in
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
19 # some ways more version-independent than full .config files. On the other
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
20 # hand, when you update to a new kernel it won't get default values for newly
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
21 # created symbols (they'll be off if they didn't exist before and thus weren't
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
22 # in your "I need this and this and this" checklist), which can cause problems.
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
23
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
24 # See sources/more/migrate_kernel.sh for a script that expands a miniconfig
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
25 # to a .config under an old kernel version, copies it to a new version,
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
26 # runs "make oldconfig" to update it, creates a new mini.config from the
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
27 # result, and then shows a diff so you can see whether you want the new symbols.
14bd42f4a47e More documentation for miniconfig.sh.
Rob Landley <rob@landley.net>
parents: 602
diff changeset
28
198
77dfe348925c Teach script to normalize input before converting, to be more flexible.
Rob Landley <rob@landley.net>
parents: 194
diff changeset
29 export KCONFIG_NOTIMESTAMP=1
77dfe348925c Teach script to normalize input before converting, to be more flexible.
Rob Landley <rob@landley.net>
parents: 194
diff changeset
30
235
c0d9e91f528b Improve error message when $1 not found.
Rob Landley <rob@landley.net>
parents: 199
diff changeset
31 if [ $# -ne 1 ]
85
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
32 then
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
33 echo "Usage: miniconfig.sh configfile"
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
34 exit 1
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
35 fi
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
36
235
c0d9e91f528b Improve error message when $1 not found.
Rob Landley <rob@landley.net>
parents: 199
diff changeset
37 if [ ! -f "$1" ]
c0d9e91f528b Improve error message when $1 not found.
Rob Landley <rob@landley.net>
parents: 199
diff changeset
38 then
c0d9e91f528b Improve error message when $1 not found.
Rob Landley <rob@landley.net>
parents: 199
diff changeset
39 echo "Couldn't find "'"'"$1"'"'
c0d9e91f528b Improve error message when $1 not found.
Rob Landley <rob@landley.net>
parents: 199
diff changeset
40 exit 1
c0d9e91f528b Improve error message when $1 not found.
Rob Landley <rob@landley.net>
parents: 199
diff changeset
41 fi
c0d9e91f528b Improve error message when $1 not found.
Rob Landley <rob@landley.net>
parents: 199
diff changeset
42
85
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
43 if [ "$1" == ".config" ]
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
44 then
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
45 echo "It overwrites .config, rename it and try again."
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
46 exit 1
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
47 fi
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
48
131
2916a56bacd1 Move uClibc to miniconfig.
Rob Landley <rob@landley.net>
parents: 85
diff changeset
49 make allnoconfig KCONFIG_ALLCONFIG="$1" > /dev/null
350
9db12e74a380 Fun _new_ breakage: using arch/arm/configs/spitz_defconfig in 2.6.25.4
Rob Landley <rob@landley.net>
parents: 349
diff changeset
50 # Shouldn't need this, but kconfig goes "boing" at times...
9db12e74a380 Fun _new_ breakage: using arch/arm/configs/spitz_defconfig in 2.6.25.4
Rob Landley <rob@landley.net>
parents: 349
diff changeset
51 yes "" | make oldconfig > /dev/null
198
77dfe348925c Teach script to normalize input before converting, to be more flexible.
Rob Landley <rob@landley.net>
parents: 194
diff changeset
52 if ! cmp .config "$1"
131
2916a56bacd1 Move uClibc to miniconfig.
Rob Landley <rob@landley.net>
parents: 85
diff changeset
53 then
198
77dfe348925c Teach script to normalize input before converting, to be more flexible.
Rob Landley <rob@landley.net>
parents: 194
diff changeset
54 echo Sanity test failed, normalizing starting configuration...
77dfe348925c Teach script to normalize input before converting, to be more flexible.
Rob Landley <rob@landley.net>
parents: 194
diff changeset
55 diff -u "$1" .config
131
2916a56bacd1 Move uClibc to miniconfig.
Rob Landley <rob@landley.net>
parents: 85
diff changeset
56 fi
198
77dfe348925c Teach script to normalize input before converting, to be more flexible.
Rob Landley <rob@landley.net>
parents: 194
diff changeset
57 cp .config .big.config
349
798cdf05aca2 The comment removal heuristic breaks on 2.6.25.4 arch/ppc/configs/luan_defconfig
Rob Landley <rob@landley.net>
parents: 348
diff changeset
58
798cdf05aca2 The comment removal heuristic breaks on 2.6.25.4 arch/ppc/configs/luan_defconfig
Rob Landley <rob@landley.net>
parents: 348
diff changeset
59 # Speed heuristic: remove all blank/comment lines
307
e6a201119439 Tweak from Tony Przygienda that triples the speed of miniconfig creation script.
Rob Landley <rob@landley.net>
parents: 235
diff changeset
60 grep -v '^[#$]' .config | grep -v '^$' > mini.config
349
798cdf05aca2 The comment removal heuristic breaks on 2.6.25.4 arch/ppc/configs/luan_defconfig
Rob Landley <rob@landley.net>
parents: 348
diff changeset
61 # This should never fail, but kconfig is so broken it does sometimes.
798cdf05aca2 The comment removal heuristic breaks on 2.6.25.4 arch/ppc/configs/luan_defconfig
Rob Landley <rob@landley.net>
parents: 348
diff changeset
62 make allnoconfig KCONFIG_ALLCONFIG=mini.config > /dev/null
798cdf05aca2 The comment removal heuristic breaks on 2.6.25.4 arch/ppc/configs/luan_defconfig
Rob Landley <rob@landley.net>
parents: 348
diff changeset
63 if ! cmp .config "$1"
798cdf05aca2 The comment removal heuristic breaks on 2.6.25.4 arch/ppc/configs/luan_defconfig
Rob Landley <rob@landley.net>
parents: 348
diff changeset
64 then
798cdf05aca2 The comment removal heuristic breaks on 2.6.25.4 arch/ppc/configs/luan_defconfig
Rob Landley <rob@landley.net>
parents: 348
diff changeset
65 echo Insanity test failed: reversing blank line removal heuristic.
798cdf05aca2 The comment removal heuristic breaks on 2.6.25.4 arch/ppc/configs/luan_defconfig
Rob Landley <rob@landley.net>
parents: 348
diff changeset
66 cp .big.config mini.config
798cdf05aca2 The comment removal heuristic breaks on 2.6.25.4 arch/ppc/configs/luan_defconfig
Rob Landley <rob@landley.net>
parents: 348
diff changeset
67 fi
307
e6a201119439 Tweak from Tony Przygienda that triples the speed of miniconfig creation script.
Rob Landley <rob@landley.net>
parents: 235
diff changeset
68 #cp .config mini.config
131
2916a56bacd1 Move uClibc to miniconfig.
Rob Landley <rob@landley.net>
parents: 85
diff changeset
69
85
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
70 echo "Calculating mini.config..."
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
71
307
e6a201119439 Tweak from Tony Przygienda that triples the speed of miniconfig creation script.
Rob Landley <rob@landley.net>
parents: 235
diff changeset
72 LENGTH=`cat mini.config | wc -l`
602
8de4598dfe46 Add percent progress indicator to miniconfig creation script.
Rob Landley <rob@landley.net>
parents: 350
diff changeset
73 OLDLENGTH=$LENGTH
85
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
74
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
75 # Loop through all lines in the file
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
76 I=1
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
77 while true
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
78 do
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
79 if [ $I -gt $LENGTH ]
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
80 then
199
4d55eff218e9 Cosmetic fixes.
Rob Landley <rob@landley.net>
parents: 198
diff changeset
81 break
85
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
82 fi
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
83 sed -n "${I}!p" mini.config > .config.test
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
84 # Do a config with this file
348
d1e73f644c62 Work around the kernel's allnoconfig trying to go nuts while shrinking
Rob Landley <rob@landley.net>
parents: 307
diff changeset
85 rm .config
d1e73f644c62 Work around the kernel's allnoconfig trying to go nuts while shrinking
Rob Landley <rob@landley.net>
parents: 307
diff changeset
86 make allnoconfig KCONFIG_ALLCONFIG=.config.test | head -n 1000000 > /dev/null
198
77dfe348925c Teach script to normalize input before converting, to be more flexible.
Rob Landley <rob@landley.net>
parents: 194
diff changeset
87 # Compare. Because we normalized at the start, the files should be identical.
77dfe348925c Teach script to normalize input before converting, to be more flexible.
Rob Landley <rob@landley.net>
parents: 194
diff changeset
88 if cmp -s .config .big.config
85
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
89 then
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
90 mv .config.test mini.config
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
91 LENGTH=$[$LENGTH-1]
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
92 else
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
93 I=$[$I + 1]
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
94 fi
602
8de4598dfe46 Add percent progress indicator to miniconfig creation script.
Rob Landley <rob@landley.net>
parents: 350
diff changeset
95 echo -n -e "\r$[$I-1]/$LENGTH lines $(cat mini.config | wc -c) bytes $[100-((($LENGTH-$I)*100)/$OLDLENGTH)]% "
85
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
96 done
198
77dfe348925c Teach script to normalize input before converting, to be more flexible.
Rob Landley <rob@landley.net>
parents: 194
diff changeset
97 rm .big.config
85
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents:
diff changeset
98 echo