Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More compress options #310

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions actions/pack_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,9 +31,14 @@ import (
)

var tarOpts = map[string]string{
"gz": "z",
"bzip2": "j",
"xz": "J",
"bzip2": "--bzip2",
obbardc marked this conversation as resolved.
Show resolved Hide resolved
"gz": "--gzip",
"lzop": "--lzop",
"lzma": "--lzma",
"lzip", "--lzip",
"xz": "--xz",
"zstd": "--zstd",
"auto", "--auto-compress",
"none": "",
}

Expand Down Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: no comma between arguments

"--xattrs", "--xattrs-include=*.*",
"-C", context.Rootdir, ".")
}
2 changes: 1 addition & 1 deletion actions/unpack_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
obbardc marked this conversation as resolved.
Show resolved Hide resolved
"lzma": "--lzma",
"lzip", "--lzip",
"xz": "--xz",
"zstd": "--zstd",
} // Trying to guess all other supported compression types

return unpackTarOpts[compression]
Expand Down