[pacman-dev] [PATCH 1/2] libmakepkg: Fix handling of file paths in get_filepath
Vladimir Panteleev
archlinux at thecybershadow.net
Sat Apr 28 09:31:07 UTC 2018
With local sources containing a path component, get_filepath used to
silently discard the non-filename part of the source URI, which led to
uninformative errors (as well as not being able to place source files
in a subdirectory).
Correct this bug by explicitly adding a case for the local protocol,
and appropriately resolve file paths (local or global) to an absolute
one usable by extract_file.
---
scripts/libmakepkg/util/source.sh.in | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/scripts/libmakepkg/util/source.sh.in b/scripts/libmakepkg/util/source.sh.in
index 17e44664..5092347d 100644
--- a/scripts/libmakepkg/util/source.sh.in
+++ b/scripts/libmakepkg/util/source.sh.in
@@ -85,8 +85,9 @@ get_filename() {
# Return the absolute filename of a source entry
get_filepath() {
- local file="$(get_filename "$1")"
- local proto="$(get_protocol "$1")"
+ local netfile="$1"
+ local file="$(get_filename "$netfile")"
+ local proto="$(get_protocol "$netfile")"
case $proto in
bzr*|git*|hg*|svn*)
@@ -98,6 +99,23 @@ get_filepath() {
return 1
fi
;;
+ local)
+ if [[ "$netfile" == /* ]]; then
+ # absolute path
+ if [[ -f "$netfile" ]]; then
+ file="$netfile"
+ else
+ return 1
+ fi
+ elif [[ -f "$startdir/$netfile" ]]; then
+ # relative path
+ file="$startdir/$netfile"
+ elif [[ -f "$SRCDEST/$netfile" ]]; then
+ file="$SRCDEST/$netfile"
+ else
+ return 1
+ fi
+ ;;
*)
if [[ -f "$startdir/$file" ]]; then
file="$startdir/$file"
--
2.17.0
More information about the pacman-dev
mailing list