[pacman-dev] [PATCH 2/2] makepkg: add sodepends support

Florian Pritz bluewind at xssn.at
Mon Apr 12 13:47:35 EDT 2010


Support-by: brain0 <thomas at archlinux.org>
Support-by: GNU\caustic <Christoph.Schied at uni-ulm.de>

Signed-off-by: Florian Pritz <bluewind at xssn.at>
---
 scripts/makepkg.sh.in |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 584c427..6e04618 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -869,6 +869,27 @@ tidy_install() {
 	fi
 }
 
+find_sodepends() {
+	local sodepends
+	find $pkgdir -type f | while read filename
+	do
+		soarch="$(objdump -a "$filename" 2>/dev/null | \
+			sed -rn 's/.* file format elf[0-9]+-(.*)$/\1/p' | tr - _)_$(uname -s)"
+		[ -n "$soarch" ] || continue
+		for sofile in $(readelf -d "$filename" 2> /dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p')
+		do
+			soname=$(sed -rn 's/(.*)\.so.*/\1.so/p' <<< "$sofile")
+			soversion=$(sed -rn 's/.*\.so\.(.*)/\1/p' <<< "$sofile")
+			if in_array "${soname}" ${depends[@]}; then
+				if ! in_array "${soname}=${soversion}-${soarch}" ${sodepends[@]}; then
+					echo "${soname}=${soversion}-${soarch}"
+					sodepends=(${sodepends[@]} "${soname}=${soversion}-${soarch}")
+				fi
+			fi
+		done
+	done
+}
+
 find_soprovides() {
 	local soprovides
 	find $pkgdir -type f -name \*.so\* | while read filename
@@ -921,6 +942,8 @@ write_pkginfo() {
 	fi
 
 	soprovides=$(find_soprovides)
+	sodepends=$(find_sodepends)
+	depends=("${depends[@]}" ${sodepends})
 	provides=("${provides[@]}" ${soprovides})
 
 	local it
@@ -934,7 +957,14 @@ write_pkginfo() {
 		echo "group = $it" >>.PKGINFO
 	done
 	for it in "${depends[@]}"; do
-		echo "depend = $it" >>.PKGINFO
+		if grep -q ".*\.so$" <<< "$it"; then
+			if ! grep -q "\(^\|\s\)${it}=.*" <<< $sodepends; then
+				error "$(gettext "Can't find library listed in \$depends: %s")" "$it"
+				return 1
+			fi
+		else
+			echo "depend = $it" >>.PKGINFO
+		fi
 	done
 	for it in "${optdepends[@]}"; do
 		echo "optdepend = $it" >>.PKGINFO
-- 
1.7.0.4


More information about the pacman-dev mailing list