summaryrefslogtreecommitdiffstats
path: root/abuild.in
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2015-06-05 12:11:47 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2015-06-05 12:11:47 +0000
commitb4c8ef7dadf851e07188ea5ef64922a6ee8158b5 (patch)
tree4047578388b1f9621446703287653a1a33233043 /abuild.in
parent9d91994a748fae94730dfa8bd46b53f35f3f8b95 (diff)
downloadabuild-b4c8ef7dadf851e07188ea5ef64922a6ee8158b5.tar.bz2
abuild-b4c8ef7dadf851e07188ea5ef64922a6ee8158b5.tar.xz
abuild: normalize path when finding symlink targets
some paths like usr/lib/../../lib/libudev.so.0.13.0 will fail to resolve if usr/lib is does not exist, even if lib/libudev.so.0.13.0 does. To solve thise we normalize out the ../ in path string before we try to resolve it.
Diffstat (limited to 'abuild.in')
-rw-r--r--abuild.in23
1 files changed, 19 insertions, 4 deletions
diff --git a/abuild.in b/abuild.in
index 12e43da..662a06f 100644
--- a/abuild.in
+++ b/abuild.in
@@ -1180,6 +1180,21 @@ scan_shared_objects() {
done > "$controldir"/.needs-so
}
+# normalize a path string
+normalize_path() {
+ local oifs="$IFS" pathstr= i=
+ IFS='/'
+ set -- $1
+ for i; do
+ case "$i" in
+ "."|"") continue;;
+ "..") pathstr="${pathstr%%/${pathstr##*/}}";;
+ *) pathstr="${pathstr}/$i";;
+ esac
+ done
+ echo "$pathstr"
+}
+
# find which package provides file that symlink points to
scan_symlink_targets() {
local name="$1" dir="$2" datadir="$3"
@@ -1188,10 +1203,10 @@ scan_symlink_targets() {
for symfile in "$pkgbasedir"/.control.*/.symlinks; do
[ -e "$symfile" ] || continue
while read symlink target; do
- case "$target" in
- /*) targetpath="${datadir}/$target";;
- *) targetpath="${symlink%/*}/$target";;
- esac
+ if [ "${target#/}" = "$target" ]; then
+ target="${symlink%/*}/$target"
+ fi
+ targetpath="$datadir"/$(normalize_path "$target")
if [ -e "$targetpath" ] || [ -L "$targetpath" ]; then
local d="${symfile%/.symlinks}"
echo "$name=$pkgver-r$pkgrel" \