mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-09 13:07:58 -05:00
makepkg: rework libprovides
This reworks the implmentation of libprovides for the following benefits: - Moves functionality from write_pkginfo() to find_libprovides() - Only calculates the version for libraries specifically requested and not all libraries. This has the disadvantage of running find over the $pkgdir for as many libraries as needed, but is unlikely to be an issue due to caching. - The order of the provides array in the PKGBUILD is kept in the package - There are more warning messages when things fail and those that were there are no longer errors (as I do not think failure of libprovides should result in complete packaging failure) - It is now modular so can be easy extended to other library types other than ELF *.so. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
f8892b9d08
commit
5bbe342932
@ -1084,30 +1084,53 @@ find_libdepends() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
find_libprovides() {
|
find_libprovides() {
|
||||||
local libprovides
|
local libprovides missing
|
||||||
find "$pkgdir" -type f -name \*.so\* | while read filename
|
for p in ${provides[@]}; do
|
||||||
do
|
missing=0
|
||||||
|
case "$p" in
|
||||||
|
*.so)
|
||||||
|
local filename=$(find "$pkgdir" -type f -name $p\*)
|
||||||
|
if [[ $filename ]]; then
|
||||||
|
# packages may provide multiple versions of the same library
|
||||||
|
for fn in ${filename[@]}; do
|
||||||
# check if we really have a shared object
|
# check if we really have a shared object
|
||||||
if LC_ALL=C readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
|
if LC_ALL=C readelf -h "$fn" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
|
||||||
# 64
|
# get the string binaries link to (e.g. libfoo.so.1.2 -> libfoo.so.1)
|
||||||
soarch=$(LC_ALL=C readelf -h "$filename" | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
|
local sofile=$(LC_ALL=C readelf -d "$fn" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
|
||||||
# get the string binaries link to: libfoo.so.1.2 -> libfoo.so.1
|
if [[ -z "$sofile" ]]; then
|
||||||
sofile=$(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
|
warning "$(gettext "Library listed in %s is not versioned: %s")" "'provides'" "$p"
|
||||||
[ -z "$sofile" ] && sofile="${filename##*/}"
|
libprovides=(${libprovides[@]} "$p")
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# extract the library name: libfoo.so
|
# get the library architecture (32 or 64 bit)
|
||||||
soname="${sofile%%\.so\.*}.so"
|
local soarch=$(LC_ALL=C readelf -h "$fn" | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
|
||||||
# extract the major version: 1
|
|
||||||
soversion="${sofile##*\.so\.}"
|
# extract the library major version
|
||||||
if in_array "${soname}" ${provides[@]}; then
|
local soversion="${sofile##*\.so\.}"
|
||||||
if ! in_array "${soname}=${soversion}-${soarch}" ${libprovides[@]}; then
|
|
||||||
# libfoo.so=1-64
|
libprovides=(${libprovides[@]} "${p}=${soversion}-${soarch}")
|
||||||
echo "${soname}=${soversion}-${soarch}"
|
else
|
||||||
libprovides=(${libprovides[@]} "${soname}=${soversion}-${soarch}")
|
warning "$(gettext "Library listed in %s is not a shared object: %s")" "'provides'" "$p"
|
||||||
fi
|
libprovides=(${libprovides[@]} "$p")
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
else
|
||||||
|
libprovides=(${libprovides[@]} "$p")
|
||||||
|
missing=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
libprovides=(${libprovides[@]} "$p")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if (( missing )); then
|
||||||
|
warning "$(gettext "Can not find library listed in %s: %s")" "'provides'" "$p"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ${libprovides[@]}
|
||||||
}
|
}
|
||||||
|
|
||||||
check_license() {
|
check_license() {
|
||||||
@ -1149,13 +1172,15 @@ write_pkginfo() {
|
|||||||
[[ $groups ]] && printf "group = %s\n" "${groups[@]}"
|
[[ $groups ]] && printf "group = %s\n" "${groups[@]}"
|
||||||
[[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]//+([[:space:]])/ }"
|
[[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]//+([[:space:]])/ }"
|
||||||
[[ $conflicts ]] && printf "conflict = %s\n" "${conflicts[@]}"
|
[[ $conflicts ]] && printf "conflict = %s\n" "${conflicts[@]}"
|
||||||
|
|
||||||
|
provides=($(find_libprovides))
|
||||||
|
[[ $provides ]] && printf "provides = %s\n" "${provides[@]}"
|
||||||
|
|
||||||
[[ $backup ]] && printf "backup = %s\n" "${backup[@]}"
|
[[ $backup ]] && printf "backup = %s\n" "${backup[@]}"
|
||||||
|
|
||||||
local it
|
|
||||||
|
|
||||||
libprovides=$(find_libprovides)
|
local it
|
||||||
libdepends=$(find_libdepends)
|
libdepends=$(find_libdepends)
|
||||||
provides=("${provides[@]}" ${libprovides})
|
|
||||||
depends=("${depends[@]}" ${libdepends})
|
depends=("${depends[@]}" ${libdepends})
|
||||||
|
|
||||||
for it in "${depends[@]}"; do
|
for it in "${depends[@]}"; do
|
||||||
@ -1171,20 +1196,6 @@ write_pkginfo() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for it in "${provides[@]}"; do
|
|
||||||
# ignore versionless entires (those come from the PKGBUILD)
|
|
||||||
if [[ $it = *.so ]]; then
|
|
||||||
# check if the entry has been found by find_libprovides
|
|
||||||
# if not, it's unneeded; tell the user so he can remove it
|
|
||||||
if [[ ! $libprovides =~ (^|\s)${it}=.* ]]; then
|
|
||||||
error "$(gettext "Cannot find library listed in %s: %s")" "'provides'" "$it"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "provides = $it"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
for it in "${packaging_options[@]}"; do
|
for it in "${packaging_options[@]}"; do
|
||||||
local ret="$(check_option $it)"
|
local ret="$(check_option $it)"
|
||||||
if [[ $ret != "?" ]]; then
|
if [[ $ret != "?" ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user