From ab9e920b52ca2d178e174b04d89b3eec875deed7 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 3 Jul 2011 12:21:36 -0400 Subject: mkinitcpio: refactor BASEDIR resolution This should be performed first, to avoid false positives on any checks that would have been previously done before we knew our BASEDIR was valid. Remove usage of readlink here as well, and use pushd/pwd to resolve. The final trimming of any trailing slash (which might be the entire BASEDIR value) resolves an edge case bug where specifying a BASEDIR that resolved to '/' would cause explosions in add_symlink. Signed-off-by: Dave Reisner --- mkinitcpio | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mkinitcpio b/mkinitcpio index 289c98d..434172e 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -31,7 +31,8 @@ declare -a SKIPHOOKS ADDED_MODULES MODPATHS PATH=$PATH:/sbin:/usr/sbin # Sanitize environment further # GREP_OPTIONS="--color=always" will break everything -unset GREP_OPTIONS +# CDPATH can affect cd and pushd +unset GREP_OPTIONS CDPATH usage() { cat </dev/null; then + die "base directory '$BASEDIR' does not exist or is not a directory" + fi + BASEDIR=$(pwd -P) + BASEDIR=${BASEDIR%/} + popd &>/dev/null +fi + if [[ $optkver ]]; then if ! KERNELVERSION=$(get_kernver "$optkver"); then die "'$optkver' is an invalid kernel specifier" @@ -230,16 +241,6 @@ if [[ $PRESET ]]; then fi fi -if [[ $BASEDIR ]]; then - # resolve the path. it might be a relative path and/or contain symlinks - abspath=$(readlink -e "$BASEDIR") - if [[ -z $abspath ]]; then - die "base directory '$BASEDIR' does not exist or is not a directory" - fi - BASEDIR=$abspath - unset abspath -fi - if [[ $GENIMG ]]; then IMGPATH=$(readlink -f "$GENIMG") if [[ -z $IMGPATH || ! -w ${IMGPATH%/*} ]]; then -- cgit v1.2.3-24-g4f1b