diff options
author | merakor <cem@ckyln.com> | 2021-02-04 09:12:12 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2021-02-04 09:12:12 +0000 |
commit | e7ac846aef7d18c94c2a021d231aa551ba93bdad (patch) | |
tree | 93393c7fe8f83a2f1cdf724bdc8a52fffe625279 | |
parent | 1080f6b06c16f21bd3f47923fb26f36a55b44899 (diff) | |
download | cpt-e7ac846aef7d18c94c2a021d231aa551ba93bdad.tar.gz |
cpt-export: properly fallback to gz
FossilOrigin-Name: 0ab060ec8b5253ee6220fe9778f552a44eb145be5adfe4dc0398b671e6bba1c4
-rwxr-xr-x | contrib/cpt-export | 12 |
1 files changed, 8 insertions, 4 deletions
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" |