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

Florian Pritz bluewind at xssn.at
Wed Jan 19 12:13:29 EST 2011


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 |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index cf7dbb9..a851983 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -917,6 +917,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
@@ -969,7 +990,6 @@ write_pkginfo() {
 	[[ $license ]]    && printf "license = %s\n"   "${license[@]}"
 	[[ $replaces ]]   && printf "replaces = %s\n"  "${replaces[@]}"
 	[[ $groups ]]     && printf "group = %s\n"     "${groups[@]}"
-	[[ $depends ]]    && printf "depend = %s\n"    "${depends[@]}"
 	[[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]}"
 	[[ $conflicts ]]  && printf "conflict = %s\n"  "${conflicts[@]}"
 	[[ $backup ]]     && printf "backup = %s\n"    "${backup[@]}"
@@ -977,7 +997,20 @@ write_pkginfo() {
 	local it
 
 	soprovides=$(find_soprovides)
+	sodepends=$(find_sodepends)
 	provides=("${provides[@]}" ${soprovides})
+	depends=("${depends[@]}" ${sodepends})
+
+	for it in "${depends[@]}"; do
+		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"
+		fi
+	done
 
 	for it in "${provides[@]}"; do
 		if grep -q ".*\.so$" <<< "$it"; then
-- 
1.7.3.5


More information about the pacman-dev mailing list