Skip to content

Commit 099894e

Browse files
committed
Make squashfs defaults more consistent
Signed-off-by: David Cassany <[email protected]>
1 parent 127fa52 commit 099894e

File tree

4 files changed

+7
-17
lines changed

4 files changed

+7
-17
lines changed

pkg/constants/constants.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package constants
1919
import (
2020
"os"
2121
"path/filepath"
22-
"runtime"
2322
)
2423

2524
const (
@@ -265,20 +264,12 @@ func GetCloudInitPaths() []string {
265264
return []string{"/system/oem", "/oem/", "/usr/local/cloud-config/"}
266265
}
267266

268-
// GetDefaultSquashfsOptions returns the default options to use when creating a squashfs
269-
func GetDefaultSquashfsOptions() []string {
270-
return []string{"-b", "1024k"}
267+
func GetSquashfsNoCompressionOptions() []string {
268+
return []string{"-no-compression"}
271269
}
272270

273271
func GetDefaultSquashfsCompressionOptions() []string {
274-
options := []string{"-comp", "xz", "-Xbcj"}
275-
// Set the filter based on arch for best compression results
276-
if runtime.GOARCH == "arm64" {
277-
options = append(options, "arm")
278-
} else {
279-
options = append(options, "x86")
280-
}
281-
return options
272+
return []string{"-b", "1024k"}
282273
}
283274

284275
// GetRunKeyEnvMap returns environment variable bindings to RunConfig data

pkg/elemental/elemental.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,7 @@ func CreateImageFromTree(c types.Config, img *types.Image, rootDir string, prelo
363363
return err
364364
}
365365

366-
squashOptions := append(cnst.GetDefaultSquashfsOptions(), c.SquashFsCompressionConfig...)
367-
err = utils.CreateSquashFS(c.Runner, c.Logger, rootDir, img.File, squashOptions)
366+
err = utils.CreateSquashFS(c.Runner, c.Logger, rootDir, img.File, c.SquashFsCompressionConfig)
368367
if err != nil {
369368
c.Logger.Errorf("failed creating squashfs image for %s: %v", img.File, err)
370369
return err

pkg/types/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (c *Config) Sanitize() error {
147147
// By default on NewConfig the SquashFsCompressionConfig is set to the default values, and then override
148148
// on config unmarshall.
149149
if c.SquashFsNoCompression {
150-
c.SquashFsCompressionConfig = []string{}
150+
c.SquashFsCompressionConfig = constants.GetSquashfsNoCompressionOptions()
151151
}
152152

153153
if c.Arch != "" {

pkg/utils/utils_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,9 +911,9 @@ var _ = Describe("Utils", Label("utils"), func() {
911911
Expect(err).ToNot(HaveOccurred())
912912
})
913913
It("runs with options if given", func() {
914-
err := utils.CreateSquashFS(runner, logger, "source", "dest", constants.GetDefaultSquashfsOptions())
914+
err := utils.CreateSquashFS(runner, logger, "source", "dest", constants.GetDefaultSquashfsCompressionOptions())
915915
cmd := []string{"mksquashfs", "source", "dest"}
916-
cmd = append(cmd, constants.GetDefaultSquashfsOptions()...)
916+
cmd = append(cmd, constants.GetDefaultSquashfsCompressionOptions()...)
917917
Expect(runner.IncludesCmds([][]string{
918918
cmd,
919919
})).To(BeNil())

0 commit comments

Comments
 (0)