From 5d55ccf10921ae5c576653b129106ff2cb61244a Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Tue, 22 Nov 2022 18:37:21 +0100 Subject: [PATCH] manifest: support specifying squashfs compression for ISOs Add support for specifying the squashfs compression method for ISOTree pipelines from the caller. Build Fedora ISOs with lz4 compression and RHEL with xz. --- internal/distro/fedora/images.go | 4 ++++ internal/distro/rhel9/images.go | 4 ++++ internal/image/image_installer.go | 4 ++++ internal/image/ostree_installer.go | 5 +++++ internal/manifest/iso_tree.go | 19 ++++++++++++++++--- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/internal/distro/fedora/images.go b/internal/distro/fedora/images.go index d9bee6474..c811b2d37 100644 --- a/internal/distro/fedora/images.go +++ b/internal/distro/fedora/images.go @@ -224,6 +224,8 @@ func imageInstallerImage(workload workload.Workload, img.Users = users.UsersFromBP(customizations.GetUsers()) img.Groups = users.GroupsFromBP(customizations.GetGroups()) + img.SquashfsCompression = "lz4" + d := t.arch.distro img.ISOLabelTempl = d.isolabelTmpl @@ -323,6 +325,8 @@ func iotInstallerImage(workload workload.Workload, img.Users = users.UsersFromBP(customizations.GetUsers()) img.Groups = users.GroupsFromBP(customizations.GetGroups()) + img.SquashfsCompression = "lz4" + img.ISOLabelTempl = d.isolabelTmpl img.Product = d.product img.Variant = "IoT" diff --git a/internal/distro/rhel9/images.go b/internal/distro/rhel9/images.go index 60b3842d4..5f6d2653f 100644 --- a/internal/distro/rhel9/images.go +++ b/internal/distro/rhel9/images.go @@ -270,6 +270,8 @@ func edgeInstallerImage(workload workload.Workload, img.Users = users.UsersFromBP(customizations.GetUsers()) img.Groups = users.GroupsFromBP(customizations.GetGroups()) + img.SquashfsCompression = "xz" + img.ISOLabelTempl = d.isolabelTmpl img.Product = d.product img.Variant = "edge" @@ -342,6 +344,8 @@ func imageInstallerImage(workload workload.Workload, img.Users = users.UsersFromBP(customizations.GetUsers()) img.Groups = users.GroupsFromBP(customizations.GetGroups()) + img.SquashfsCompression = "xz" + d := t.arch.distro img.ISOLabelTempl = d.isolabelTmpl diff --git a/internal/image/image_installer.go b/internal/image/image_installer.go index 9333c9fb6..cb0243167 100644 --- a/internal/image/image_installer.go +++ b/internal/image/image_installer.go @@ -27,6 +27,8 @@ type ImageInstaller struct { Users []users.User Groups []users.Group + SquashfsCompression string + ISOLabelTempl string Product string Variant string @@ -120,6 +122,8 @@ func (img *ImageInstaller) InstantiateManifest(m *manifest.Manifest, isoTreePipeline.Users = img.Users isoTreePipeline.Groups = img.Groups + isoTreePipeline.SquashfsCompression = img.SquashfsCompression + isoTreePipeline.OSPipeline = osPipeline isoTreePipeline.KernelOpts = img.AdditionalKernelOpts diff --git a/internal/image/ostree_installer.go b/internal/image/ostree_installer.go index d23ae870a..040a06caf 100644 --- a/internal/image/ostree_installer.go +++ b/internal/image/ostree_installer.go @@ -22,6 +22,8 @@ type OSTreeInstaller struct { Users []users.User Groups []users.Group + SquashfsCompression string + ISOLabelTempl string Product string Variant string @@ -101,6 +103,9 @@ func (img *OSTreeInstaller) InstantiateManifest(m *manifest.Manifest, isoTreePipeline.OSName = img.OSName isoTreePipeline.Users = img.Users isoTreePipeline.Groups = img.Groups + + isoTreePipeline.SquashfsCompression = img.SquashfsCompression + isoTreePipeline.KSPath = "/ostree.ks" isoTreePipeline.OSTree = &img.Commit diff --git a/internal/manifest/iso_tree.go b/internal/manifest/iso_tree.go index 7137ffe89..e115f1d4e 100644 --- a/internal/manifest/iso_tree.go +++ b/internal/manifest/iso_tree.go @@ -32,6 +32,8 @@ type ISOTree struct { KSPath string isoLabel string + SquashfsCompression string + OSPipeline *OS OSTree *ostree.CommitSpec @@ -143,10 +145,21 @@ func (p *ISOTree) serialize() osbuild.Pipeline { squashfsOptions := osbuild.SquashfsStageOptions{ Filename: "images/install.img", - Compression: osbuild.FSCompression{ - Method: "lz4", - }, } + + if p.SquashfsCompression != "" { + squashfsOptions.Compression.Method = p.SquashfsCompression + } else { + // default to xz if not specified + squashfsOptions.Compression.Method = "xz" + } + + if squashfsOptions.Compression.Method == "xz" { + squashfsOptions.Compression.Options = &osbuild.FSCompressionOptions{ + BCJ: osbuild.BCJOption(p.anacondaPipeline.platform.GetArch().String()), + } + } + squashfsStage := osbuild.NewSquashfsStage(&squashfsOptions, p.rootfsPipeline.Name()) pipeline.AddStage(squashfsStage)