genkernel: Add --kconfig to set specific kernel config options master
authorW. Trevor King <wking@tremily.us>
Fri, 8 Mar 2013 13:54:55 +0000 (08:54 -0500)
committerW. Trevor King <wking@tremily.us>
Fri, 8 Mar 2013 13:54:55 +0000 (08:54 -0500)
Some kernel config manipulation options already exist in genkernel
(--lvm, --multipath, ...), but this option allows you to override a
given config setting without rolling a new option specific to that
setting:

  $ genkernel ... --kconfig=CONFIG_LOGO=n ...

Ordinarily it would be easier (and more robust, with dependency
checking) to use --menuconfig or similar, but for reproducible
catalyst builds its better to specify the overrides explicitly in the
spec file.

gen_cmdline.sh
gen_configkernel.sh
genkernel

index 5503bb56abcc866ba4e457baed2603755e0a76ad..6766b4ea292c5476e0d7ce97923d5ca97269bf08 100755 (executable)
@@ -32,6 +32,7 @@ longusage() {
   echo "       --save-config           Save the configuration to /etc/kernels"
   echo "       --no-save-config        Don't save the configuration to /etc/kernels"
   echo "       --virtio                        Include VirtIO kernel code"
+  echo "       --kconfig=<CONFIG>=<value>      Set a specific kernel config option"
   echo "  Kernel Compile settings"
   echo "       --oldconfig             Implies --no-clean and runs a 'make oldconfig'"
   echo "       --clean                 Run make clean before compilation"
@@ -326,6 +327,12 @@ parse_cmdline() {
                        CMD_VIRTIO=`parse_optbool "$*"`
                        print_info 2 "CMD_VIRTIO: ${CMD_VIRTIO}"
                        ;;
+               --kconfig=*)
+                       KCONFIG_KEY=$(echo "$*" | cut -d= -f2)
+                       KCONFIG_VALUE=$(echo "$*" | cut -d= -f3)
+                       KCONFIG["$KCONFIG_KEY"]="$KCONFIG_VALUE"
+                       print_info 2 "KCONFIG: ${KCONFIG_KEY}=${KCONFIG_VALUE}"
+                       ;;
                --multipath|--no-multipath)
                        CMD_MULTIPATH=`parse_optbool "$*"`
                        if [ "$CMD_MULTIPATH" = "1" -a ! -e /usr/include/libdevmapper.h ]
index a69c7130fb421ce62c164be89c953d7a51fa9835..c1a1cce82b0b52e216b600715669986cceb5b35e 100755 (executable)
@@ -160,4 +160,9 @@ config_kernel() {
                sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_VIRTIO_NET.*/CONFIG_VIRTIO_NET=y/g'
                sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_VHOST_NET.*/CONFIG_VHOST_NET=y/g'
        fi 
+
+       for KEY in "${!KCONFIG[@]}"; do
+               VALUE="${KCONFIG[$KEY]}"
+               sed -i ${KERNEL_DIR}/.config -e "s/#\? \?$KEY.*/$KEY=$VALUE/g'
+       done
 }
index 83fbb515613df673cf3091ac71e453469eb7fbd7..2784992e591e26e545d742ca4f5a5172823341bd 100755 (executable)
--- a/genkernel
+++ b/genkernel
@@ -79,6 +79,7 @@ trap trap_cleanup SIGHUP SIGQUIT SIGINT SIGTERM SIGKILL
 BUILD_KERNEL=0
 BUILD_RAMDISK=0
 BUILD_MODULES=0
+declare -A KCONFIG
 
 # Parse all command line options...
 Options=$* # Save for later