manifest: make the partition tool for raw images configurable

Add the partition tool as an option on the Raw pipeline.  Set it to the
old value (sfdisk) by default.

Expose the option up through the liveImage image kind so that the
distribution can set it if needed.
For RHEL 7, set it to sgdisk.
This commit is contained in:
Achilleas Koutsou 2023-01-23 23:09:41 +01:00 committed by Tomáš Hozza
parent 1cc53f00f4
commit 83fc8218d6
3 changed files with 14 additions and 3 deletions

View file

@ -181,6 +181,8 @@ func liveImage(workload workload.Workload,
img.Environment = t.environment
img.Workload = workload
img.Compression = t.compression
img.PartTool = osbuild.PTSgdisk // all RHEL 7 images should use sgdisk
// TODO: move generation into LiveImage
pt, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
if err != nil {

View file

@ -25,11 +25,13 @@ type LiveImage struct {
Workload workload.Workload
Filename string
Compression string
PartTool osbuild.PartTool
}
func NewLiveImage() *LiveImage {
return &LiveImage{
Base: NewBase("live-image"),
Base: NewBase("live-image"),
PartTool: osbuild.PTSfdisk,
}
}
@ -47,6 +49,7 @@ func (img *LiveImage) InstantiateManifest(m *manifest.Manifest,
osPipeline.Workload = img.Workload
imagePipeline := manifest.NewRawImage(m, buildPipeline, osPipeline)
imagePipeline.PartTool = img.PartTool
var artifact *artifact.Artifact
var artifactPipeline manifest.Pipeline

View file

@ -12,6 +12,7 @@ type RawImage struct {
Base
treePipeline *OS
Filename string
PartTool osbuild.PartTool
}
func NewRawImage(m *Manifest,
@ -26,12 +27,17 @@ func NewRawImage(m *Manifest,
if treePipeline.Base.manifest != m {
panic("tree pipeline from different manifest")
}
p.PartTool = osbuild.PTSfdisk // default; can be changed after initialisation
m.addPipeline(p)
return p
}
func (p *RawImage) getBuildPackages() []string {
return p.treePipeline.getBuildPackages()
pkgs := p.treePipeline.getBuildPackages()
if p.PartTool == osbuild.PTSgdisk {
pkgs = append(pkgs, "gdisk")
}
return pkgs
}
func (p *RawImage) serialize() osbuild.Pipeline {
@ -42,7 +48,7 @@ func (p *RawImage) serialize() osbuild.Pipeline {
panic("no partition table in live image")
}
for _, stage := range osbuild.GenImagePrepareStages(pt, p.Filename, osbuild.PTSfdisk) {
for _, stage := range osbuild.GenImagePrepareStages(pt, p.Filename, p.PartTool) {
pipeline.AddStage(stage)
}