summaryrefslogtreecommitdiff
path: root/abuild.in
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2015-06-03 06:28:34 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2015-06-03 06:28:34 +0000
commitc70dbf84953826c7b39f3991864dfffd7a132a57 (patch)
tree3004287140dbc129f29654ac720a4324da0ec7ab /abuild.in
parent5e268f8d70d29621c3d93170c0ddf6b19f69317d (diff)
downloadabuild-c70dbf84953826c7b39f3991864dfffd7a132a57.tar.gz
abuild-c70dbf84953826c7b39f3991864dfffd7a132a57.tar.bz2
abuild-c70dbf84953826c7b39f3991864dfffd7a132a57.tar.xz
abuild-c70dbf84953826c7b39f3991864dfffd7a132a57.zip
abuild: automatically detect symlink targets in other subpackages
Automatically pull in dependencies for symlink targets provided by other subpackages. This is mainly for pulling in target of .so symlinks.
Diffstat (limited to 'abuild.in')
-rw-r--r--abuild.in45
1 files changed, 43 insertions, 2 deletions
diff --git a/abuild.in b/abuild.in
index 0de5e49..4607da5 100644
--- a/abuild.in
+++ b/abuild.in
@@ -886,6 +886,19 @@ prepare_trace_rpaths() {
fi
}
+# search for broken symlinks so we later can pull in proper depends
+prepare_symlinks() {
+ local dir="${subpkgdir:-$pkgdir}"
+ options_has "!tracedeps" && return 0
+ cd "$dir" || return 1
+ find -type l | while read symlink; do
+ if ! [ -e "$symlink" ]; then
+ echo "$symlink $(readlink $symlink)" \
+ >> "$controldir"/.symlinks
+ fi
+ done
+}
+
# check if dir has arch specific binaries
dir_has_arch_binaries() {
local dir="$1"
@@ -920,7 +933,8 @@ archcheck() {
prepare_package() {
msg "Preparing ${subpkgname:+sub}package ${subpkgname:-$pkgname}..."
stripbin
- prepare_metafiles && prepare_trace_rpaths || return 1
+ prepare_metafiles && prepare_trace_rpaths && prepare_symlinks \
+ || return 1
archcheck
}
@@ -1004,6 +1018,12 @@ trace_apk_deps() {
autodeps="$autodeps $found"
done
+ # symlink targets
+ for i in $(sort -u "$dir"/.symlinks-needs 2>/dev/null); do
+ msg " added $i (symlink target)"
+ autodeps="$autodeps $i"
+ done
+
echo "# automatically detected:" >> "$dir"/.PKGINFO
if [ -f "$dir"/.provides-so ]; then
sed 's/^\(.*\) \([0-9].*\)/provides = so:\1=\2/' "$dir"/.provides-so \
@@ -1042,6 +1062,10 @@ scan_shared_objects() {
local name="$1" controldir="$2" datadir="$3"
local opt= i=
+ if [ "$arch" != "noarch" ]; then
+ return 0
+ fi
+
# allow spaces in paths
IFS=:
set -- $(find_scanelf_paths "$datadir")
@@ -1112,6 +1136,22 @@ scan_shared_objects() {
done > "$controldir"/.needs-so
}
+# find which package provides file that symlink points to
+scan_symlink_targets() {
+ local name="$1" dir="$2" datadir="$3"
+ local symfile
+ cd "$datadir"
+ for symfile in "$pkgbasedir"/.control.*/.symlinks; do
+ [ -e "$symfile" ] || continue
+ while read symlink target; do
+ if [ -e "${symlink%/*}"/"$target" ]; then
+ local d="${symfile%/.symlinks}"
+ echo "$name" >> "$d"/.symlinks-needs
+ fi
+ done < "$symfile"
+ done
+}
+
# read size in bytes from stdin and show as human readable
human_size() {
awk '{ split("B KB MB GB TB PB", type)
@@ -1124,13 +1164,14 @@ create_apks() {
local file= dir= name= ver= apk= datadir= size=
getpkgver || return 1
mkdir -p "$PKGDEST"
- if [ "$arch" != "noarch" ] && ! options_has "!tracedeps"; then
+ if ! options_has "!tracedeps"; then
for file in "$pkgbasedir"/.control.*/.PKGINFO; do
dir="${file%/.PKGINFO}"
name="$(pkginfo_val pkgname $file)"
datadir="$pkgbasedir"/$name
subpkgname=$name
scan_shared_objects "$name" "$dir" "$datadir"
+ scan_symlink_targets "$name" "$dir" "$datadir"
done
fi
for file in "$pkgbasedir"/.control.*/.PKGINFO; do