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.
This commit is contained in:
Natanael Copa 2015-06-03 06:28:34 +00:00
parent 5e268f8d70
commit c70dbf8495

View File

@ -886,6 +886,19 @@ prepare_trace_rpaths() {
fi 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 # check if dir has arch specific binaries
dir_has_arch_binaries() { dir_has_arch_binaries() {
local dir="$1" local dir="$1"
@ -920,7 +933,8 @@ archcheck() {
prepare_package() { prepare_package() {
msg "Preparing ${subpkgname:+sub}package ${subpkgname:-$pkgname}..." msg "Preparing ${subpkgname:+sub}package ${subpkgname:-$pkgname}..."
stripbin stripbin
prepare_metafiles && prepare_trace_rpaths || return 1 prepare_metafiles && prepare_trace_rpaths && prepare_symlinks \
|| return 1
archcheck archcheck
} }
@ -1004,6 +1018,12 @@ trace_apk_deps() {
autodeps="$autodeps $found" autodeps="$autodeps $found"
done 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 echo "# automatically detected:" >> "$dir"/.PKGINFO
if [ -f "$dir"/.provides-so ]; then if [ -f "$dir"/.provides-so ]; then
sed 's/^\(.*\) \([0-9].*\)/provides = so:\1=\2/' "$dir"/.provides-so \ 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 name="$1" controldir="$2" datadir="$3"
local opt= i= local opt= i=
if [ "$arch" != "noarch" ]; then
return 0
fi
# allow spaces in paths # allow spaces in paths
IFS=: IFS=:
set -- $(find_scanelf_paths "$datadir") set -- $(find_scanelf_paths "$datadir")
@ -1112,6 +1136,22 @@ scan_shared_objects() {
done > "$controldir"/.needs-so 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 # read size in bytes from stdin and show as human readable
human_size() { human_size() {
awk '{ split("B KB MB GB TB PB", type) awk '{ split("B KB MB GB TB PB", type)
@ -1124,13 +1164,14 @@ create_apks() {
local file= dir= name= ver= apk= datadir= size= local file= dir= name= ver= apk= datadir= size=
getpkgver || return 1 getpkgver || return 1
mkdir -p "$PKGDEST" mkdir -p "$PKGDEST"
if [ "$arch" != "noarch" ] && ! options_has "!tracedeps"; then if ! options_has "!tracedeps"; then
for file in "$pkgbasedir"/.control.*/.PKGINFO; do for file in "$pkgbasedir"/.control.*/.PKGINFO; do
dir="${file%/.PKGINFO}" dir="${file%/.PKGINFO}"
name="$(pkginfo_val pkgname $file)" name="$(pkginfo_val pkgname $file)"
datadir="$pkgbasedir"/$name datadir="$pkgbasedir"/$name
subpkgname=$name subpkgname=$name
scan_shared_objects "$name" "$dir" "$datadir" scan_shared_objects "$name" "$dir" "$datadir"
scan_symlink_targets "$name" "$dir" "$datadir"
done done
fi fi
for file in "$pkgbasedir"/.control.*/.PKGINFO; do for file in "$pkgbasedir"/.control.*/.PKGINFO; do