mirror of
https://github.com/outbackdingo/debos.git
synced 2026-01-27 10:18:47 +00:00
actions: pack/unpack: Add support for zstd compression
Debian Bookworm includes a version of tar with native support for Zstandard compression. Add mapping to enable zstd in pack and unpack operations. Signed-off-by: Julien Massot <julien.massot@collabora.com>
This commit is contained in:
@@ -14,7 +14,7 @@ Mandatory properties:
|
||||
|
||||
Optional properties:
|
||||
|
||||
- compression -- compression type to use. Currently only 'gz', 'bzip2' and 'xz'
|
||||
- compression -- compression type to use. Currently only 'gz', 'bzip2', 'xz' and 'zstd'.
|
||||
compression types are supported. Use 'none' for uncompressed tarball. The 'gz'
|
||||
compression type will be used by default.
|
||||
|
||||
@@ -32,9 +32,10 @@ import (
|
||||
)
|
||||
|
||||
var tarOpts = map[string]string{
|
||||
"gz": "z",
|
||||
"bzip2": "j",
|
||||
"xz": "J",
|
||||
"gz": "--gzip",
|
||||
"bzip2": "--bzip2",
|
||||
"xz": "--xz",
|
||||
"zstd": "--zstd",
|
||||
"none": "",
|
||||
}
|
||||
|
||||
@@ -77,16 +78,14 @@ func (pf *PackAction) Run(context *debos.DebosContext) error {
|
||||
outfile := path.Join(context.Artifactdir, pf.File)
|
||||
|
||||
command := []string{"tar"}
|
||||
if usePigz == true {
|
||||
command = append(command, "cf")
|
||||
} else {
|
||||
command = append(command, "cf" + tarOpts[pf.Compression])
|
||||
}
|
||||
command = append(command, "cf")
|
||||
command = append(command, outfile)
|
||||
command = append(command, "--xattrs")
|
||||
command = append(command, "--xattrs-include=*.*")
|
||||
if usePigz == true {
|
||||
command = append(command, "--use-compress-program=pigz")
|
||||
} else if tarOpts[pf.Compression] != "" {
|
||||
command = append(command, tarOpts[pf.Compression])
|
||||
}
|
||||
command = append(command, "-C", context.Rootdir)
|
||||
command = append(command, ".")
|
||||
|
||||
@@ -86,6 +86,7 @@ func tarOptions(compression string) string {
|
||||
"gz": "-z",
|
||||
"bzip2": "-j",
|
||||
"xz": "-J",
|
||||
"zstd": "--zstd",
|
||||
} // Trying to guess all other supported compression types
|
||||
|
||||
return unpackTarOpts[compression]
|
||||
|
||||
Reference in New Issue
Block a user