Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Script to merge all configs and run 'make silentoldconfig' on it to wade out bad juju. |
| 4 | # Then split the configs into distro-commmon and flavour-specific parts |
| 5 | |
| 6 | # We have to be in the top level kernel source directory |
| 7 | if [ ! -f MAINTAINERS ] || [ ! -f Makefile ]; then |
| 8 | echo "This does not appear to be the kernel source directory." 1>&2 |
| 9 | exit 1 |
| 10 | fi |
| 11 | |
| 12 | mode=${1:?"Usage: $0 [oldconfig|editconfig]"} |
| 13 | case "$mode" in |
| 14 | oldconfig) ;; # All is good |
| 15 | editconfig) ;; # All is good |
| 16 | genconfig) ;; # All is good |
| 17 | *) echo "$0 called with invalid mode" 1>&2 |
| 18 | exit 1 ;; |
| 19 | esac |
| 20 | kerneldir="`pwd`" |
| 21 | confdir="$kerneldir/chromeos/config" |
| 22 | archs="x86_64 i386 armel" |
| 23 | family='chromeos' |
| 24 | bindir="`pwd`/chromeos/scripts" |
| 25 | common_conf="$confdir/config.common.$family" |
| 26 | tmpdir=`mktemp -d` |
| 27 | |
| 28 | if [ "$mode" = "genconfig" ]; then |
| 29 | keep=1 |
| 30 | mode="oldconfig" |
| 31 | test -d CONFIGS || mkdir CONFIGS |
| 32 | fi |
| 33 | |
| 34 | test -d build || mkdir build |
| 35 | |
| 36 | for arch in $archs; do |
| 37 | # Map debian archs to kernel archs |
| 38 | case "$arch" in |
| 39 | amd64) kernarch="x86_64" ;; |
| 40 | lpia) kernarch="x86" ;; |
| 41 | sparc) kernarch="sparc64" ;; |
| 42 | armel) kernarch="arm" ;; |
| 43 | *) kernarch="$arch" ;; |
| 44 | esac |
| 45 | |
| 46 | echo "" |
| 47 | echo "***************************************" |
| 48 | echo "* Processing $arch ($kernarch) ... " |
| 49 | archconfdir=$confdir/$arch |
| 50 | flavourconfigs=$(cd $archconfdir && ls config.flavour.*[^~]) |
| 51 | |
| 52 | # Merge configs |
| 53 | # We merge config.common.ubuntu + config.common.<arch> + |
| 54 | # config.flavour.<flavour> |
| 55 | |
| 56 | for config in $flavourconfigs; do |
| 57 | fullconf="$tmpdir/$arch-$config-full" |
| 58 | case $config in |
| 59 | *) |
| 60 | : >"$fullconf" |
| 61 | if [ -f $common_conf ]; then |
| 62 | cat $common_conf >> "$fullconf" |
| 63 | fi |
| 64 | if [ -f $archconfdir/config.common.$arch ]; then |
| 65 | cat $archconfdir/config.common.$arch >> "$fullconf" |
| 66 | fi |
| 67 | cat "$archconfdir/$config" >>"$fullconf" |
| 68 | ;; |
| 69 | esac |
| 70 | done |
| 71 | |
| 72 | for config in $flavourconfigs; do |
| 73 | if [ -f $archconfdir/$config ]; then |
| 74 | fullconf="$tmpdir/$arch-$config-full" |
| 75 | cat "$fullconf" > build/.config |
| 76 | # Call oldconfig or menuconfig |
| 77 | case "$mode" in |
| 78 | oldconfig) |
| 79 | # Weed out incorrect config parameters |
| 80 | echo "* Run silentoldconfig on $arch/$config ..." |
| 81 | make O=`pwd`/build ARCH=$kernarch silentoldconfig ;; |
| 82 | editconfig) |
| 83 | # Interactively edit config parameters |
| 84 | echo " * Run menuconfig on $arch/$config... Press a key." |
| 85 | read |
| 86 | make O=`pwd`/build ARCH=$kernarch menuconfig ;; |
| 87 | *) # Bad! |
| 88 | exit 1 ;; |
| 89 | esac |
| 90 | cat build/.config > $archconfdir/$config |
| 91 | if [ "$keep" = "1" ]; then |
| 92 | cat build/.config > CONFIGS/$arch-$config |
| 93 | fi |
| 94 | else |
| 95 | echo "!! Config not found $archconfdir/$config..." |
| 96 | fi |
| 97 | done |
| 98 | |
| 99 | echo "Running splitconfig for $arch" |
| 100 | echo |
| 101 | |
| 102 | # Can we make this more robust by avoiding $tmpdir completely? |
| 103 | # This approach was used for now because I didn't want to change |
| 104 | # splitconfig |
| 105 | (cd $archconfdir; rm config.common.$arch; $bindir/splitconfig; \ |
| 106 | mv config.common config.common.$arch; \ |
| 107 | cp config.common.$arch $tmpdir) |
| 108 | done |
| 109 | |
| 110 | rm -f $common_conf |
| 111 | |
| 112 | # Now run splitconfig on all the config.common.<arch> copied to |
| 113 | # $tmpdir |
| 114 | (cd $tmpdir; $bindir/splitconfig) |
| 115 | ( |
| 116 | cd $confdir; |
| 117 | rm -f *-full |
| 118 | grep -v 'is UNMERGABLE' <$tmpdir/config.common >$common_conf |
| 119 | for arch in $archs; do |
| 120 | grep -v 'is UNMERGABLE' <$tmpdir/config.common.$arch \ |
| 121 | >$arch/config.common.$arch |
| 122 | done |
| 123 | ) |