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.

The mkfs.erofs arguments will look like this:
zstd,8 -E all-fragments,dedupe -C 131072
  • Loading branch information
bcl committed Dec 20, 2024
1 parent 9ad74c1 commit a85043c
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 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,36 @@ 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",
}
}

var compression osbuild.ErofsCompression
if p.RootfsCompression != "" {
compression.Method = p.RootfsCompression
} else {
// default to zstd if not specified
compression.Method = "zstd"
}
compression.Level = common.ToPtr(8)
erofsOptions.Compression = &compression
erofsOptions.ExtendedOptions = []string{"all-fragments", "dedupe"}
erofsOptions.ClusterSize = common.ToPtr(131072)

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 +333,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 a85043c

Please sign in to comment.