xbps-src: new code to verify shlibs, rundeps from shlibs are added automagically.
This commit is contained in:
parent
9bda824de0
commit
05e4225a55
1 changed files with 81 additions and 87 deletions
|
@ -1,5 +1,5 @@
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2010 Juan Romero Pardines.
|
# Copyright (c) 2010-2011 Juan Romero Pardines.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -43,17 +43,16 @@ find_rundep()
|
||||||
|
|
||||||
verify_rundeps()
|
verify_rundeps()
|
||||||
{
|
{
|
||||||
local j i f nlib verify_deps maplib found_dup igndir
|
local j f nlib verify_deps maplib found_dup igndir
|
||||||
local missing missing_libs rdep builddep rdep_list builddep_list
|
local broken rdep found rsonamef soname_list
|
||||||
|
|
||||||
PKG_DESTDIR="$1"
|
|
||||||
maplib="$XBPS_COMMONVARSDIR/mapping_shlib_binpkg.txt"
|
maplib="$XBPS_COMMONVARSDIR/mapping_shlib_binpkg.txt"
|
||||||
|
|
||||||
[ -n "$noarch" -o -n "$noverifyrdeps" ] && return 0
|
[ -n "$noarch" -o -n "$noverifyrdeps" ] && return 0
|
||||||
msg_normal "$pkgver: verifying required run dependencies, please wait...\n"
|
msg_normal "$pkgver: verifying required shlibs...\n"
|
||||||
|
|
||||||
depsftmp=$(mktemp -t xbps_src_depstmp.XXXXXXXXXX) || exit 1
|
depsftmp=$(mktemp -t xbps_src_depstmp.XXXXXXXXXX) || exit 1
|
||||||
find ${PKG_DESTDIR} -type f -perm -u+w > $depsftmp 2>/dev/null
|
find ${1} -type f -perm -u+w > $depsftmp 2>/dev/null
|
||||||
|
|
||||||
exec 3<&0 # save stdin
|
exec 3<&0 # save stdin
|
||||||
exec < $depsftmp
|
exec < $depsftmp
|
||||||
|
@ -75,8 +74,8 @@ verify_rundeps()
|
||||||
verify_deps="$nlib"
|
verify_deps="$nlib"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
for i in ${verify_deps}; do
|
for j in ${verify_deps}; do
|
||||||
[ "$i" != "$nlib" ] && continue
|
[ "$j" != "$nlib" ] && continue
|
||||||
found_dup=1
|
found_dup=1
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
|
@ -91,99 +90,94 @@ verify_rundeps()
|
||||||
exec 0<&3 # restore stdin
|
exec 0<&3 # restore stdin
|
||||||
rm -f $depsftmp
|
rm -f $depsftmp
|
||||||
|
|
||||||
# Now verify that those required libs are added into package's
|
#
|
||||||
# template via Add_dependency.
|
# Add required run time packages by using required shlibs resolved
|
||||||
|
# above, the mapping is done thru the mapping_shlib_binpkg.txt file.
|
||||||
|
#
|
||||||
for f in ${verify_deps}; do
|
for f in ${verify_deps}; do
|
||||||
# Bail out if maplib is not aware for this lib
|
# Bail out if maplib is not aware for this lib
|
||||||
rdep="$(grep "$f" $maplib|awk '{print $2}')"
|
rdep="$(grep "$f" $maplib|awk '{print $2}')"
|
||||||
rdepcnt="$(grep "$f" $maplib|awk '{print $2}'|wc -l)"
|
rdepcnt="$(grep "$f" $maplib|awk '{print $2}'|wc -l)"
|
||||||
if [ -z "$rdep" ]; then
|
if [ -z "$rdep" ]; then
|
||||||
echo " UNKNOWN PACKAGE FOR SHLIB DEPENDENCY '$f', PLEASE FIX!"
|
echo " SONAME: $f <-> UNKNOWN PKG PLEASE FIX!"
|
||||||
|
broken=1
|
||||||
fi
|
fi
|
||||||
# Ignore libs by current pkg
|
|
||||||
[ "$rdep" = "$pkgname" ] && continue
|
|
||||||
|
|
||||||
# Check if shlib is provided by multiple pkgs.
|
# Check if shlib is provided by multiple pkgs.
|
||||||
if [ "$rdepcnt" -gt 1 ]; then
|
if [ "$rdepcnt" -gt 1 ]; then
|
||||||
echo " shlib dependency '$f' is provided by these pkgs: "
|
|
||||||
for j in ${rdep}; do
|
for j in ${rdep}; do
|
||||||
printf "\t$j\n"
|
[ -z "${_rdep}" ] && _rdep=$j
|
||||||
done
|
done
|
||||||
|
else
|
||||||
|
_rdep=$rdep
|
||||||
|
fi
|
||||||
|
# Ignore libs by current pkg
|
||||||
|
if [ "${_rdep}" = "$pkgname" ]; then
|
||||||
|
echo " SONAME: $f <-> ${_rdep} (ignored)"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
# Warn if rundep is not in template.
|
|
||||||
if find_rundep "$rdep"; then
|
# Add required shlib to rundeps.
|
||||||
echo " REQUIRED SHLIB DEPENDENCY '$f' FROM PACKAGE '$rdep' MISSING, PLEASE FIX!"
|
echo " SONAME: $f <-> ${_rdep}"
|
||||||
missing=1
|
if [ -z "$soname_list" ]; then
|
||||||
if [ -z "$missing_libs" ]; then
|
soname_list="${f}"
|
||||||
missing_libs="$f"
|
else
|
||||||
|
soname_list="${soname_list} ${f}"
|
||||||
|
fi
|
||||||
|
if find_rundep ${_rdep}; then
|
||||||
|
Add_dependency run ${_rdep}
|
||||||
|
fi
|
||||||
|
unset rdep _rdep rdepcnt
|
||||||
|
done
|
||||||
|
|
||||||
|
#
|
||||||
|
# If pkg uses any SONAME not known, error out.
|
||||||
|
#
|
||||||
|
[ -n "$broken" ] && \
|
||||||
|
msg_error "$pkgver: cannot guess required shlibs, aborting!\n"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Update package's rshlibs file.
|
||||||
|
#
|
||||||
|
unset broken
|
||||||
|
msg_normal "$pkgver: updating rshlibs file...\n"
|
||||||
|
rsonamef=${XBPS_SRCPKGDIR}/${pkgname}/${pkgname}.rshlibs
|
||||||
|
if [ ! -f $rsonamef ]; then
|
||||||
|
# file not found, add soname.
|
||||||
|
for j in ${soname_list}; do
|
||||||
|
echo " SONAME: $j (added)"
|
||||||
|
echo "${j}" >> $rsonamef
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# check if soname is already in the rshlibs file.
|
||||||
|
for j in ${soname_list}; do
|
||||||
|
if ! grep -q "$j" $rsonamef; then
|
||||||
|
echo " SONAME: $j (added)"
|
||||||
|
echo "$j" >> $rsonamef
|
||||||
|
broken=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
exec 3<&0 # save stdin
|
||||||
|
exec < $rsonamef
|
||||||
|
# now check if any soname in the rshlibs file is unnecessary.
|
||||||
|
while read f; do
|
||||||
|
for j in ${soname_list}; do
|
||||||
|
if [ "$f" = "$j" ]; then
|
||||||
|
found=1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ -n "$found" ]; then
|
||||||
|
unset found
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
for i in ${missing_libs}; do
|
echo " SONAME: $f (removed, not required)"
|
||||||
[ "$i" != "$f" ] && continue
|
sed -i "/^${f}$/d" $rsonamef
|
||||||
found_dup=1
|
broken=1
|
||||||
break
|
|
||||||
done
|
|
||||||
if [ -z "$found_dup" ]; then
|
|
||||||
missing_libs="$missing_libs $f"
|
|
||||||
fi
|
|
||||||
unset found_dup
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
echo " shlib dependency '$f' provided by the '$rdep' package (OK)."
|
|
||||||
unset rdep
|
|
||||||
done
|
|
||||||
|
|
||||||
[ -z "$missing" ] && return 0
|
|
||||||
|
|
||||||
# Print an informative message suggesting what needs to be added
|
|
||||||
# into the build template.
|
|
||||||
|
|
||||||
msg_normal "The following code needs to be added into the build template:\n"
|
|
||||||
echo "============ CUT HERE ==============="
|
|
||||||
|
|
||||||
for f in ${missing_libs}; do
|
|
||||||
rdep="$(grep "$f" $maplib|awk '{print $2}')"
|
|
||||||
rdepcnt="$(grep "$f" $maplib|awk '{print $2}'|wc -l)"
|
|
||||||
builddep="$(grep "$f" $maplib|awk '{print $3}')"
|
|
||||||
|
|
||||||
# If required shlib is provided by multiple pkgs pass
|
|
||||||
# to next one.
|
|
||||||
[ "$rdepcnt" -gt 1 ] && continue
|
|
||||||
|
|
||||||
if [ -z "$rdep_list" ]; then
|
|
||||||
rdep_list="$rdep"
|
|
||||||
fi
|
|
||||||
if [ -z "$builddep_list" -a -n "$builddep" ]; then
|
|
||||||
builddep_list="$builddep"
|
|
||||||
fi
|
|
||||||
for i in ${rdep_list}; do
|
|
||||||
[ "$rdep" != "$i" ] && continue
|
|
||||||
found_dup=1
|
|
||||||
break
|
|
||||||
done
|
done
|
||||||
if [ -z "$found_dup" ]; then
|
exec 0<&3 # restore stdin
|
||||||
rdep_list="$rdep_list $rdep"
|
fi
|
||||||
fi
|
|
||||||
unset found_dup
|
|
||||||
for i in ${builddep_list}; do
|
|
||||||
[ "$builddep" != "$i" ] && continue
|
|
||||||
found_dup=1
|
|
||||||
break
|
|
||||||
done
|
|
||||||
if [ -z "$found_dup" ]; then
|
|
||||||
builddep_list="$builddep_list $builddep"
|
|
||||||
fi
|
|
||||||
unset found_dup
|
|
||||||
done
|
|
||||||
|
|
||||||
for f in ${rdep_list}; do
|
if [ -n "$broken" ]; then
|
||||||
echo "Add_dependency run $f"
|
msg_error "$pkgver: shlibs changed: a revbump is necessary!\n"
|
||||||
done
|
fi
|
||||||
for f in ${builddep_list}; do
|
|
||||||
echo "Add_dependency build $f"
|
|
||||||
done
|
|
||||||
echo "============ CUT HERE ==============="
|
|
||||||
|
|
||||||
msg_error "$pkgver: incorrect run dependencies, won't continue...\n"
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue