commit:     01a319d31fa8dfc6dba903ca202f4a915d49f2dc
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 10 18:20:45 2019 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Sat Aug 10 18:34:33 2019 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=01a319d3

gen_configkernel.sh: determine_kernel_config_file(): Add kconfig containing 
KERNEL_LOCALVERSION to kconfig candidate list

Since we added $ARCH to KERNEL_LOCALVERSION by default,
$KV from fresh kernel sources won't match with saved kernel
config file anymore which will break kernel upgrades when
saved kernel config file was just copied to new kernel
version without removing LOV part.

WIth this commit we still prefer extracted $KV when looking
for kernel config file, however, we will also look for
kernel config file where $KV contains KERNEL_LOCALVERSION
we are going to use in addition.

Bug: https://bugs.gentoo.org/691852
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 gen_configkernel.sh | 36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/gen_configkernel.sh b/gen_configkernel.sh
index 4cfd246..2ff983f 100755
--- a/gen_configkernel.sh
+++ b/gen_configkernel.sh
@@ -17,17 +17,41 @@ determine_kernel_config_file() {
                fi
        else
                local -a kconfig_candidates
-               kconfig_candidates+=( 
"${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" )
-               kconfig_candidates+=( 
"${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" )
-               kconfig_candidates+=( 
"${GK_SHARE}/arch/${ARCH}/generated-config" )
-               kconfig_candidates+=( "${GK_SHARE}/arch/${ARCH}/kernel-config" )
-               kconfig_candidates+=( "${DEFAULT_KERNEL_CONFIG}" )
+
+               local -a gk_kconfig_candidates
+               gk_kconfig_candidates+=( 
"${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" )
+               gk_kconfig_candidates+=( 
"${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" )
+               gk_kconfig_candidates+=( 
"${GK_SHARE}/arch/${ARCH}/generated-config" )
+               gk_kconfig_candidates+=( 
"${GK_SHARE}/arch/${ARCH}/kernel-config" )
+               gk_kconfig_candidates+=( "${DEFAULT_KERNEL_CONFIG}" )
 
                if [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" = 
"default" ]
                then
                        print_info 1 "Default configuration was forced. Will 
ignore any user kernel configuration!"
+                       kconfig_candidates=( ${gk_kconfig_candidates[@]} )
                else
-                       kconfig_candidates=( 
"/etc/kernels/${GK_FILENAME_CONFIG}" "/etc/kernels/kernel-config-${ARCH}-${KV}" 
${kconfig_candidates[@]} )
+                       local -a user_kconfig_candidates
+
+                       # Always prefer kernel config based on actual $KV 
reading
+                       user_kconfig_candidates+=( 
"/etc/kernels/${GK_FILENAME_CONFIG}" )
+
+                       if [ -n "${KERNEL_LOCALVERSION}" -a 
"${KERNEL_LOCALVERSION}" != "UNSET" ]
+                       then
+                               # Look for kernel config based on 
KERNEL_LOCALVERSION
+                               # which we are going to use, too.
+                               # This will allow user to copy previous kernel 
config file
+                               # which includes LOV by default to new version 
when doing
+                               # kernel upgrade since we add $ARCH to $LOV by 
default.
+                               user_kconfig_candidates+=( 
"/etc/kernels/kernel-config-${VER}.${PAT}.${SUB}${EXV}${KERNEL_LOCALVERSION}" )
+                       fi
+
+                       # Look for genkernel-3.x configs for backward 
compatibility, too
+                       user_kconfig_candidates+=( 
"/etc/kernels/kernel-config-${ARCH}-${KV}" )
+
+                       kconfig_candidates=(
+                                ${user_kconfig_candidates[@]}
+                                ${gk_kconfig_candidates[@]}
+                       )
                fi
 
                local f

Reply via email to