Skip to content

Commit

Permalink
os: generate modularity files
Browse files Browse the repository at this point in the history
Generate stages for files and directories based on the data returned by
the dependency solver for the enabled modules.

Signed-off-by: Simon de Vlieger <[email protected]>
  • Loading branch information
supakeen committed Feb 6, 2025
1 parent da00546 commit 6979001
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkg/manifest/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ type OS struct {
// content-related fields
repos []rpmmd.RepoConfig
packageSpecs []rpmmd.PackageSpec
moduleSpecs []rpmmd.ModuleSpec
containerSpecs []container.Spec
ostreeParentSpec *ostree.CommitSpec

Expand Down Expand Up @@ -372,6 +373,10 @@ func (p *OS) getPackageSpecs() []rpmmd.PackageSpec {
return p.packageSpecs
}

func (p *OS) getModuleSpecs() []rpmmd.ModuleSpec {

Check failure on line 376 in pkg/manifest/os.go

View workflow job for this annotation

GitHub Actions / ⌨ Lint

func `(*OS).getModuleSpecs` is unused (unused)
return p.moduleSpecs
}

func (p *OS) getContainerSpecs() []container.Spec {
return p.containerSpecs
}
Expand All @@ -382,6 +387,7 @@ func (p *OS) serializeStart(inputs Inputs) {
}

p.packageSpecs = inputs.Depsolved.Packages
p.moduleSpecs = inputs.Depsolved.Modules
p.containerSpecs = inputs.Containers
if len(inputs.Commits) > 0 {
if len(inputs.Commits) > 1 {
Expand Down Expand Up @@ -444,6 +450,34 @@ func (p *OS) serialize() osbuild.Pipeline {
}
pipeline.AddStage(osbuild.NewRPMStage(rpmOptions, osbuild.NewRpmStageSourceFilesInputs(p.packageSpecs)))

// write modularity related configuration files
if len(p.moduleSpecs) > 0 {
pipeline.AddStages(osbuild.GenDNFModuleConfigStages(p.moduleSpecs)...)

var failsafeFiles []*fsnode.File

// the failsafe file is a blob of YAML returned directly from the depsolver,
// we write them as 'normal files' without a special stage
for _, module := range p.moduleSpecs {
moduleFailsafeFile, err := fsnode.NewFile(module.FailsafeFile.Path, nil, nil, nil, []byte(module.FailsafeFile.Data))

if err != nil {
panic("failed to create module failsafe file")
}

failsafeFiles = append(failsafeFiles, moduleFailsafeFile)
}

failsafeDir, err := fsnode.NewDirectory("/var/lib/dnf/modulefailsafe", nil, nil, nil, true)

if err != nil {
panic("failed to create module failsafe directory")
}

pipeline.AddStages(osbuild.GenDirectoryNodesStages([]*fsnode.Directory{failsafeDir})...)
pipeline.AddStages(osbuild.GenFileNodesStages(failsafeFiles)...)
}

if !p.NoBLS {
// If the /boot is on a separate partition, the prefix for the BLS stage must be ""
if p.PartitionTable == nil || p.PartitionTable.FindMountable("/boot") == nil {
Expand Down

0 comments on commit 6979001

Please sign in to comment.