compress initrds with zstd
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/klauspost/compress/zstd"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
"novit.tech/direktil/pkg/cpiocat"
|
||||
@ -39,7 +40,12 @@ func buildInitrd(out io.Writer, ctx *renderContext) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
cat := cpiocat.New(out)
|
||||
zout, err := zstd.NewWriter(out, zstd.WithEncoderLevel(zstd.EncoderLevelFromZstd(12)))
|
||||
if err != nil {
|
||||
return fmt.Errorf("zstd writer setup failed: %w", err)
|
||||
}
|
||||
|
||||
cat := cpiocat.New(zout)
|
||||
|
||||
// initrd
|
||||
initrdPath, err := distFetch("initrd", ctx.Host.Initrd)
|
||||
@ -88,7 +94,15 @@ func buildInitrd(out io.Writer, ctx *renderContext) (err error) {
|
||||
|
||||
cat.AppendBytes(userCA, "user_ca.pub", 0600)
|
||||
|
||||
return cat.Close()
|
||||
if err = cat.Close(); err != nil {
|
||||
return fmt.Errorf("cpio close failed: %w", err)
|
||||
}
|
||||
|
||||
if err = zout.Close(); err != nil {
|
||||
return fmt.Errorf("zstd close failed: %w", err)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func buildBootstrap(out io.Writer, ctx *renderContext) (err error) {
|
||||
|
Reference in New Issue
Block a user