makepkg: libprovides: don't provide both versioned and unversioned sonames

If multiple files match the pattern libfoo.so*, we want to check each of
them and see if they are shared libraries, and if so, if they have
versions attached.

But some packages can have both shared libraries and random files which
match the filename pattern. This is true at least for files in
/usr/share/gdb/auto-load/, which must match the filename they are paired
with, followed by "-gdb.py" (or some other gdb scripting ext), but
definitely don't contain a shared library. In this case, we don't want
to double-report the library in the generated provides.

It's also possible (probably) for a package to provide a versioned as
well as an unversioned shared library, but in such cases a single
provides entry is sufficient to cover both cases (and the libdepends
for the depending package would contain an unversioned dependency).

Solve this by keeping track of whether we have added a versioned soname
provides already, and then only adding a maximum of one unversioned
provides *iff* there isn't a versioned one yet.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Eli Schwartz 2020-05-14 13:05:30 -04:00 committed by Allan McRae
parent 4533c6a8e0
commit 406a37206f

View file

@ -522,9 +522,10 @@ find_libdepends() {
find_libprovides() { find_libprovides() {
local p libprovides missing local p versioned_provides libprovides missing
for p in "${provides[@]}"; do for p in "${provides[@]}"; do
missing=0 missing=0
versioned_provides=()
case "$p" in case "$p" in
*.so) *.so)
mapfile -t filename < <(find "$pkgdir" -type f -name $p\* | LC_ALL=C sort) mapfile -t filename < <(find "$pkgdir" -type f -name $p\* | LC_ALL=C sort)
@ -537,7 +538,6 @@ find_libprovides() {
local sofile=$(LC_ALL=C readelf -d "$fn" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p') local sofile=$(LC_ALL=C readelf -d "$fn" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
if [[ -z "$sofile" ]]; then if [[ -z "$sofile" ]]; then
warning "$(gettext "Library listed in %s is not versioned: %s")" "'provides'" "$p" warning "$(gettext "Library listed in %s is not versioned: %s")" "'provides'" "$p"
libprovides+=("$p")
continue continue
fi fi
@ -547,25 +547,25 @@ find_libprovides() {
# extract the library major version # extract the library major version
local soversion="${sofile##*\.so\.}" local soversion="${sofile##*\.so\.}"
libprovides+=("${p}=${soversion}-${soarch}") versioned_provides+=("${p}=${soversion}-${soarch}")
else else
warning "$(gettext "Library listed in %s is not a shared object: %s")" "'provides'" "$p" warning "$(gettext "Library listed in %s is not a shared object: %s")" "'provides'" "$p"
libprovides+=("$p")
fi fi
done done
else else
libprovides+=("$p")
missing=1 missing=1
fi fi
;; ;;
*)
libprovides+=("$p")
;;
esac esac
if (( missing )); then if (( missing )); then
warning "$(gettext "Cannot find library listed in %s: %s")" "'provides'" "$p" warning "$(gettext "Cannot find library listed in %s: %s")" "'provides'" "$p"
fi fi
if (( ${#versioned_provides[@]} > 0 )); then
libprovides+=("${versioned_provides[@]}")
else
libprovides+=("$p")
fi
done done
(( ${#libprovides[@]} )) && printf '%s\n' "${libprovides[@]}" (( ${#libprovides[@]} )) && printf '%s\n' "${libprovides[@]}"