From e7ac846aef7d18c94c2a021d231aa551ba93bdad Mon Sep 17 00:00:00 2001 From: merakor Date: Thu, 4 Feb 2021 09:12:12 +0000 Subject: cpt-export: properly fallback to gz FossilOrigin-Name: 0ab060ec8b5253ee6220fe9778f552a44eb145be5adfe4dc0398b671e6bba1c4 --- contrib/cpt-export | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'contrib/cpt-export') diff --git a/contrib/cpt-export b/contrib/cpt-export index 90bc3e0..d0ce36a 100755 --- a/contrib/cpt-export +++ b/contrib/cpt-export @@ -3,7 +3,7 @@ case "$1" in --help|-h) - printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" + printf 'usage: %s [pkg]\n' "${0##*/}" exit 0 ;; '') set -- "${PWD##*/}" @@ -15,9 +15,12 @@ cpt-list "${1:-null}" >/dev/null read -r ver rel 2>/dev/null < \ "$CPT_ROOT/var/db/cpt/installed/$1/version" +# Fallback to gzip if there is a typo +case "$CPT_COMPRESS" in bz2|gz|xz|zst) ;; *) CPT_COMPRESS=gz; esac + # Reset the argument list. pkg=$1 -tarball="$PWD/$1#$ver-$rel.tar.${CPT_COMPRESS:=gz}" +tarball="$PWD/$1#$ver-$rel.tar.$CPT_COMPRESS" set -- # Construct the argument list using each file. @@ -26,12 +29,13 @@ eval set -- "$(sed '/\/$/d;s|^|".|;s|$|"|' \ # Turn the list of files back into a package. cd "$CPT_ROOT/" - tar cf - -- "$@" | case "$CPT_COMPRESS" in +tar cf - -- "$@" | + +case "$CPT_COMPRESS" in bz2) bzip2 -z ;; gz) gzip -6 ;; xz) xz -zT 0 ;; zst) zstd -3 ;; - *) gzip -6 ;; # Fallback to gzip esac > "$tarball" printf 'tarball created in %s\n' "$tarball" -- cgit v1.2.3