diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2019-03-29 03:53:53 +0100 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2019-03-29 05:12:22 +0100 |
commit | db881955a5d03740db2dd55f33ffeeda373bf611 (patch) | |
tree | 114652093fcc3ebe0449c0c17638165e8530ef6c | |
parent | Add new function expand_file() to allow file path expansion (diff) | |
download | genkernel-db881955.tar.gz genkernel-db881955.tar.bz2 genkernel-db881955.zip |
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@gentoo.org>
-rwxr-xr-x | gen_configkernel.sh | 67 |
1 files changed, 43 insertions, 24 deletions
diff --git a/gen_configkernel.sh b/gen_configkernel.sh index 541a3a81..34fdbe16 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 } |