[pacman-dev] [PATCH 1/3] makepkg: refactor archive compression for reusability

Allan McRae allan at archlinux.org
Thu Sep 14 06:27:36 UTC 2017


On 29/08/17 15:01, Eli Schwartz wrote:
> This allows for more easily extending the list of allowed compression
> methods, as it has to be modified in only one place.
> 
> Also allow the user to specify their own preferred command + options for
> source packages in addition to compiled packages. Currently,
> makepkg.conf(5) erroneously claims this is already possible.
> 
> Signed-off-by: Eli Schwartz <eschwartz at archlinux.org>
> ---
> 
> I'm not 100% sure how to handle this, perhaps it should encompass
> bsdtar/$pkg_file as well?
> 
>  scripts/makepkg.sh.in | 57 ++++++++++++++++++++++++++-------------------------
>  1 file changed, 29 insertions(+), 28 deletions(-)
> 
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 20e9dd7e..a5c216dd 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -698,6 +698,26 @@ list_package_files() {
>  	sed -e 's|^\./||' | tr '\n' '\0'
>  }
> 
> +# Wrapper around many stream compression formats, for use in the middle of a
> +# pipeline. A tar archive is passed on stdin and compressed to stdout.
> +compress_as() {

This should really make its way to libmakepkg in util/compress.sh.

I have also internal debated the name for a while.  compress_as() vs
compress_to() vs compress().  I was slightly leaning to the last one...

> +	# $1: final archive filename extension for compression type detection
> +
> +	local ext="$1"
> +
> +	case "$ext" in
> +		*tar.gz)  ${COMPRESSGZ[@]:-gzip -c -f -n} ;;
> +		*tar.bz2) ${COMPRESSBZ2[@]:-bzip2 -c -f} ;;
> +		*tar.xz)  ${COMPRESSXZ[@]:-xz -c -z -} ;;
> +		*tar.lrz) ${COMPRESSLRZ[@]:-lrzip -q} ;;
> +		*tar.lzo) ${COMPRESSLZO[@]:-lzop -q} ;;
> +		*tar.Z)   ${COMPRESSZ[@]:-compress -c -f} ;;

Aside: we need to do something about all these COMPRESSFOO variables...
Adding a new one to our example makepkg.conf with each new addition is
not ideal.  Perhaps we can just document them in the man page but no
have default entries in makepkg.conf?   Or is there a better way?

> +		*tar)     cat ;;
> +		*) warning "$(gettext "'%s' is not a valid archive extension.")" \
> +			"$ext"; cat ;;
> +	esac
> +}
> +


More information about the pacman-dev mailing list