aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-04-23 20:53:28 +0000
committermerakor <cem@ckyln.com>2021-04-23 20:53:28 +0000
commit85b402cb08956fb6b434968430b52d16d5b33f1f (patch)
tree3ee469302016ee08c8ba3ccdffed604e9128a6ac /src
parent32fc7163d87f8fd5544cbc97dc8973c68e7fc24a (diff)
downloadcpt-85b402cb08956fb6b434968430b52d16d5b33f1f.tar.gz
pkg_fix_depends: support multilib by resolving fullpath
FossilOrigin-Name: 2aaf44b696b5d66754f9886c20e9f705ae736213c8daa63e55620f239b0a92ef
Diffstat (limited to 'src')
-rw-r--r--src/cpt-lib.in24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/cpt-lib.in b/src/cpt-lib.in
index 5416efe..da84659 100644
--- a/src/cpt-lib.in
+++ b/src/cpt-lib.in
@@ -882,11 +882,19 @@ pkg_strip() {
done 2>/dev/null ||:
}
+pkg_fix_deps_fullpath() {
+ # Return the canonical path of libraries extracted by readelf.
+ while read -r dep _ rslv _; do
+ [ "$dep" = "$1" ] || continue
+ printf '%s\n' "$rslv"
+ done
+}
+
pkg_fix_deps() {
# Dynamically look for missing runtime dependencies by checking each binary
# and library with either 'ldd' or 'readelf'. This catches any extra
# libraries and or dependencies pulled in by the package's build suite.
- log "$1" "Checking for missing dependencies"
+ log "$1" "Checking for missing dependencies (using ${elf_prog##*/})"
# Go to the directory containing the built package to
# simplify path building.
@@ -911,9 +919,15 @@ pkg_fix_deps() {
find "$pkg_dir/$pkg_name/" -type f 2>/dev/null |
while read -r file; do
+ # We call ldd regardless here, because we also use it to retrieve the
+ # fullpath of a library when using readelf. Best use we have here is
+ # saving it in a buffer, so we don't use the dynamic loader everytime we
+ # need to reference it.
+ lddbuf=$(ldd -- "$file" 2>/dev/null) ||:
+
case ${elf_prog:-ldd} in
*readelf) "$elf_prog" -d "$file" 2>/dev/null ;;
- *) ldd "$file" 2>/dev/null ;;
+ *) pirntf '%s\n' "$lddbuf" ;;
esac |
while read -r dep; do
# Skip lines containing 'ldd'.
@@ -925,6 +939,12 @@ pkg_fix_deps() {
dep=${dep##*\[}
dep=${dep%%\]*}
+ # Retrieve the fullpath of the library from our ldd buffer.
+ case $elf_prog in
+ *readelf) line=$(printf '%s\n' "$lddbuf" |
+ pkg_fix_deps_fullpath "$line")
+ esac
+
# ldd output:
# libc.so => /lib/ld-musl-x86_64.so.1
dep=${dep#* => }