From 91e86fb1b0cf1e2948429f17ccba9a0c509ccbc5 Mon Sep 17 00:00:00 2001 From: rektide de la faye Date: Mon, 21 Feb 2022 20:27:30 -0500 Subject: [PATCH 1/2] add auto/zstd/lzop/lzma/lzip compression options to pack action. --- actions/pack_action.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/actions/pack_action.go b/actions/pack_action.go index b85f3188..c003014b 100644 --- a/actions/pack_action.go +++ b/actions/pack_action.go @@ -14,9 +14,9 @@ Mandatory properties: Optional properties: -- compression -- compression type to use. Currently only 'gz', 'bzip2' and 'xz' -compression types are supported. Use 'none' for uncompressed tarball. The 'gz' -compression type will be used by default. +- compression -- compression type to use. Currently 'gz', 'bzip2', 'lzip', lzma', 'lzop', 'xz', 'zstd' compression types +are supported. Use 'none' for uncompressed tarball. Use 'auto' to pick via file extension. The 'gz' compression type will +be used by default. */ package actions @@ -31,9 +31,14 @@ import ( ) var tarOpts = map[string]string{ - "gz": "z", - "bzip2": "j", - "xz": "J", + "bzip2": "--bzip2", + "gz": "--gzip", + "lzop": "--lzop", + "lzma": "--lzma", + "lzip", "--lzip", + "xz": "--xz", + "zstd": "--zstd", + "auto", "--auto-compress", "none": "", } @@ -70,9 +75,9 @@ func (pf *PackAction) Run(context *debos.DebosContext) error { pf.LogStart() outfile := path.Join(context.Artifactdir, pf.File) - var tarOpt = "cf" + tarOpts[pf.Compression] + var compressOpt = tarOpts[pf.Compression] log.Printf("Compressing to %s\n", outfile) - return debos.Command{}.Run("Packing", "tar", tarOpt, outfile, + return debos.Command{}.Run("Packing", "tar", "cf", compressOpt outfile, "--xattrs", "--xattrs-include=*.*", "-C", context.Rootdir, ".") } From 49a5891d71fba18b2e7b248534a57c5c18500820 Mon Sep 17 00:00:00 2001 From: rektide de la faye Date: Mon, 21 Feb 2022 20:29:56 -0500 Subject: [PATCH 2/2] add lzop/zlma/lzip/zstd unpack compress options. --- actions/unpack_action.go | 2 +- archiver.go | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/actions/unpack_action.go b/actions/unpack_action.go index d4993b14..04123b9c 100644 --- a/actions/unpack_action.go +++ b/actions/unpack_action.go @@ -27,7 +27,7 @@ The default value is 'artifacts' directory in case if this property is omitted. - compression -- optional hint for unpack allowing to use proper compression method. -Currently only 'gz', bzip2' and 'xz' compression types are supported. +Currently 'gz', bzip2', 'xz', "zstd", "lzop", "lzma", "lzip" compression types are supported. If not provided an attempt to autodetect the compression type will be done. */ package actions diff --git a/archiver.go b/archiver.go index c54f89c0..34c315c8 100644 --- a/archiver.go +++ b/archiver.go @@ -82,9 +82,13 @@ func unpack(command []string, destination string) error { // Returns empty string for unknown func tarOptions(compression string) string { unpackTarOpts := map[string]string{ - "gz": "-z", - "bzip2": "-j", - "xz": "-J", + "bzip2": "--bzip2", + "gz": "--gzip", + "lzop": "--lzop", + "lzma": "--lzma", + "lzip", "--lzip", + "xz": "--xz", + "zstd": "--zstd", } // Trying to guess all other supported compression types return unpackTarOpts[compression]