#!/bin/bash # Script to merge all configs and run 'make silentoldconfig' on it to wade out bad juju. # Then split the configs into distro-commmon and flavour-specific parts # # See this page for more details: # http://dev.chromium.org/chromium-os/how-tos-and-troubleshooting/kernel-configuration # We have to be in the top level kernel source directory if [ ! -f MAINTAINERS ] || [ ! -f Makefile ]; then echo "This does not appear to be the kernel source directory." 1>&2 exit 1 fi mode=${1:?"Usage: $0 [oldconfig|editconfig]"} case "$mode" in oldconfig) ;; # All is good editconfig) ;; # All is good genconfig) ;; # All is good *) echo "$0 called with invalid mode" 1>&2 exit 1 ;; esac kerneldir="`pwd`" confdir="$kerneldir/debian/config" archs="armhf arm64" bindir="`pwd`/debian/scripts" tmpdir=`mktemp -d` if [ "$mode" = "genconfig" ]; then keep=1 mode="oldconfig" test -d CONFIGS || mkdir CONFIGS fi test -d build || mkdir build for arch in $archs; do # Map debian archs to kernel archs case "$arch" in amd64) kernarch="x86_64" ;; lpia) kernarch="x86" ;; sparc) kernarch="sparc64" ;; armel) kernarch="arm" ;; armhf) kernarch="arm" ;; *) kernarch="$arch" ;; esac echo "" echo "***************************************" echo "* Processing $arch ($kernarch) ... " archconfdir=$confdir/$arch flavourconfigs=$(cd $archconfdir && ls config*) for config in $flavourconfigs; do fullconf="$tmpdir/$arch-$config-full" cat $confdir/config > "$fullconf" cat $archconfdir/$config >> "$fullconf" done echo archconfdir=$archconfdir echo flavourconfigs=$flavourconfigs echo fullconf=$fullconf for config in $flavourconfigs; do fullconf="$tmpdir/$arch-$config-full" mv "$fullconf" build/.config # Call oldconfig or menuconfig case "$mode" in oldconfig) # Weed out incorrect config parameters echo "* Run silentoldconfig on $arch/$config ..." make O=`pwd`/build ARCH=$kernarch silentoldconfig ;; editconfig) # Interactively edit config parameters echo "* $arch/$config: press to edit, S to skip" read -s -n 1 if [ $REPLY = 's' -o $REPLY = 'S' ]; then echo "* Skip: running silentoldconfig" make O=`pwd`/build ARCH=$kernarch silentoldconfig else echo "* Running menuconfig" make O=`pwd`/build ARCH=$kernarch menuconfig fi ;; *) # Bad! exit 1 ;; esac cat build/.config > $archconfdir/$config if [ "$keep" = "1" ]; then make O=`pwd`/build ARCH=$kernarch oldconfig make O=`pwd`/build ARCH=$kernarch savedefconfig mv build/.config CONFIGS/$arch-$config mv build/defconfig CONFIGS/$arch-$config.def fi done done echo "Running splitconfig for $arch" echo # Can we make this more robust by avoiding $tmpdir completely? # This approach was used for now because I didn't want to change # splitconfig echo archconfdir=$archconfdir, config=$config (cd $confdir; $bindir/splitconfig) rm -rf $tmpdir