Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use plain squashfs as the iso rootfs #1105

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions pkg/distro/distro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func listTestedDistros(t *testing.T) []string {
// needed for knowing the names of pipelines from the static object without
// having access to a manifest, which we need when parsing metadata from build
// results.
// NOTE: The static list of pipelines really only needs to include those that
// have rpm or ostree metadata in them.
func TestImageTypePipelineNames(t *testing.T) {
// types for parsing the opaque manifest with just the fields we care about
type rpmStageOptions struct {
Expand All @@ -53,16 +55,16 @@ func TestImageTypePipelineNames(t *testing.T) {
Pipelines []pipeline `json:"pipelines"`
}

assert := assert.New(t)
distroFactory := distrofactory.NewDefault()
distros := listTestedDistros(t)
for _, distroName := range distros {
d := distroFactory.GetDistro(distroName)
for _, archName := range d.ListArches() {
arch, err := d.GetArch(archName)
assert.Nil(err)
assert.Nil(t, err)
for _, imageTypeName := range arch.ListImageTypes() {
t.Run(fmt.Sprintf("%s/%s/%s", distroName, archName, imageTypeName), func(t *testing.T) {
assert := assert.New(t)
imageType, err := arch.GetImageType(imageTypeName)
assert.Nil(err)

Expand Down Expand Up @@ -138,11 +140,10 @@ func TestImageTypePipelineNames(t *testing.T) {
err = json.Unmarshal(mf, pm)
assert.NoError(err)

assert.Equal(len(allPipelines), len(pm.Pipelines))
var pmNames []string
for idx := range pm.Pipelines {
// manifest pipeline names should be identical to the ones
// defined in the image type and in the same order
assert.Equal(allPipelines[idx], pm.Pipelines[idx].Name)
// Gather the names of the manifest piplines for later
pmNames = append(pmNames, pm.Pipelines[idx].Name)

if pm.Pipelines[idx].Name == "os" {
rpmStagePresent := false
Expand Down Expand Up @@ -171,6 +172,15 @@ func TestImageTypePipelineNames(t *testing.T) {
// sure they match.
assert.Equal(imageType.Exports()[0], pm.Pipelines[len(pm.Pipelines)-1].Name)

// The pipelines named in allPipelines must exist in the manifest, and in the
// order specified (eg. 'build' first) but it does not need to be an exact
// match. Only the pipelines with rpm or ostree metadata are required.
bcl marked this conversation as resolved.
Show resolved Hide resolved
var order int
for _, name := range allPipelines {
idx := slices.Index(pmNames, name)
assert.True(idx >= order, "%s not in order %v", name, pmNames)
order = idx
}
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/distro/fedora/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ var (
// We don't know the variant of the OS pipeline being installed
isoLabel: getISOLabelFunc("Unknown"),
buildPipelines: []string{"build"},
payloadPipelines: []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "os", "bootiso-tree", "bootiso"},
payloadPipelines: []string{"anaconda-tree", "efiboot-tree", "os", "bootiso-tree", "bootiso"},
exports: []string{"bootiso"},
requiredPartitionSizes: requiredDirectorySizes,
}
Expand All @@ -119,7 +119,7 @@ var (
image: liveInstallerImage,
isoLabel: getISOLabelFunc("Workstation"),
buildPipelines: []string{"build"},
payloadPipelines: []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "bootiso-tree", "bootiso"},
payloadPipelines: []string{"anaconda-tree", "efiboot-tree", "bootiso-tree", "bootiso"},
exports: []string{"bootiso"},
requiredPartitionSizes: requiredDirectorySizes,
}
Expand Down Expand Up @@ -200,7 +200,7 @@ var (
image: iotInstallerImage,
isoLabel: getISOLabelFunc("IoT"),
buildPipelines: []string{"build"},
payloadPipelines: []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "bootiso-tree", "bootiso"},
payloadPipelines: []string{"anaconda-tree", "efiboot-tree", "bootiso-tree", "bootiso"},
exports: []string{"bootiso"},
requiredPartitionSizes: requiredDirectorySizes,
}
Expand Down
18 changes: 14 additions & 4 deletions pkg/distro/fedora/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ func liveInstallerImage(workload workload.Workload,

img.Filename = t.Filename()

if common.VersionGreaterThanOrEqual(img.OSVersion, VERSION_ROOTFS_SQUASHFS) {
img.RootfsType = manifest.SquashfsRootfs
}

return img, nil
}

Expand Down Expand Up @@ -456,8 +460,6 @@ func imageInstallerImage(workload workload.Workload,

img.ExtraBasePackages = packageSets[installerPkgsKey]

img.SquashfsCompression = "lz4"

d := t.arch.distro

img.Product = d.product
Expand All @@ -477,6 +479,11 @@ func imageInstallerImage(workload workload.Workload,

img.Filename = t.Filename()

img.SquashfsCompression = "lz4"
if common.VersionGreaterThanOrEqual(img.OSVersion, VERSION_ROOTFS_SQUASHFS) {
img.RootfsType = manifest.SquashfsRootfs
}

return img, nil
}

Expand Down Expand Up @@ -660,8 +667,6 @@ func iotInstallerImage(workload workload.Workload,
anaconda.ModuleUsers,
}...)

img.SquashfsCompression = "lz4"

img.Product = d.product
img.Variant = "IoT"
img.OSVersion = d.osVersion
Expand All @@ -675,6 +680,11 @@ func iotInstallerImage(workload workload.Workload,

img.Filename = t.Filename()

img.SquashfsCompression = "lz4"
if common.VersionGreaterThanOrEqual(img.OSVersion, VERSION_ROOTFS_SQUASHFS) {
bcl marked this conversation as resolved.
Show resolved Hide resolved
img.RootfsType = manifest.SquashfsRootfs
}

return img, nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/distro/fedora/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ package fedora

const VERSION_BRANCHED = "42"
const VERSION_RAWHIDE = "42"

// Fedora version 41 and later use a plain squashfs rootfs on the iso instead of
// compressing an ext4 filesystem.
const VERSION_ROOTFS_SQUASHFS = "41"
6 changes: 6 additions & 0 deletions pkg/distro/rhel/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ func EdgeInstallerImage(workload workload.Workload,
img.Kickstart.Timezone, _ = customizations.GetTimezoneSettings()

img.SquashfsCompression = "xz"
if t.Arch().Distro().Releasever() == "10" {
img.RootfsType = manifest.SquashfsRootfs
}

installerConfig, err := t.getDefaultInstallerConfig()
if err != nil {
Expand Down Expand Up @@ -714,6 +717,9 @@ func ImageInstallerImage(workload workload.Workload,
img.AdditionalAnacondaModules = append(img.AdditionalAnacondaModules, anaconda.ModuleUsers)

img.SquashfsCompression = "xz"
if t.Arch().Distro().Releasever() == "10" {
img.RootfsType = manifest.SquashfsRootfs
}

// put the kickstart file in the root of the iso
img.ISORootKickstart = true
Expand Down
2 changes: 1 addition & 1 deletion pkg/distro/rhel/rhel10/bare_metal.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func mkImageInstallerImgType() *rhel.ImageType {
},
rhel.ImageInstallerImage,
[]string{"build"},
[]string{"anaconda-tree", "rootfs-image", "efiboot-tree", "os", "bootiso-tree", "bootiso"},
[]string{"anaconda-tree", "efiboot-tree", "os", "bootiso-tree", "bootiso"},
[]string{"bootiso"},
)

Expand Down
10 changes: 8 additions & 2 deletions pkg/image/anaconda_container_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type AnacondaContainerInstaller struct {
ExtraBasePackages rpmmd.PackageSet

SquashfsCompression string
RootfsType manifest.RootfsType

ISOLabel string
Product string
Expand Down Expand Up @@ -98,8 +99,13 @@ func (img *AnacondaContainerInstaller) InstantiateManifest(m *manifest.Manifest,
}
anacondaPipeline.AdditionalDrivers = img.AdditionalDrivers

rootfsImagePipeline := manifest.NewISORootfsImg(buildPipeline, anacondaPipeline)
rootfsImagePipeline.Size = 4 * datasizes.GibiByte
var rootfsImagePipeline *manifest.ISORootfsImg
switch img.RootfsType {
case manifest.SquashfsExt4Rootfs:
rootfsImagePipeline = manifest.NewISORootfsImg(buildPipeline, anacondaPipeline)
rootfsImagePipeline.Size = 4 * datasizes.GibiByte
default:
}

bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.Product, img.OSVersion)
bootTreePipeline.Platform = img.Platform
Expand Down
14 changes: 12 additions & 2 deletions pkg/image/anaconda_live_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ type AnacondaLiveInstaller struct {

ExtraBasePackages rpmmd.PackageSet

SquashfsCompression string
RootfsType manifest.RootfsType

ISOLabel string
Product string
Variant string
Expand Down Expand Up @@ -70,8 +73,13 @@ func (img *AnacondaLiveInstaller) InstantiateManifest(m *manifest.Manifest,

livePipeline.Checkpoint()

rootfsImagePipeline := manifest.NewISORootfsImg(buildPipeline, livePipeline)
rootfsImagePipeline.Size = 8 * datasizes.GibiByte
var rootfsImagePipeline *manifest.ISORootfsImg
switch img.RootfsType {
case manifest.SquashfsExt4Rootfs:
rootfsImagePipeline = manifest.NewISORootfsImg(buildPipeline, livePipeline)
rootfsImagePipeline.Size = 8 * datasizes.GibiByte
default:
}

bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.Product, img.OSVersion)
bootTreePipeline.Platform = img.Platform
Expand Down Expand Up @@ -99,6 +107,8 @@ func (img *AnacondaLiveInstaller) InstantiateManifest(m *manifest.Manifest,
isoTreePipeline.KernelOpts = kernelOpts
isoTreePipeline.ISOLinux = isoLinuxEnabled

isoTreePipeline.SquashfsCompression = img.SquashfsCompression

isoPipeline := manifest.NewISO(buildPipeline, isoTreePipeline, img.ISOLabel)
isoPipeline.SetFilename(img.Filename)
isoPipeline.ISOLinux = isoLinuxEnabled
Expand Down
10 changes: 8 additions & 2 deletions pkg/image/anaconda_ostree_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type AnacondaOSTreeInstaller struct {
Subscription *subscription.ImageOptions

SquashfsCompression string
RootfsType manifest.RootfsType

ISOLabel string
Product string
Expand Down Expand Up @@ -101,8 +102,13 @@ func (img *AnacondaOSTreeInstaller) InstantiateManifest(m *manifest.Manifest,
anacondaPipeline.DisabledAnacondaModules = img.DisabledAnacondaModules
anacondaPipeline.AdditionalDrivers = img.AdditionalDrivers

rootfsImagePipeline := manifest.NewISORootfsImg(buildPipeline, anacondaPipeline)
rootfsImagePipeline.Size = 4 * datasizes.GibiByte
var rootfsImagePipeline *manifest.ISORootfsImg
switch img.RootfsType {
case manifest.SquashfsExt4Rootfs:
rootfsImagePipeline = manifest.NewISORootfsImg(buildPipeline, anacondaPipeline)
rootfsImagePipeline.Size = 4 * datasizes.GibiByte
default:
}

bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.Product, img.OSVersion)
bootTreePipeline.Platform = img.Platform
Expand Down
10 changes: 8 additions & 2 deletions pkg/image/anaconda_tar_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type AnacondaTarInstaller struct {
Kickstart *kickstart.Options

SquashfsCompression string
RootfsType manifest.RootfsType

ISOLabel string
Product string
Expand Down Expand Up @@ -153,8 +154,13 @@ func (img *AnacondaTarInstaller) InstantiateManifest(m *manifest.Manifest,

anacondaPipeline.Checkpoint()

rootfsImagePipeline := manifest.NewISORootfsImg(buildPipeline, anacondaPipeline)
rootfsImagePipeline.Size = 5 * datasizes.GibiByte
var rootfsImagePipeline *manifest.ISORootfsImg
switch img.RootfsType {
case manifest.SquashfsExt4Rootfs:
rootfsImagePipeline = manifest.NewISORootfsImg(buildPipeline, anacondaPipeline)
rootfsImagePipeline.Size = 5 * datasizes.GibiByte
default:
}

bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.Product, img.OSVersion)
bootTreePipeline.Platform = img.Platform
Expand Down
Loading
Loading