Skip to content

Commit

Permalink
manifest: Add support for plain erofs root filesystem on the iso
Browse files Browse the repository at this point in the history
Add support for erofs by setting the RootfsType on
AnacondaInstallerISOTree to ErofsRootfs to select a plain erofs
compressed root filesystem for the Anaconda ISO.
  • Loading branch information
bcl committed Dec 20, 2024
1 parent dc2bd0d commit bc37dbe
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions pkg/manifest/anaconda_installer_iso_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type RootfsType uint64
const ( // Rootfs type enum
SquashfsExt4Rootfs RootfsType = iota // Create an EXT4 rootfs compressed by Squashfs
SquashfsRootfs // Create a plain squashfs rootfs
ErofsRootfs // Create a plain erofs rootfs
)

// An AnacondaInstallerISOTree represents a tree containing the anaconda installer,
Expand Down Expand Up @@ -136,8 +137,13 @@ func (p *AnacondaInstallerISOTree) getInline() []string {
return inlineData
}
func (p *AnacondaInstallerISOTree) getBuildPackages(_ Distro) []string {
packages := []string{
"squashfs-tools",
var packages []string
switch p.RootfsType {
case SquashfsExt4Rootfs, SquashfsRootfs:
packages = []string{"squashfs-tools"}
case ErofsRootfs:
packages = []string{"erofs-utils"}
default:
}

if p.OSTreeCommitSource != nil {
Expand Down Expand Up @@ -191,6 +197,32 @@ func (p *AnacondaInstallerISOTree) NewSquashfsStage() *osbuild.Stage {
return osbuild.NewSquashfsStage(&squashfsOptions, p.anacondaPipeline.Name())
}

// NewErofsStage returns an osbuild stage configured to build
// the erofs root filesystem for the ISO.
func (p *AnacondaInstallerISOTree) NewErofsStage() *osbuild.Stage {
var erofsOptions osbuild.ErofsStageOptions

if p.anacondaPipeline.Type == AnacondaInstallerTypePayload {
erofsOptions = osbuild.ErofsStageOptions{
Filename: "images/install.img",
}
} else if p.anacondaPipeline.Type == AnacondaInstallerTypeLive {
erofsOptions = osbuild.ErofsStageOptions{
Filename: "LiveOS/squashfs.img",
}
}

if p.RootfsCompression != "" {
erofsOptions.Compression.Method = p.RootfsCompression
} else {
// default to zstd if not specified
erofsOptions.Compression.Method = "zstd"
}
erofsOptions.Options = []string{"all-fragments", "dedupe"}

return osbuild.NewErofsStage(&erofsOptions, p.anacondaPipeline.Name())
}

func (p *AnacondaInstallerISOTree) serializeStart(_ []rpmmd.PackageSpec, containers []container.Spec, commits []ostree.CommitSpec, _ []rpmmd.RepoConfig) {
if p.ostreeCommitSpec != nil || p.containerSpec != nil {
panic("double call to serializeStart()")
Expand Down Expand Up @@ -297,7 +329,15 @@ func (p *AnacondaInstallerISOTree) serialize() osbuild.Pipeline {
copyStageInputs := osbuild.NewPipelineTreeInputs(inputName, p.anacondaPipeline.Name())
copyStage := osbuild.NewCopyStageSimple(copyStageOptions, copyStageInputs)
pipeline.AddStage(copyStage)
pipeline.AddStage(p.NewSquashfsStage())

// Add the selected roofs stage
switch p.RootfsType {
case SquashfsExt4Rootfs, SquashfsRootfs:
pipeline.AddStage(p.NewSquashfsStage())
case ErofsRootfs:
pipeline.AddStage(p.NewErofsStage())
default:
}

if p.ISOLinux {
isoLinuxOptions := &osbuild.ISOLinuxStageOptions{
Expand Down

0 comments on commit bc37dbe

Please sign in to comment.