firmware

view sources/toys/miniconfig.sh @ 243:be703e9510bb

Added tag 0.3.0 for changeset c3d2fd8b45cf
author Rob Landley <rob@landley.net>
date Fri Nov 02 02:19:32 2007 -0500 (2 years ago)
parents 4d55eff218e9
children e6a201119439
line source
1 #!/bin/bash
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
13 if [ $# -ne 1 ]
14 then
15 echo "Usage: miniconfig.sh configfile"
16 exit 1
17 fi
19 if [ ! -f "$1" ]
20 then
21 echo "Couldn't find "'"'"$1"'"'
22 exit 1
23 fi
25 if [ "$1" == ".config" ]
26 then
27 echo "It overwrites .config, rename it and try again."
28 exit 1
29 fi
31 make allnoconfig KCONFIG_ALLCONFIG="$1" > /dev/null
32 if ! cmp .config "$1"
33 then
34 echo Sanity test failed, normalizing starting configuration...
35 diff -u "$1" .config
36 fi
37 cp .config .big.config
38 cp .config mini.config
40 echo "Calculating mini.config..."
42 LENGTH=`cat $1 | wc -l`
44 # Loop through all lines in the file
45 I=1
46 while true
47 do
48 if [ $I -gt $LENGTH ]
49 then
50 break
51 fi
52 sed -n "${I}!p" mini.config > .config.test
53 # Do a config with this file
54 make allnoconfig KCONFIG_ALLCONFIG=.config.test > /dev/null
56 # Compare. Because we normalized at the start, the files should be identical.
57 if cmp -s .config .big.config
58 then
59 mv .config.test mini.config
60 LENGTH=$[$LENGTH-1]
61 else
62 I=$[$I + 1]
63 fi
64 echo -n -e "\r$[$I-1]/$LENGTH lines $(cat mini.config | wc -c) bytes "
65 done
66 rm .big.config
67 echo