diff options
author | merakor <cem@ckyln.com> | 2021-02-04 10:11:35 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2021-02-04 10:11:35 +0000 |
commit | 63c4051197cfcad2231de6eb9874055d668f47df (patch) | |
tree | 53d3b3e340570e1dda7d763a5071bafe0ad56543 /contrib/cpt-export | |
parent | 37d93c5413b1025c8490b57edf2dea821320d2ca (diff) | |
parent | 8d5398a76eda8beec3e7458a1400b9a363afce3d (diff) | |
download | cpt-63c4051197cfcad2231de6eb9874055d668f47df.tar.gz |
Merge branch 'shellspec'
FossilOrigin-Name: 9f02ac446d6b0e692389a85882df0ff8b2ac54ea40c0f040c5c4dd1713456a21
Diffstat (limited to 'contrib/cpt-export')
-rwxr-xr-x | contrib/cpt-export | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/contrib/cpt-export b/contrib/cpt-export index 9b4edd1..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,23 +15,27 @@ 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" set -- # Construct the argument list using each file. -while read -r file; do - [ -d "$CPT_ROOT/$file" ] || set -- "$@" ".$file" -done < "$CPT_ROOT/var/db/cpt/installed/$pkg/manifest" +eval set -- "$(sed '/\/$/d;s|^|".|;s|$|"|' \ + "$CPT_ROOT/var/db/cpt/installed/$pkg/manifest" | tr '\n' ' ')" # Turn the list of files back into a package. -: "${CPT_COMPRESS:=gz}" -tar cf - -C / -- "$@" | case "$CPT_COMPRESS" in +cd "$CPT_ROOT/" +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 > "$pkg#$ver-$rel.tar.$CPT_COMPRESS" +esac > "$tarball" -printf 'tarball created in %s\n' "$PWD/$pkg#$ver-$rel.tar.$CPT_COMPRESS" +printf 'tarball created in %s\n' "$tarball" |