archive: support using lzma (MR 25)
fixes: https://gitlab.com/postmarketOS/postmarketos-mkinitfs/-/issues/2
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
|
||||
"github.com/cavaliercoder/go-cpio"
|
||||
"github.com/klauspost/compress/zstd"
|
||||
"github.com/ulikunitz/xz"
|
||||
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/filelist"
|
||||
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/osutil"
|
||||
)
|
||||
@@ -26,6 +27,7 @@ type CompressFormat string
|
||||
|
||||
const (
|
||||
FormatGzip CompressFormat = "gzip"
|
||||
FormatLzma CompressFormat = "lzma"
|
||||
FormatZstd CompressFormat = "zstd"
|
||||
)
|
||||
|
||||
@@ -98,6 +100,9 @@ func ExtractFormatLevel(s string) (format CompressFormat, level CompressLevel) {
|
||||
|
||||
switch format {
|
||||
case FormatGzip:
|
||||
case FormatLzma:
|
||||
log.Println("Format lzma doesn't support a compression level, using default settings")
|
||||
level = LevelDefault
|
||||
case FormatZstd:
|
||||
default:
|
||||
log.Print("Unknown or no compression format set, using gzip")
|
||||
@@ -295,6 +300,11 @@ func (archive *Archive) writeCompressed(path string, mode os.FileMode) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case FormatLzma:
|
||||
compressor, err = xz.NewWriter(fd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case FormatZstd:
|
||||
level := zstd.SpeedDefault
|
||||
switch archive.compress_level {
|
||||
|
Reference in New Issue
Block a user