[pacman-dev] [PATCH 2/2] makepkg: test for appropriate file suffixes when extracting sources

Xavier shiningxc at gmail.com
Wed Aug 5 10:30:57 EDT 2009


On Wed, Aug 5, 2009 at 4:12 PM, Cedric Staniewski<cedric at gmx.ca> wrote:
> The selection of the decompression command for gzip/bzip2/xz
> compressed files now also depends on the file suffix, since the
> decompression programs rely on them when not using -c option.
>
> Signed-off-by: Cedric Staniewski <cedric at gmx.ca>
> ---
>  scripts/makepkg.sh.in |   13 ++++++++++---
>  1 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 2f1db38..702e4c1 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -641,16 +641,23 @@ extract_sources() {
>
>                # fix flyspray #6246
>                local file_type=$(file -bizL "$file")
> +               local ext=${file##*.}
>                local cmd=''
>                case "$file_type" in
>                        *application/x-tar*|*application/zip*|*application/x-zip*|*application/x-cpio*)
>                                cmd="bsdtar -x -f '$file'" ;;
>                        *application/x-gzip*)
> -                               cmd="gunzip -c -f '$file' > '${file%.*}'" ;;
> +                               [ "$ext" = "gz" -o "$ext" = "z" -o "$ext" = "Z" ] \
> +                                       && cmd="gunzip -cf '$file' > '${file%.*}'" \
> +                                       || continue ;;
>                        *application/x-bzip*)
> -                               cmd="bunzip2 -f -k '$file'" ;;
> +                               [ "$ext" = "bz2" -o "$ext" = "bz" ] \
> +                                       && cmd="bunzip2 -fk '$file'" \
> +                                       || continue ;;
>                        *application/x-xz*)
> -                               cmd="xz -d -f -k '$file'" ;;
> +                               [ "$ext" = "xz" ] \
> +                                       && cmd="xz -dfk '$file'" \
> +                                       || continue ;;
>                        *)
>                                # Don't know what to use to extract this file,
>                                # skip to the next file
> --
> 1.6.4
>

an example of a compressed file with a different extension which came
to my mind :
http://en.wikipedia.org/wiki/PK3_%28file_extension%29

So without this patch, makepkg would just error out, unless we put the
file in noextract
With this patch, it is just skipped.

This situation is probably quite rare, but I am totally fine with this patch.


More information about the pacman-dev mailing list