[pacman-dev,v2,1/2] libmakepkg: fix reporting of invalid archive extensions in compress.sh

Message ID 20190312172828.13249-1-eschwartz@archlinux.org
State Accepted, archived
Headers show
Series [pacman-dev,v2,1/2] libmakepkg: fix reporting of invalid archive extensions in compress.sh | expand

Commit Message

Eli Schwartz March 12, 2019, 5:28 p.m. UTC
In commit 1825bd6716c2a51c92642e8b96beac0101e83805 this was split out
from makepkg, but the warning was not properly migrated; $ext did not
ever exist.

As a result, no matter what you did, the only possible warning was:

==> WARNING: '' is not a valid archive extension.

Fix to filter based on the presence of .tar in the argument, and
building the $ext variable for all checking and messaging purposes
within the function.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
---
 scripts/libmakepkg/util/compress.sh.in | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Comments

Allan McRae March 19, 2019, 4:13 a.m. UTC | #1
On 13/3/19 3:28 am, Eli Schwartz wrote:
> In commit 1825bd6716c2a51c92642e8b96beac0101e83805 this was split out
> from makepkg, but the warning was not properly migrated; $ext did not
> ever exist.
> 
> As a result, no matter what you did, the only possible warning was:
> 
> ==> WARNING: '' is not a valid archive extension.
> 
> Fix to filter based on the presence of .tar in the argument, and
> building the $ext variable for all checking and messaging purposes
> within the function.
> 

OK.

A

Patch

diff --git a/scripts/libmakepkg/util/compress.sh.in b/scripts/libmakepkg/util/compress.sh.in
index 3d4d88fd..9e3150f7 100644
--- a/scripts/libmakepkg/util/compress.sh.in
+++ b/scripts/libmakepkg/util/compress.sh.in
@@ -29,21 +29,21 @@  source "$LIBRARY/util/message.sh"
 # 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() {
-       # $1: final archive filename extension for compression type detection
+	# $1: final archive filename extension for compression type detection
 
-	local filename="$1"
+	local ext=".tar${1##*.tar}"
 
-	case "$filename" in
-		*tar.gz)  ${COMPRESSGZ[@]:-gzip -c -f -n} ;;
-		*tar.bz2) ${COMPRESSBZ2[@]:-bzip2 -c -f} ;;
-		*tar.xz)  ${COMPRESSXZ[@]:-xz -c -z -} ;;
-		*tar.zst) ${COMPRESSZST[@]:-zstd -c -z -q -} ;;
-		*tar.lrz) ${COMPRESSLRZ[@]:-lrzip -q} ;;
-		*tar.lzo) ${COMPRESSLZO[@]:-lzop -q} ;;
-		*tar.Z)   ${COMPRESSZ[@]:-compress -c -f} ;;
-		*tar.lz4) ${COMPRESSLZ4[@]:-lz4 -q} ;;
-		*tar.lz)  ${COMPRESSLZ[@]:-lzip -c -f} ;;
-		*tar)     cat ;;
+	case "$ext" in
+		*.tar.gz)  ${COMPRESSGZ[@]:-gzip -c -f -n} ;;
+		*.tar.bz2) ${COMPRESSBZ2[@]:-bzip2 -c -f} ;;
+		*.tar.xz)  ${COMPRESSXZ[@]:-xz -c -z -} ;;
+		*.tar.zst) ${COMPRESSZST[@]:-zstd -c -z -q -} ;;
+		*.tar.lrz) ${COMPRESSLRZ[@]:-lrzip -q} ;;
+		*.tar.lzo) ${COMPRESSLZO[@]:-lzop -q} ;;
+		*.tar.Z)   ${COMPRESSZ[@]:-compress -c -f} ;;
+		*.tar.lz4) ${COMPRESSLZ4[@]:-lz4 -q} ;;
+		*.tar.lz)  ${COMPRESSLZ[@]:-lzip -c -f} ;;
+		*.tar)     cat ;;
 		*) warning "$(gettext "'%s' is not a valid archive extension.")" \
 			"$ext"; cat ;;
 	esac