Skip to content

Commit fbfaa93

Browse files
committed
manifest: copy boot files from build
When the `FromBuild` property is set on a `BootFile` the source pipeline is the build pipeline; instead of the root tree. This allows us to have certain firmware packages to only be in the build pipeline instead of having to be installed in the root tree. This *also* allows us to omit the problematic `efi-srpm-macros` package which is depended upon by same firmware packages that want to write directly into the ESP. This is problematic because the ESP path is defined by `efi-srpm-macros` at build time; and can be different from what it is in our partition tables or customizations. The caveat is that without these packages installed in the root tree they also won't receive updates. This is, I guess, a necessary evil until this can be addressed in Fedora itself. Signed-off-by: Simon de Vlieger <cmdr@supakeen.com>
1 parent a4a6110 commit fbfaa93

3 files changed

Lines changed: 42 additions & 11 deletions

File tree

pkg/manifest/raw.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,20 @@ func (p *RawImage) serialize() (osbuild.Pipeline, error) {
6969
copyInputs := osbuild.NewPipelineTreeInputs(inputName, p.treePipeline.Name())
7070
pipeline.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
7171

72-
bootFiles := p.treePipeline.platform.GetBootFiles()
73-
if len(bootFiles) > 0 {
74-
bootCopyInputs := osbuild.NewPipelineTreeInputs(inputName, p.treePipeline.Name())
75-
stage, err := bootFilesCopyStage(bootFiles, bootCopyInputs, inputName, inputName, p.treePipeline.Name(), p.Filename(), pt)
72+
treeBootFiles, buildBootFiles := splitBootFiles(p.treePipeline.platform.GetBootFiles())
73+
if len(treeBootFiles) > 0 {
74+
treeInputName := "root-tree"
75+
bootCopyInputs := osbuild.NewPipelineTreeInputs(treeInputName, p.treePipeline.Name())
76+
stage, err := bootFilesCopyStage(treeBootFiles, bootCopyInputs, treeInputName, p.Filename(), pt)
77+
if err != nil {
78+
return osbuild.Pipeline{}, err
79+
}
80+
pipeline.AddStage(stage)
81+
}
82+
if len(buildBootFiles) > 0 {
83+
buildInputName := "build-tree"
84+
buildCopyInputs := osbuild.NewPipelineTreeInputs(buildInputName, p.build.Name())
85+
stage, err := bootFilesCopyStage(buildBootFiles, buildCopyInputs, buildInputName, p.Filename(), pt)
7686
if err != nil {
7787
return osbuild.Pipeline{}, err
7888
}
@@ -117,13 +127,24 @@ func (p *RawImage) serialize() (osbuild.Pipeline, error) {
117127
return pipeline, nil
118128
}
119129

130+
func splitBootFiles(bootFiles []platform.BootFile) (tree, build []platform.BootFile) {
131+
for _, bf := range bootFiles {
132+
if bf.FromBuild {
133+
build = append(build, bf)
134+
} else {
135+
tree = append(tree, bf)
136+
}
137+
}
138+
return tree, build
139+
}
140+
120141
func bootFilesCopyStage(
121142
bootFiles []platform.BootFile,
122143
inputs osbuild.Inputs,
123-
srcPrefix, inputName, pipelineName, filename string,
144+
srcPrefix, filename string,
124145
pt *disk.PartitionTable,
125146
) (*osbuild.Stage, error) {
126-
_, devices, mounts := osbuild.GenCopyFSTreeOptions(inputName, pipelineName, filename, pt)
147+
_, devices, mounts := osbuild.GenCopyFSTreeOptions("", "", filename, pt)
127148

128149
var fsRootMntName string
129150
for _, mnt := range mounts {

pkg/manifest/raw_ostree.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,24 @@ func (p *RawOSTreeImage) serialize() (osbuild.Pipeline, error) {
7171

7272
pipeline.AddStage(osbuild.NewCopyStage(treeCopyOptions, treeCopyInputs, treeCopyDevices, treeCopyMounts))
7373

74-
bootFiles := p.platform.GetBootFiles()
75-
if len(bootFiles) > 0 {
74+
treeBootFiles, buildBootFiles := splitBootFiles(p.platform.GetBootFiles())
75+
if len(treeBootFiles) > 0 {
7676
commit := p.treePipeline.ostreeSpec
7777
commitChecksum := commit.Checksum
7878
bootCopyInputs := osbuild.OSTreeCheckoutInputs{
7979
"ostree-tree": *osbuild.NewOSTreeCheckoutInput("org.osbuild.source", commitChecksum),
8080
}
8181
srcPrefix := fmt.Sprintf("ostree-tree/%s", commitChecksum)
82-
stage, err := bootFilesCopyStage(bootFiles, bootCopyInputs, srcPrefix, inputName, p.treePipeline.Name(), p.Filename(), pt)
82+
stage, err := bootFilesCopyStage(treeBootFiles, bootCopyInputs, srcPrefix, p.Filename(), pt)
83+
if err != nil {
84+
return osbuild.Pipeline{}, err
85+
}
86+
pipeline.AddStage(stage)
87+
}
88+
if len(buildBootFiles) > 0 {
89+
buildInputName := "build-tree"
90+
buildCopyInputs := osbuild.NewPipelineTreeInputs(buildInputName, p.build.Name())
91+
stage, err := bootFilesCopyStage(buildBootFiles, buildCopyInputs, buildInputName, p.Filename(), pt)
8392
if err != nil {
8493
return osbuild.Pipeline{}, err
8594
}

pkg/platform/platform.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ func (f *ImageFormat) UnmarshalYAML(unmarshal func(any) error) error {
150150
}
151151

152152
type BootFile struct {
153-
Src string `yaml:"src" json:"src"`
154-
Dst string `yaml:"dst" json:"dst"`
153+
Src string `yaml:"src" json:"src"`
154+
Dst string `yaml:"dst" json:"dst"`
155+
FromBuild bool `yaml:"from_build,omitempty" json:"from_build,omitempty"`
155156
}
156157

157158
type Platform interface {

0 commit comments

Comments
 (0)