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

Florian Pritz bluewind at xinu.at
Sun Dec 25 05:06:38 EST 2011


First off, this patch creates a syntax error.

On 25.12.2011 07:52, Allan McRae wrote:
>  - Only calculates the version for libraries specifically requested
>    and not all libraries. This has the disadvantage of running find
>    over the $pkgdir for as many libraries as needed, but is unlikely
>    to be an issue due to caching.

Maybe you could create a search string like the following? This won't
preserve the order, but it will traverse the file system only once and
according to the find manpage it's POSIX compliant.

find /usr/lib -type f \( -name libx264.so\* -o -name libc.so\* -o -name
libarchive.so\* \)

>  - The order of the provides array in the PKGBUILD is kept in the
>    package
>  - There are more warning messages when things fail and those that
>    were there are no longer errors (as I do not think failure of
>    libprovides should result in complete packaging failure)

I think it should because libraries hardly move between packages or
change their names and the packager might not see the message and push a
package with incorrect provides.

It might be a good idea not to abort right away though. You could check
all entries and abort later, but I think you shouldn't create a package
since the packager will have to fix the incorrect entry and
rebuild/repackage anyway.

>  - It is now modular so can be easy extended to other library types
>    other than ELF *.so.
> 
> Signed-off-by: Allan McRae <allan at archlinux.org>
> ---
>  scripts/makepkg.sh.in |   85 +++++++++++++++++++++++++++----------------------
>  1 files changed, 47 insertions(+), 38 deletions(-)
> 
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 64b33c6..08c4384 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -1076,30 +1076,51 @@ find_libdepends() {
>  }
>  
>  find_libprovides() {
> -	local libprovides
> -	find "$pkgdir" -type f -name \*.so\* | while read filename
> -	do
> -		# 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##*/}"
> +	local libprovides missing
> +	for p in ${provides[@]}; do
> +		missing=0
> +		case "$p" in
> +			*.so)
> +				local filename=$(find "$pkgdir" -type f -name $p\*)
> +				# packages may provide multiple versions of the same library
> +				for fn in ${filename[@]}; do
> +					# check if we really have a shared object
> +					if LC_ALL=C readelf -h "$fn" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
> +						# get the string binaries link to (e.g. libfoo.so.1.2 -> libfoo.so.1)
> +						local sofile=$(LC_ALL=C readelf -d "$fn" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
> +						if [[ -z "$sofile" ]]; then
> +							warning "$(gettext "Library listed in %s is not versioned: %s")" "'provides'" "$p"
> +							libprovides=(${libprovides[@]} "$p")
> +							continue
> +						fi
>  
> -			# extract the library name: libfoo.so
> -			soname="${sofile%%\.so\.*}.so"
> -			# extract the major version: 1
> -			soversion="${sofile##*\.so\.}"
> -			if in_array "${soname}" ${provides[@]}; then
> -				if ! in_array "${soname}=${soversion}-${soarch}" ${libprovides[@]}; then
> -					# libfoo.so=1-64
> -					echo "${soname}=${soversion}-${soarch}"
> -					libprovides=(${libprovides[@]} "${soname}=${soversion}-${soarch}")
> +						# get the library architecture (32 or 64 bit)
> +						local soarch=$(LC_ALL=C readelf -h "$fn" | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
> +
> +						# extract the library major version
> +						local soversion="${sofile##*\.so\.}"
> +
> +						libprovides=(${libprovides[@]} "${p}=${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

This else block doesn't have any matching if statement. The one with
"Library listed in %s is not a shared object" already closes
'if LC_ALL=C readelf -h "$fn" 2>/dev/null | grep -q '.*Type:.*DYN
(Shared object file).*'; then'

-- 
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/20111225/387c007c/attachment.asc>


More information about the pacman-dev mailing list