From 65d72951782ae4c5143b3fbe1bf9a9c7238f775f Mon Sep 17 00:00:00 2001 From: merakor Date: Tue, 10 Aug 2021 23:19:10 +0000 Subject: compress: add new function FossilOrigin-Name: 5f62704fdc9a04856c8ef5f764e8c2da6fd87082c94a673365ecf1cc728c1071 --- src/cpt-lib.in | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/cpt-lib.in b/src/cpt-lib.in index abf5bdf..58c9a0f 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -570,6 +570,18 @@ run_hook() { CPT_HOOK=$oldCPT_HOOK } +# An optional argument could be provided to enforce a compression algorithm. +# shellcheck disable=2120 +compress() { + case ${1:-$CPT_COMPRESS} in + bz2) bzip2 -z ;; + gz) gzip -6 ;; + xz) xz -zT 0 ;; + zst) zstd -3 ;; + lz) lzip -6 ;; + esac +} + decompress() { case $1 in *.tar|*.cpio) cat ;; @@ -1055,19 +1067,8 @@ pkg_tar() { # Create a tarball from the contents of the built package. cd "$pkg_dir/$1" - pax -w . | - case $CPT_COMPRESS in - bz2) bzip2 -z ;; - xz) xz -zT 0 ;; - gz) gzip -6 ;; - zst) zstd -3 ;; - lz) lzip -6 ;; - *) gzip -6 ;; # Fallback to gzip - esac \ - > "$bin_dir/$1#$version-$release.tar.$CPT_COMPRESS" - + pax -w . | compress > "$bin_dir/$1#$version-$release.tar.$CPT_COMPRESS" log "$1" "Successfully created tarball" - run_hook post-package "$1" "$bin_dir/$1#$version-$release.tar.$CPT_COMPRESS" } -- cgit v1.2.3