commit: c85901916e603cac8f92f176a84fbb03d0f0bc6d Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> AuthorDate: Sun Jul 21 13:03:19 2019 +0000 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> CommitDate: Sun Jul 21 16:09:45 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=c8590191
Add --kernel-localversion option This option will set/unset kernel option CONFIG_LOCALVERSION. Closes: https://bugs.gentoo.org/521774 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> doc/genkernel.8.txt | 4 ++++ gen_cmdline.sh | 7 +++++++ gen_configkernel.sh | 19 +++++++++++++++++++ gen_determineargs.sh | 19 +++++++++++++++++++ genkernel.conf | 4 ++++ 5 files changed, 53 insertions(+) diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt index e04e800..15beee6 100644 --- a/doc/genkernel.8.txt +++ b/doc/genkernel.8.txt @@ -124,6 +124,10 @@ KERNEL CONFIGURATION *--*[*no-*]*virtio*:: Adds, or skip adding VirtIO support to kernel configuration. +*--kernel-localversion*=<...>:: + Set kernel option CONFIG_LOCALVERSION. Use special value "UNSET" to + unset any already set LOCALVERSION. + KERNEL COMPILATION ~~~~~~~~~~~~~~~~~~ diff --git a/gen_cmdline.sh b/gen_cmdline.sh index a8700cd..17d66d2 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -75,6 +75,9 @@ longusage() { echo " Kernel configuration file to use for compilation; Use" echo " 'default' to explicitly start from scratch using" echo " genkernel defaults" + echo " --kernel-localversion=<...>" + echo " Set kernel CONFIG_LOCALVERSION, use special value" + echo " 'UNSET' to unset any set LOCALVERSION" echo " --module-prefix=<dir> Prefix to kernel module destination, modules" echo " will be installed in <prefix>/lib/modules" echo " Low-Level Compile settings" @@ -625,6 +628,10 @@ parse_cmdline() { CMD_KERNEL_CONFIG="${*#*=}" print_info 3 "CMD_KERNEL_CONFIG: ${CMD_KERNEL_CONFIG}" ;; + --kernel-localversion=*) + CMD_KERNEL_LOCALVERSION="${*#*=}" + print_info 3 "CMD_KERNEL_LOCALVERSION: ${CMD_KERNEL_LOCALVERSION}" + ;; --module-prefix=*) CMD_INSTALL_MOD_PATH="${*#*=}" print_info 3 "CMD_INSTALL_MOD_PATH: ${CMD_INSTALL_MOD_PATH}" diff --git a/gen_configkernel.sh b/gen_configkernel.sh index 503812c..a5ad953 100755 --- a/gen_configkernel.sh +++ b/gen_configkernel.sh @@ -193,6 +193,25 @@ config_kernel() { fi fi + # --kernel-localversion handling + if [ -n "${KERNEL_LOCALVERSION}" ] + then + local cfg_CONFIG_LOCALVERSION=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_LOCALVERSION") + case "${KERNEL_LOCALVERSION}" in + UNSET) + print_info 2 "$(get_indent 1)>> Ensure that CONFIG_LOCALVERSION is unset ..." + if [ -n "${cfg_CONFIG_LOCALVERSION}" ] + then + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_LOCALVERSION" "" + fi + ;; + *) + print_info 2 "$(get_indent 1)>> Ensure that CONFIG_LOCALVERSION is set ..." + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_LOCALVERSION" "\"${KERNEL_LOCALVERSION}\"" + ;; + esac + fi + # Do we support modules at all? local cfg_CONFIG_MODULES=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_MODULES") if isTrue "${cfg_CONFIG_MODULES}" diff --git a/gen_determineargs.sh b/gen_determineargs.sh index e2eafbb..a82fb0a 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -120,6 +120,7 @@ determine_real_args() { set_config_with_override STRING CROSS_COMPILE CMD_CROSS_COMPILE set_config_with_override STRING BOOTDIR CMD_BOOTDIR "/boot" set_config_with_override STRING KERNEL_OUTPUTDIR CMD_KERNEL_OUTPUTDIR "${KERNEL_DIR}" + set_config_with_override STRING KERNEL_LOCALVERSION CMD_KERNEL_LOCALVERSION set_config_with_override STRING MODPROBEDIR CMD_MODPROBEDIR "/etc/modprobe.d" set_config_with_override BOOL SPLASH CMD_SPLASH "no" @@ -456,6 +457,24 @@ determine_real_args() { fi fi + if isTrue "${BUILD_KERNEL}" + then + if [ -n "${KERNEL_LOCALVERSION}" ] + then + case "${KERNEL_LOCALVERSION}" in + UNSET) + ;; + *) + local valid_localversion_pattern='^-[A-Za-z0-9\-_]{1,}$' + if [[ ! "${KERNEL_LOCALVERSION}" =~ ${valid_localversion_pattern} ]] + then + gen_die "--kernel-localversion value '${KERNEL_LOCALVERSION}' does not match '${valid_localversion_pattern}' regex!" + fi + ;; + esac + fi + fi + if ! isTrue "${BUILD_RAMDISK}" then INTEGRATED_INITRAMFS=0 diff --git a/genkernel.conf b/genkernel.conf index b4f1dbe..b2af4de 100644 --- a/genkernel.conf +++ b/genkernel.conf @@ -278,6 +278,10 @@ DEFAULT_KERNEL_SOURCE="/usr/src/linux" # 'genkernel' #KNAME="genkernel" +# This option will set kernel option CONFIG_LOCALVERSION. +# Use special value "UNSET" to unset already set CONFIG_LOCALVERSION. +#KERNEL_LOCALVERSION="" + # This option is only valid if kerncache is # defined. If there is a valid kerncache no checks # will be made against a kernel source tree.