diff options
Diffstat (limited to 'contrib/cpt-export')
-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" |