Skip to content

Commit

Permalink
images: Add ability to select type of rootfs for isos
Browse files Browse the repository at this point in the history
  • Loading branch information
bcl committed Dec 17, 2024
1 parent 8da1e8d commit ad09763
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 11 deletions.
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
21 changes: 18 additions & 3 deletions pkg/manifest/anaconda_installer_iso_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ import (
"github.com/osbuild/images/pkg/rpmmd"
)

type RootfsType uint64

// These constants are used by the ISO images to control the style of the root filesystem
const ( // Rootfs type enum
SquashfsExt4Rootfs RootfsType = iota // Create an EXT4 rootfs compressed by Squashfs
SquashfsRootfs // Create a plain squashfs rootfs
)

// An AnacondaInstallerISOTree represents a tree containing the anaconda installer,
// configuration in terms of a kickstart file, as well as an embedded
// payload to be installed, this payload can either be an ostree
Expand All @@ -30,7 +38,7 @@ type AnacondaInstallerISOTree struct {
PartitionTable *disk.PartitionTable

anacondaPipeline *AnacondaInstaller
rootfsPipeline *ISORootfsImg
rootfsPipeline *ISORootfsImg // May be nil for plain squashfs rootfs
bootTreePipeline *EFIBootTree

// The path where the payload (tarball, ostree repo, or container) will be stored.
Expand Down Expand Up @@ -68,7 +76,7 @@ type AnacondaInstallerISOTree struct {
func NewAnacondaInstallerISOTree(buildPipeline Build, anacondaPipeline *AnacondaInstaller, rootfsPipeline *ISORootfsImg, bootTreePipeline *EFIBootTree) *AnacondaInstallerISOTree {

// the three pipelines should all belong to the same manifest
if anacondaPipeline.Manifest() != rootfsPipeline.Manifest() ||
if (rootfsPipeline != nil && anacondaPipeline.Manifest() != rootfsPipeline.Manifest()) ||
anacondaPipeline.Manifest() != bootTreePipeline.Manifest() {
panic("pipelines from different manifests")
}
Expand Down Expand Up @@ -278,7 +286,14 @@ func (p *AnacondaInstallerISOTree) serialize() osbuild.Pipeline {
}
}

squashfsStage := osbuild.NewSquashfsStage(&squashfsOptions, p.rootfsPipeline.Name())
// The iso's rootfs can either be an ext4 filesystem compressed with squashfs, or
// a squashfs of the plain directory tree
var squashfsStage *osbuild.Stage
if p.rootfsPipeline != nil {
squashfsStage = osbuild.NewSquashfsStage(&squashfsOptions, p.rootfsPipeline.Name())
} else {
squashfsStage = osbuild.NewSquashfsStage(&squashfsOptions, p.anacondaPipeline.Name())
}
pipeline.AddStage(squashfsStage)

if p.ISOLinux {
Expand Down

0 comments on commit ad09763

Please sign in to comment.