Add -k (keep) option to the bunzip2/xz commands and make gunzip decompressing to stdout, because it does not offer something like a -k option. Additionally 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@gmx.ca> --- scripts/makepkg.sh.in | 33 +++++++++++++++++++++------------ 1 files changed, 21 insertions(+), 12 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 9141e1c..10a99f0 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -644,22 +644,31 @@ extract_sources() { local cmd='' case "$file_type" in application/x-tar|application/zip|application/x-zip|application/x-cpio) - cmd="bsdtar -x -f" ;; - application/x-gzip) - cmd="gunzip -d -f" ;; - application/x-bzip) - cmd="bunzip2 -f" ;; - application/x-xz) - cmd="xz -d -f" ;; + cmd="bsdtar xf '$file'" ;; *) - # Don't know what to use to extract this file, - # skip to the next file - continue;; + case "$file" in + *.gz|*.z|*.Z) + [ "$file_type" = "application/x-gzip" ] \ + && cmd="gunzip -cf '$file' > '${file%.*}'" + ;; + *.bz2|*.bz) + [ "$file_type" = "application/x-bzip" ] \ + && cmd="bunzip2 -fk '$file'" + ;; + *.xz) + [ "$file_type" = "application/x-xz" ] \ + && cmd="xz -dfk '$file'" + ;; + *) + # Don't know what to use to extract this file, + # skip to the next file + continue ;; + esac esac local ret=0 - msg2 '%s' "$cmd \"$file\"" - $cmd "$file" || ret=$? + msg2 '%s' "$cmd" + $cmd || ret=$? if [ $ret -ne 0 ]; then error "$(gettext "Failed to extract %s")" "$file" plain "$(gettext "Aborting...")" -- 1.6.4