Skip to content

Commit

Permalink
Merge #282 #310
Browse files Browse the repository at this point in the history
282: actions: overlay: Log using action log functions r=obbardc a=obbardc

Currently the overlay action prints directly to stdout, which
ends up not following the standard output format the other
actions follow. Let's clean this up by using the action's
existing logging functions rather than printing directly
to stdout.

Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>

310: More compress options r=obbardc a=rektide

Add `zstd`, `lzop`, `lzma`, `lzip` options. Add `auto` for pack.

Co-authored-by: Christopher Obbard <chris.obbard@collabora.com>
Co-authored-by: rektide de la faye <rektide@voodoowarez.com>
  • Loading branch information
3 people authored Oct 12, 2022
3 parents b6c41ca + b40722f + 49a5891 commit f7726b1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
2 changes: 2 additions & 0 deletions actions/overlay_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package actions

import (
"fmt"
"log"
"path"

"github.com/go-debos/debos"
Expand Down Expand Up @@ -63,5 +64,6 @@ func (overlay *OverlayAction) Run(context *debos.DebosContext) error {
return err
}

log.Printf("Overlaying %s on %s", sourcedir, destination)
return debos.CopyTree(sourcedir, destination)
}
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",
"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,
"--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",
"lzma": "--lzma",
"lzip", "--lzip",
"xz": "--xz",
"zstd": "--zstd",
} // Trying to guess all other supported compression types

return unpackTarOpts[compression]
Expand Down
1 change: 0 additions & 1 deletion filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func CopyFile(src, dst string, mode os.FileMode) error {
}

func CopyTree(sourcetree, desttree string) error {
fmt.Printf("Overlaying %s on %s\n", sourcetree, desttree)
walker := func(p string, info os.FileInfo, err error) error {

if err != nil {
Expand Down

0 comments on commit f7726b1

Please sign in to comment.