From c3a84adda049e53d9ea94507bf05e695e1575def Mon Sep 17 00:00:00 2001 From: merakor Date: Mon, 11 Jan 2021 17:32:01 +0000 Subject: cpt-export: change directory in a subshell FossilOrigin-Name: 063411c0c7d0323b39f8d915486cda56ab77155d89c764870018ace267630445 --- contrib/cpt-export | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'contrib/cpt-export') diff --git a/contrib/cpt-export b/contrib/cpt-export index 9b4edd1..87ba2da 100755 --- a/contrib/cpt-export +++ b/contrib/cpt-export @@ -25,8 +25,10 @@ while read -r file; do done < "$CPT_ROOT/var/db/cpt/installed/$pkg/manifest" # Turn the list of files back into a package. -: "${CPT_COMPRESS:=gz}" -tar cf - -C / -- "$@" | case "$CPT_COMPRESS" in +(cd "$CPT_ROOT/" + tar cf - -- "$@" || exit 1) | + +case "$CPT_COMPRESS" in bz2) bzip2 -z ;; gz) gzip -6 ;; xz) xz -zT 0 ;; -- cgit v1.2.3 From e76ede06d13bb8369ab57168ea5da2fd0054d42d Mon Sep 17 00:00:00 2001 From: merakor Date: Mon, 11 Jan 2021 17:34:15 +0000 Subject: cpt-export: simplify tar usage FossilOrigin-Name: a983ef58192f4474e7e6718bd3372eb0c7f2027195eda17f22dbb58f7c519a55 --- contrib/cpt-export | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'contrib/cpt-export') diff --git a/contrib/cpt-export b/contrib/cpt-export index 87ba2da..5429c08 100755 --- a/contrib/cpt-export +++ b/contrib/cpt-export @@ -17,6 +17,7 @@ read -r ver rel 2>/dev/null < \ # Reset the argument list. pkg=$1 +tarball="$PWD/$1#$ver-$rel.tar.${CPT_COMPRESS:=gz}" set -- # Construct the argument list using each file. @@ -25,15 +26,12 @@ while read -r file; do done < "$CPT_ROOT/var/db/cpt/installed/$pkg/manifest" # Turn the list of files back into a package. -(cd "$CPT_ROOT/" - tar cf - -- "$@" || exit 1) | - -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 > "$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" -- cgit v1.2.3 From f72d7864674b7f9e25541354ad1f0779e3ce27ef Mon Sep 17 00:00:00 2001 From: merakor Date: Mon, 11 Jan 2021 17:36:33 +0000 Subject: cpt-export: use sed to generate manifest Testing the boost package, using sed results in a significant reduction for argument generation instead of using the 'read' function. Below are the 'time' stats for the script. Previous: real 0m 58.95s user 0m 55.80s sys 0m 3.54s Current: real 0m 0.66s user 0m 0.78s sys 0m 0.27s FossilOrigin-Name: 80d891e830579822317d30b66b1b019828fca9343ada23ce17585622288deef3 --- contrib/cpt-export | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'contrib/cpt-export') diff --git a/contrib/cpt-export b/contrib/cpt-export index 5429c08..90bc3e0 100755 --- a/contrib/cpt-export +++ b/contrib/cpt-export @@ -21,11 +21,11 @@ tarball="$PWD/$1#$ver-$rel.tar.${CPT_COMPRESS:=gz}" 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. +cd "$CPT_ROOT/" tar cf - -- "$@" | case "$CPT_COMPRESS" in bz2) bzip2 -z ;; gz) gzip -6 ;; -- cgit v1.2.3 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