diff options
author | 2019-11-18 03:40:48 +0100 | |
---|---|---|
committer | 2019-11-19 17:47:53 +0100 | |
commit | 4344d6de2451e163bc922df9700b5729b46d6517 (patch) | |
tree | 0ee0af6b2aa46241d3feb1f6269241b87bafc0cd /gen_determineargs.sh | |
parent | gen_determineargs.sh: determine_real_args(): Check for `realpath -m` support (diff) | |
download | genkernel-4344d6de2451e163bc922df9700b5729b46d6517.tar.gz genkernel-4344d6de2451e163bc922df9700b5729b46d6517.tar.bz2 genkernel-4344d6de2451e163bc922df9700b5729b46d6517.zip |
gen_determineargs.sh: determine_real_args(): Initialize $KERNEL_OUTPUTDIR after $KERNEL_DIR
Bug: https://bugs.gentoo.org/698828
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'gen_determineargs.sh')
-rwxr-xr-x | gen_determineargs.sh | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/gen_determineargs.sh b/gen_determineargs.sh index 9233c42e..9a9db9b0 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -302,7 +302,6 @@ 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_APPEND_LOCALVERSION CMD_KERNEL_APPEND_LOCALVERSION set_config_with_override STRING KERNEL_LOCALVERSION CMD_KERNEL_LOCALVERSION "-%%ARCH%%" set_config_with_override STRING MODPROBEDIR CMD_MODPROBEDIR "/etc/modprobe.d" @@ -374,6 +373,29 @@ determine_real_args() { set_config_with_override BOOL INSTALL CMD_INSTALL "yes" set_config_with_override BOOL CLEANUP CMD_CLEANUP "yes" + # We need to expand and normalize provided $KERNEL_DIR and + # we need to do it early because $KERNEL_OUTPUTDIR will be + # set to $KERNEL_DIR by default. + KERNEL_DIR=$(cd -L "${CMD_KERNEL_DIR}" &>/dev/null && pwd -L 2>/dev/null) + if [ -z "${KERNEL_DIR}" ] + then + # We tried to use cd first to keep symlinks (i.e. to preserve + # a path like /usr/src/linux) which probably failed + # because $KERNEL_DIR does NOT exist. However, at this stage + # we don't know if $KERNEL_DIR is required so we have to + # accept an invalid value... + KERNEL_DIR=$(expand_file "${CMD_KERNEL_DIR}" 2>/dev/null) + fi + + if [[ "${KERNEL_DIR}" != "${CMD_KERNEL_DIR}" ]] + then + print_info 5 " KERNEL_DIR value \"${CMD_KERNEL_DIR}\" normalized to \"${KERNEL_DIR}\"" + fi + + # Now that $KERNEL_DIR value is expanded and normalized we can + # initialize $KERNEL_OUTPUTDIR... + set_config_with_override STRING KERNEL_OUTPUTDIR CMD_KERNEL_OUTPUTDIR "${KERNEL_DIR}" + local can_write_log=no if [ -w "${LOGFILE}" ] then @@ -717,16 +739,35 @@ determine_real_args() { ;; esac - if isTrue "$(has_space_characters "${KERNEL_OUTPUTDIR}")" + if [[ "${KERNEL_DIR}" != "${KERNEL_OUTPUTDIR}" ]] then - # Kernel Makefile doesn't support spaces in outputdir path... - gen_die "--kernel-outputdir '${KERNEL_OUTPUTDIR}' contains space character(s) which are not supported!" + if [ -z "${KERNEL_OUTPUTDIR}" ] + then + gen_die "No --kernel-outputdir specified!" + fi + + KERNEL_OUTPUTDIR=$(expand_file "${KERNEL_OUTPUTDIR}") + if [ -z "${KERNEL_OUTPUTDIR}" ] + then + gen_die "Failed to expand set --kernel-outputdir '${CMD_KERNEL_OUTPUTDIR}'!" + fi + + if [[ "${KERNEL_OUTPUTDIR}" != "${CMD_KERNEL_OUTPUTDIR}" ]] + then + print_info 5 "KERNEL_OUTPUTDIR value '${CMD_KERNEL_OUTPUTDIR}' normalized to '${KERNEL_OUTPUTDIR}'" + fi + + if [ ! -d "${KERNEL_OUTPUTDIR}" ] + then + print_warning 3 "Set --kernel-outputdir '${KERNEL_OUTPUTDIR}' does not exist; Will try to create ..." + mkdir -p "${KERNEL_OUTPUTDIR}" || gen_die "Failed to create '${KERNEL_OUTPUTDIR}'!" + fi fi - if [ "${KERNEL_DIR}" != "${KERNEL_OUTPUTDIR}" -a ! -d "${KERNEL_OUTPUTDIR}" ] + if isTrue "$(has_space_characters "${KERNEL_OUTPUTDIR}")" then - print_warning 3 "Set --kernel-outputdir '${KERNEL_OUTPUTDIR}' does not exist; Will try to create ..." - mkdir -p "${KERNEL_OUTPUTDIR}" || gen_die "Failed to create '${KERNEL_OUTPUTDIR}'!" + # Kernel Makefile doesn't support spaces in outputdir path... + gen_die "--kernel-outputdir '${KERNEL_OUTPUTDIR}' contains space character(s) which are not supported!" fi fi |