commit: db881955a5d03740db2dd55f33ffeeda373bf611 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> AuthorDate: Fri Mar 29 02:53:53 2019 +0000 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> CommitDate: Fri Mar 29 04:12:22 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=db881955
determine_config_file(): add support for file path (tilde) expansion In addition, we make --kernel-config parameter more exclusive: Before this change, if user had set --kernel-config but value was invalid (i.e. file didn't exist) we silently fallback to default configuration. Now we will error out if --kernel-config is set but value is invalid (i.e. no file). Closes: https://bugs.gentoo.org/412321 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> gen_configkernel.sh | 67 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/gen_configkernel.sh b/gen_configkernel.sh index 541a3a8..34fdbe1 100755 --- a/gen_configkernel.sh +++ b/gen_configkernel.sh @@ -4,41 +4,60 @@ # Fills variable KERNEL_CONFIG determine_config_file() { print_info 2 "Checking for suitable kernel configuration..." - for f in \ - "${CMD_KERNEL_CONFIG}" \ - "/etc/kernels/kernel-config-${ARCH}-${KV}" \ - "${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" \ - "${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" \ - "${GK_SHARE}/arch/${ARCH}/generated-config" \ - "${GK_SHARE}/arch/${ARCH}/kernel-config" \ - "${DEFAULT_KERNEL_CONFIG}" - do - [ -z "${f}" ] && continue - - if [ -f "${f}" ] + if [ -n "${CMD_KERNEL_CONFIG}" ] + then + KERNEL_CONFIG=$(expand_file "${CMD_KERNEL_CONFIG}") + if [ -z "${KERNEL_CONFIG}" ] then - if grep -sq THIS_CONFIG_IS_BROKEN "$f" + error_msg="No kernel .config: Cannot use '${CMD_KERNEL_CONFIG}' value. " + error_msg+="Check --kernel-config value or unset " + error_msg+="to use default kernel config provided by genkernel." + gen_die "${error_msg}" + fi + else + for f in \ + "/etc/kernels/kernel-config-${ARCH}-${KV}" \ + "${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" \ + "${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" \ + "${GK_SHARE}/arch/${ARCH}/generated-config" \ + "${GK_SHARE}/arch/${ARCH}/kernel-config" \ + "${DEFAULT_KERNEL_CONFIG}" + do + [ -z "${f}" ] && continue + + if [ -f "${f}" ] then - print_info 2 "$(getIndent 1)- '${f}' is marked as broken; Skipping..." + if grep -sq THIS_CONFIG_IS_BROKEN "$f" + then + print_info 2 "$(getIndent 1)- '${f}' is marked as broken; Skipping..." + else + KERNEL_CONFIG="$f" && break + fi else - KERNEL_CONFIG="$f" && break + print_info 2 "$(getIndent 1)- '${f}' not found; Skipping..." fi - else - print_info 2 "$(getIndent 1)- '${f}' not found; Skipping..." - fi - done + done - if [ -z "${KERNEL_CONFIG}" ] - then - gen_die 'No kernel .config specified, or file not found!' + if [ -z "${KERNEL_CONFIG}" ] + then + gen_die 'No kernel .config specified, or file not found!' + fi fi KERNEL_CONFIG="$(readlink -f "${KERNEL_CONFIG}")" # Validate the symlink result if any - if [ ! -f "${KERNEL_CONFIG}" ] + if [ -z "${KERNEL_CONFIG}" -o ! -f "${KERNEL_CONFIG}" ] then - gen_die "No kernel .config: symlinked file '$KERNEL_CONFIG' not found!" + if [ -n "${CMD_KERNEL_CONFIG}" ] + then + error_msg="No kernel .config: File '${CMD_KERNEL_CONFIG}' not found! " + error_msg+="Check --kernel-config value or unset " + error_msg+="to use default kernel config provided by genkernel." + gen_die "${error_msg}" + else + gen_die "No kernel .config: symlinked file '${KERNEL_CONFIG}' not found!" + fi fi }