diff options
author | Allan McRae <allan@archlinux.org> | 2010-09-29 22:24:07 +1000 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-10-05 11:03:28 -0500 |
commit | c0f58ea9a22c64e42b6784663ceb7272565428f5 (patch) | |
tree | dc107d8c38a36bb67d277fa89fec0d0c68170d9f | |
parent | 960c2cdcf7583251592b02c41161cea65eba28fd (diff) |
makepkg: canonicalize paths from environmental variables
This prevents circular symlinks and weird final package locations
when using commands like 'PKGDEST="." makepkg'.
Fixes FS#20922.
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | scripts/makepkg.sh.in | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 2f1c747b..3a7a4d1c 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1410,6 +1410,20 @@ run_split_packaging() { done } +# Canonicalize a directory path if it exists +canonicalize_path() { + local path="$1"; + + if [[ -d $path ]]; then + ( + cd "$path" + pwd -P + ) + else + echo "$path" + fi +} + # getopt like parser parse_options() { local short_options=$1; shift; @@ -1615,10 +1629,10 @@ while true; do shift done -#preserve environment variables -_PKGDEST=${PKGDEST} -_SRCDEST=${SRCDEST} -_SRCPKGDEST=${SRCPKGDEST} +# preserve environment variables and canonicalize path +[[ -n ${PKGDEST} ]] && _PKGDEST=$(canonicalize_path ${PKGDEST}) +[[ -n ${SRCDEST} ]] && _SRCDEST=$(canonicalize_path ${SRCDEST}) +[[ -n ${SRCPKGDEST} ]] && _SRCPKGDEST=$(canonicalize_path ${SRCPKGDEST}) # default config is makepkg.conf MAKEPKG_CONF=${MAKEPKG_CONF:-$confdir/makepkg.conf} |