diff --git a/debian/scripts/misc/kernelconfig
b/debian/scripts/misc/kernelconfig
index 71c0f5e..9d8793a 100755 (executable)
--- a/debian/scripts/misc/kernelconfig
+++ b/debian/scripts/misc/kernelconfig
@@ -38,18 +38,93 @@ if [ "$mode" = "genconfig" ]; then
        test -d CONFIGS || mkdir CONFIGS
 fi
 
-for arch in $archs; do
-       rm -rf build
-       mkdir build
-
+map_arch()
+{
        # Map debian archs to kernel archs
        case "$arch" in
                amd64)  kernarch="x86_64"       ;;
                lpia)   kernarch="x86"          ;;
                sparc)  kernarch="sparc64"      ;;
                armel)  kernarch="arm"          ;;
-               *)      kernarch="$arch"        ;;
+               *)          kernarch="$arch"    ;;
        esac
+}
+
+save_config()
+{
+       cat build/.config > $archconfdir/$config
+       cat build/.config > "$tmpdir/CONFIGS/$arch-$config"
+       if [ "$keep" = "1" ]; then
+               cat build/.config > CONFIGS/$arch-$config
+       fi
+}
+
+run_splitconfig()
+{
+       echo "Running splitconfig.pl 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.pl
+       (cd $archconfdir; $bindir/splitconfig.pl; mv config.common \
+        config.common.$arch; cp config.common.$arch $tmpdir)
+}
+
+edit_config()
+{
+       inc=0
+       for arch in $archs; do
+               archconfdir=$confdir/$arch
+               archconfigs=$(cd $archconfdir && ls config.flavour.*)
+
+               fullarchconfigs=""
+               for archconfig in $archconfigs; do
+                       fullarchconfigs="$fullarchconfigs $arch/$archconfig"
+               done
+              
+               configs="$configs $fullarchconfigs"
+       done
+
+       echo -e "Which config would you like to edit?\n"
+       for config in $configs; do
+               echo "$inc) $config"
+               inc=$(($inc+1))
+       done
+
+       echo -ne "\n> "
+       read choice
+
+       inc=0
+       for config in $configs; do
+               if [ $inc -eq $choice ]; then
+                       echo "You choose: $config"
+                      
+                       arch=${config%/*}
+                       archconfdir=$confdir/$arch
+                       map_arch
+
+                       rm -rf build
+                       mkdir build
+                       cat "$confdir/$config" > build/.config
+                       make O=`pwd`/build ARCH=$kernarch menuconfig
+                       config=${config#*/}
+                       break
+               fi
+               inc=$(($inc+1))
+       done
+
+       save_config
+       run_splitconfig
+
+       exit
+}
+
+for arch in $archs; do
+       rm -rf build
+       mkdir build
+
+       map_arch
 
        echo ""
        echo "***************************************"
@@ -87,39 +162,24 @@ for arch in $archs; do
                        # 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 ;;
+                                   # Weed out incorrect config parameters
+                                       echo "* Run silentoldconfig on
$arch/$config ..."
+                                       make O=`pwd`/build
ARCH=$kernarch silentoldconfig ;;
                            defaultconfig)
-                               # Weed out incorrect config parameters
-                               echo "* Run oldconfig on $arch/$config ..."
-                               make O=`pwd`/build ARCH=$kernarch
oldconfig ;;
+                                   # Weed out incorrect config parameters
+                                       echo "* Run oldconfig on
$arch/$config ..."
+                                       make O=`pwd`/build
ARCH=$kernarch oldconfig ;;
                            editconfig)
-                               # Interactively edit config parameters
-                               echo " * Run menuconfig on
$arch/$config... Press a key."
-                               read
-                               make O=`pwd`/build ARCH=$kernarch
menuconfig ;;
-                           *)  # Bad!
+                                       edit_config ;;
+                               *)  # Bad!
                                exit 1 ;;
                        esac
-                       cat build/.config > $archconfdir/$config
-                       cat build/.config > "$tmpdir/CONFIGS/$arch-$config"
-                       if [ "$keep" = "1" ]; then
-                               cat build/.config > CONFIGS/$arch-$config
-                       fi
+                       save_config
                else
                        echo "!! Config not found $archconfdir/$config..."
                fi
        done
-
-       echo "Running splitconfig.pl for $arch"
-       echo
