From: W. Trevor King Date: Fri, 8 Mar 2013 13:54:55 +0000 (-0500) Subject: genkernel: Add --kconfig to set specific kernel config options X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=genkernel.git genkernel: Add --kconfig to set specific kernel config options 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. --- diff --git a/gen_cmdline.sh b/gen_cmdline.sh index 5503bb5..6766b4e 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -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== 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 ] diff --git a/gen_configkernel.sh b/gen_configkernel.sh index a69c713..c1a1cce 100755 --- a/gen_configkernel.sh +++ b/gen_configkernel.sh @@ -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 } diff --git a/genkernel b/genkernel index 83fbb51..2784992 100755 --- 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