aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-02-04 10:11:35 +0000
committermerakor <cem@ckyln.com>2021-02-04 10:11:35 +0000
commit63c4051197cfcad2231de6eb9874055d668f47df (patch)
tree53d3b3e340570e1dda7d763a5071bafe0ad56543 /contrib
parent37d93c5413b1025c8490b57edf2dea821320d2ca (diff)
parent8d5398a76eda8beec3e7458a1400b9a363afce3d (diff)
downloadcpt-63c4051197cfcad2231de6eb9874055d668f47df.tar.gz
Merge branch 'shellspec'
FossilOrigin-Name: 9f02ac446d6b0e692389a85882df0ff8b2ac54ea40c0f040c5c4dd1713456a21
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/cpt-export22
-rwxr-xr-xcontrib/cpt-new6
2 files changed, 16 insertions, 12 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"
diff --git a/contrib/cpt-new b/contrib/cpt-new
index 00b99c2..b5eac9c 100755
--- a/contrib/cpt-new
+++ b/contrib/cpt-new
@@ -1,10 +1,10 @@
#!/bin/sh -e
# Create a boilerplate CPT package
-out() { printf '\033[1;33m-> \033[m%s\n' "$@" >&2 ;}
+out() { printf '%s\n' "$@" ;}
die() { printf '\033[1;31m!> \033[m%s\n' "$@" >&2 ; exit 1 ;}
-case "$1" in ''|--help|-h) out "usage: ${0##*/} [name] [version] [source]"; exit 0; esac
+case "$1" in ''|--help|-h) out "usage: ${0##*/} [pkg] [version] [source]"; exit 0; esac
[ -d "$1" ] && die "Package '$1' already exists."
@@ -20,4 +20,4 @@ printf '%s\n' "$2 1" > "$1/version"
# Create the sources file
printf '%s\n' "$3" > "$1/sources"
-out "Package '$1' created to '$PWD/$1'"
+out "Package '${1##*/}' created to '$PWD/$1'" >&2