hooks/gen-rt-deps: Look for rt-deps by subpkg first, common/shlibs later

This commit is contained in:
Đoàn Trần Công Danh 2023-08-09 13:19:01 +07:00 committed by Đoàn Trần Công Danh
parent 6d6cf11a2b
commit 9ee583c661

View file

@ -47,6 +47,7 @@ store_pkgdestdir_rundeps() {
hook() { hook() {
local depsftmp f lf j mapshlibs sorequires _curdep elfmagic broken_shlibs verify_deps local depsftmp f lf j mapshlibs sorequires _curdep elfmagic broken_shlibs verify_deps
local _shlib_dir="${XBPS_STATEDIR}/shlib-provides"
# Disable trap on ERR, xbps-uhelper cmd might return error... but not something # Disable trap on ERR, xbps-uhelper cmd might return error... but not something
# to be worried about because if there are broken shlibs this hook returns # to be worried about because if there are broken shlibs this hook returns
@ -95,65 +96,42 @@ hook() {
# above, the mapping is done thru the common/shlibs file. # above, the mapping is done thru the common/shlibs file.
# #
for f in ${verify_deps}; do for f in ${verify_deps}; do
unset _f j rdep _rdep rdepcnt soname _pkgname _rdepver found unset _rdep _pkgname _rdepver
_f=$(echo "$f"|sed -E 's|\+|\\+|g')
rdep="$(grep -E "^${_f}[[:blank:]]+.*$" $mapshlibs|cut -d ' ' -f2)" if [ "$(find ${PKGDESTDIR} -name "$f")" ]; then
rdepcnt="$(grep -E "^${_f}[[:blank:]]+.*$" $mapshlibs|cut -d ' ' -f2|wc -l)"
if [ -z "$rdep" ]; then
# Ignore libs by current pkg # Ignore libs by current pkg
soname=$(find ${PKGDESTDIR} -name "$f") echo " SONAME: $f <-> $pkgname (ignored)"
if [ -z "$soname" ]; then continue
# If this library is provided by a subpkg of sourcepkg, use that subpkg
elif _pkgname="$(cd "$_shlib_dir" && grep -F -l -x "$f" *.soname 2>/dev/null)"; then
# If that library has SONAME, add it to shlibs-requires, too.
_pkgname=${_pkgname%.soname}
_sdep="${_pkgname}-${version}_${revision}"
sorequires+="${f} "
elif _pkgname="$(cd "$_shlib_dir" && grep -F -l -x "$f" *.nosoname 2>/dev/null)"; then
_pkgname=${_pkgname%.nosoname}
_sdep="${_pkgname}-${version}_${revision}"
else
_rdep="$(awk -v sl="$f" '$1 == sl { print $2; exit; }' "$mapshlibs")"
if [ -z "$_rdep" ]; then
msg_red_nochroot " SONAME: $f <-> UNKNOWN PKG PLEASE FIX!\n" msg_red_nochroot " SONAME: $f <-> UNKNOWN PKG PLEASE FIX!\n"
broken_shlibs=1 broken_shlibs=1
else continue
echo " SONAME: $f <-> $pkgname (ignored)"
fi fi
continue _pkgname=$($XBPS_UHELPER_CMD getpkgname "${_rdep}" 2>/dev/null)
elif [ "$rdepcnt" -gt 1 ]; then _rdepver=$($XBPS_UHELPER_CMD getpkgversion "${_rdep}" 2>/dev/null)
unset j found if [ -z "${_pkgname}" -o -z "${_rdepver}" ]; then
# Check if shlib is provided by multiple pkgs. msg_red_nochroot " SONAME: $f <-> UNKNOWN PKG PLEASE FIX!\n"
for j in ${rdep}; do broken_shlibs=1
_pkgname=$($XBPS_UHELPER_CMD getpkgname "$j") continue
# if there's a SONAME matching pkgname, use it.
for x in ${pkgname} ${subpackages}; do
[[ $_pkgname == $x ]] && found=1 && break
done
[[ $found ]] && _rdep=$j && break
done
if [ -z "${_rdep}" ]; then
# otherwise pick up the first one.
for j in ${rdep}; do
[ -z "${_rdep}" ] && _rdep=$j
done
fi fi
else _sdep="${_pkgname}>=${_rdepver}"
_rdep=$rdep
fi
_pkgname=$($XBPS_UHELPER_CMD getpkgname "${_rdep}" 2>/dev/null)
_rdepver=$($XBPS_UHELPER_CMD getpkgversion "${_rdep}" 2>/dev/null)
if [ -z "${_pkgname}" -o -z "${_rdepver}" ]; then
msg_red_nochroot " SONAME: $f <-> UNKNOWN PKG PLEASE FIX!\n"
broken_shlibs=1
continue
fi
# Check if pkg is a subpkg of sourcepkg; if true, ignore version
# in common/shlibs.
_sdep="${_pkgname}>=${_rdepver}"
for _subpkg in ${subpackages}; do
if [ "${_subpkg}" = "${_pkgname}" ]; then
_sdep="${_pkgname}-${version}_${revision}"
break
fi
done
if [ "${_pkgname}" != "${pkgname}" ]; then # By this point, SONAME can't be found in current pkg
echo " SONAME: $f <-> ${_sdep}"
sorequires+="${f} " sorequires+="${f} "
else
# Ignore libs by current pkg
echo " SONAME: $f <-> ${_rdep} (ignored)"
continue
fi fi
echo " SONAME: $f <-> ${_sdep}"
add_rundep "${_sdep}" add_rundep "${_sdep}"
done done
# #