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

Florian Pritz bluewind at xssn.at
Fri Oct 1 11:30:05 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 |   38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index de24338..f43d87d 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -903,6 +903,28 @@ tidy_install() {
 	fi
 }
 
+find_soprovides() {
+	local soprovides
+	find $pkgdir -type f -name \*.so\* | while read filename
+	do
+    if readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
+			soarch="$(objdump -a "$filename" 2>/dev/null | \
+				sed -rn 's/.* file format elf[0-9]+-(.*)$/\1/p' | tr - _)_$(uname -s)"
+      sofile=$(readelf -d "$filename" 2>/dev/null | sed -nr 's/.*Library soname: \[(.*)\].*/\1/p')
+			[ -z "$sofile" ] && sofile="$(basename "$filename")"
+			
+			soname=$(sed -rn 's/(.*)\.so.*/\1.so/p' <<< "$sofile")
+			soversion=$(sed -rn 's/.*\.so\.(.*)/\1/p' <<< "$sofile")
+			if in_array "${soname}" ${provides[@]}; then
+				if ! in_array "${soname}=${soversion}-${soarch}" ${soprovides[@]}; then
+					echo "${soname}=${soversion}-${soarch}"
+					soprovides=(${soprovides[@]} "${soname}=${soversion}-${soarch}")
+				fi
+			fi
+    fi
+	done
+}
+
 write_pkginfo() {
 	local builddate=$(date -u "+%s")
 	if [[ -n $PACKAGER ]]; then
@@ -938,10 +960,24 @@ write_pkginfo() {
 	[[ $depends ]]    && printf "depend = %s\n"    "${depends[@]}"
 	[[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]}"
 	[[ $conflicts ]]  && printf "conflict = %s\n"  "${conflicts[@]}"
-	[[ $provides ]]   && printf "provides = %s\n"  "${provides[@]}"
 	[[ $backup ]]     && printf "backup = %s\n"    "${backup[@]}"
 
 	local it
+
+	soprovides=$(find_soprovides)
+	provides=("${provides[@]}" ${soprovides})
+
+	for it in "${provides[@]}"; do
+		if grep -q ".*\.so$" <<< "$it"; then
+			if ! grep -q "\(^\|\s\)${it}=.*" <<< $soprovides; then
+				error "$(gettext "Can't find library listed in \$provides: %s")" "$it"
+				return 1
+			fi
+		else
+			echo "provides = $it"
+		fi
+	done
+
 	for it in "${packaging_options[@]}"; do
 		local ret="$(check_option $it)"
 		if [[ $ret != "?" ]]; then
-- 
1.7.3.1


More information about the pacman-dev mailing list