[pacman-dev] [PATCH] WIP: makepkg: rework libprovides

Florian Pritz bluewind at xinu.at
Thu Jun 16 11:58:28 EDT 2011


On 16.06.2011 10:59, Allan McRae wrote:
> WTF is the comment "# 64" supposed to mean? 

That is an example content of the soarch variable below (someone
requested those once).

> I also would like
> documentation about why we need the [ -z "$sofile" ] test (reminder: needs adjusted
> to double bracket format). 

Shared objects don't have to have a SONAME and I've noticed packages
that contain .so files without that field, for example libreoffice
(/usr/lib/libreoffice/basis3.4/program/libucbhelper4gcc3.so; there are
more).

> Also, why do we extract "soname" when that should be
> what was already given in the provides array?

It was needed before you changed the patch. I think you can remove it
now, but I don't know if it's possible that the soname and the file name
differ.

> +	local libprovides missing
> +	for p in ${provides[@]}; do
> +		missing=0
> +		case "$p" in
> +			*.so)
> +				filename=$(find "$pkgdir" -type f -name $p\*)
> +				if [[ $filename ]]; then

find could return multiple files. For example Maemo's libcurl package
ships libcurl.so.3 and libcurl.so.4. Just use a for loop and get rid of
the [[ $filename ]] check since the loop won't run without files.

> +					# 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
> +						# 64
> +						soarch=$(LC_ALL=C readelf -h "$filename" | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
> +						# get the string binaries link to: libfoo.so.1.2 -> libfoo.so.1
> +						sofile=$(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
> +						[ -z "$sofile" ] && sofile="${$filename##*/}"
> +
> +						# extract the library name: libfoo.so
> +						soname="${sofile%%\.so\.*}.so"
> +						# extract the major version: 1
> +						soversion="${sofile##*\.so\.}"
> +
> +						libprovides=(${libprovides[@]} "${soname}=${soversion}-${soarch}")
> +					else
> +						warning "$(gettext "Library listed in %s is not a shared object: %s")" "'provides'" "$p"
> +						libprovides=(${libprovides[@]} "$p")
> +					fi
> +				else
> +					libprovides=(${libprovides[@]} "$p")
> +					missing=1
>  				fi
> -			fi
> -    fi
> +				;;
> +			*)
> +				libprovides=(${libprovides[@]} "$p")
> +				;;
> +		esac
> +
> +		if (( missing )); then
> +			warning "$(gettext "Can not find library listed in %s: %s")" "'provides'" "$p"
> +		fi
>  	done
> +
> +	echo ${libprovides[@]}
>  }

-- 
Florian Pritz

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/pacman-dev/attachments/20110616/1a6e1b41/attachment.asc>


More information about the pacman-dev mailing list