distro: deduplicate *kickstartStageOptions()
Use single NewKickstartStageOptions() and replace image-type-specific
implementation from each distro.
- Followup from cb186df208, copied to the
rest of the RHEL distro definitions.
NB: The change was not made in the Fedora distro definitions as they are
currently being rewritten.
This commit is contained in:
parent
42364f2cc6
commit
3d53ca5d8d
5 changed files with 35 additions and 61 deletions
|
|
@ -14,6 +14,10 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
const (
|
||||
kspath = "/usr/share/anaconda/interactive-defaults.ks"
|
||||
)
|
||||
|
||||
type imageTypeS2 struct {
|
||||
arch *architecture
|
||||
name string
|
||||
|
|
@ -261,7 +265,11 @@ func (t *imageTypeS2) pipelines(customizations *blueprint.Customizations, option
|
|||
}
|
||||
// TODO: panic if not found
|
||||
kernelVer := fmt.Sprintf("%s-%s.%s", kernelPkg.Version, kernelPkg.Release, kernelPkg.Arch)
|
||||
pipelines = append(pipelines, *t.anacondaTreePipeline(repos, packageSetSpecs["installer"], options, kernelVer))
|
||||
anacondaPipeline, err := t.anacondaTreePipeline(repos, packageSetSpecs["installer"], options, kernelVer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pipelines = append(pipelines, *anacondaPipeline)
|
||||
pipelines = append(pipelines, *t.bootISOTreePipeline(kernelVer))
|
||||
pipelines = append(pipelines, *t.bootISOPipeline())
|
||||
} else {
|
||||
|
|
@ -431,7 +439,7 @@ func (t *imageTypeS2) containerPipeline() *osbuild.Pipeline {
|
|||
return p
|
||||
}
|
||||
|
||||
func (t *imageTypeS2) anacondaTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, options distro.ImageOptions, kernelVer string) *osbuild.Pipeline {
|
||||
func (t *imageTypeS2) anacondaTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, options distro.ImageOptions, kernelVer string) (*osbuild.Pipeline, error) {
|
||||
ostreeRepoPath := "/ostree/repo"
|
||||
p := new(osbuild.Pipeline)
|
||||
p.Name = "anaconda-tree"
|
||||
|
|
@ -473,9 +481,13 @@ func (t *imageTypeS2) anacondaTreePipeline(repos []rpmmd.RepoConfig, packages []
|
|||
p.AddStage(osbuild.NewAnacondaStage(t.anacondaStageOptions()))
|
||||
p.AddStage(osbuild.NewLoraxScriptStage(t.loraxScriptStageOptions()))
|
||||
p.AddStage(osbuild.NewDracutStage(t.dracutStageOptions(kernelVer)))
|
||||
p.AddStage(osbuild.NewKickstartStage(t.kickstartStageOptions(fmt.Sprintf("file://%s", ostreeRepoPath), options.OSTree.Ref)))
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(kspath, "", nil, nil, fmt.Sprintf("file://%s", ostreeRepoPath), options.OSTree.Ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.AddStage(osbuild.NewKickstartStage(kickstartOptions))
|
||||
|
||||
return p
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func (t *imageTypeS2) bootISOTreePipeline(kernelVer string) *osbuild.Pipeline {
|
||||
|
|
@ -665,18 +677,6 @@ func (t *imageTypeS2) dracutStageOptions(kernelVer string) *osbuild.DracutStageO
|
|||
}
|
||||
}
|
||||
|
||||
func (t *imageTypeS2) kickstartStageOptions(ostreeURL, ostreeRef string) *osbuild.KickstartStageOptions {
|
||||
return &osbuild.KickstartStageOptions{
|
||||
Path: "/usr/share/anaconda/interactive-defaults.ks",
|
||||
OSTree: &osbuild.OSTreeOptions{
|
||||
OSName: "rhel",
|
||||
URL: ostreeURL,
|
||||
Ref: ostreeRef,
|
||||
GPG: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (t *imageTypeS2) bootISOMonoStageOptions(kernelVer string) *osbuild.BootISOMonoStageOptions {
|
||||
return &osbuild.BootISOMonoStageOptions{
|
||||
Product: osbuild.Product{
|
||||
|
|
|
|||
|
|
@ -493,7 +493,10 @@ func edgeInstallerPipelines(t *imageType, customizations *blueprint.Customizatio
|
|||
kernelVer := rpmmd.GetVerStrFromPackageSpecListPanic(installerPackages, "kernel")
|
||||
ostreeRepoPath := "/ostree/repo"
|
||||
payloadStages := ostreePayloadStages(options, ostreeRepoPath)
|
||||
kickstartOptions := ostreeKickstartStageOptions(makeISORootPath(ostreeRepoPath), options.OSTree.Ref)
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(kspath, "", nil, nil, makeISORootPath(ostreeRepoPath), options.OSTree.Ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, t.Arch().Name()))
|
||||
pipelines = append(pipelines, *bootISOTreePipeline(kernelVer, t.Arch().Name(), kickstartOptions, payloadStages))
|
||||
pipelines = append(pipelines, *bootISOPipeline(t.Filename(), t.Arch().Name(), false))
|
||||
|
|
@ -528,7 +531,11 @@ func tarInstallerPipelines(t *imageType, customizations *blueprint.Customization
|
|||
|
||||
tarPath := "/liveimg.tar"
|
||||
tarPayloadStages := []*osbuild.Stage{tarStage("os", tarPath)}
|
||||
kickstartOptions := tarKickstartStageOptions(makeISORootPath(tarPath))
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(kspath, makeISORootPath(tarPath), nil, nil, "", "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, t.Arch().Name()))
|
||||
pipelines = append(pipelines, *bootISOTreePipeline(kernelVer, t.Arch().Name(), kickstartOptions, tarPayloadStages))
|
||||
pipelines = append(pipelines, *bootISOPipeline(t.Filename(), t.Arch().Name(), true))
|
||||
|
|
|
|||
|
|
@ -168,26 +168,6 @@ func dracutStageOptions(kernelVer, arch string, additionalModules []string) *osb
|
|||
}
|
||||
}
|
||||
|
||||
func tarKickstartStageOptions(tarURL string) *osbuild.KickstartStageOptions {
|
||||
return &osbuild.KickstartStageOptions{
|
||||
Path: kspath,
|
||||
LiveIMG: &osbuild.LiveIMG{
|
||||
URL: tarURL,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ostreeKickstartStageOptions(ostreeURL, ostreeRef string) *osbuild.KickstartStageOptions {
|
||||
return &osbuild.KickstartStageOptions{
|
||||
Path: kspath,
|
||||
OSTree: &osbuild.OSTreeOptions{
|
||||
OSName: "rhel",
|
||||
URL: ostreeURL,
|
||||
Ref: ostreeRef,
|
||||
GPG: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
func bootISOMonoStageOptions(kernelVer string, arch string) *osbuild.BootISOMonoStageOptions {
|
||||
comprOptions := new(osbuild.FSCompressionOptions)
|
||||
if bcj := osbuild.BCJOption(arch); bcj != "" {
|
||||
|
|
|
|||
|
|
@ -625,7 +625,11 @@ func edgeInstallerPipelines(t *imageType, customizations *blueprint.Customizatio
|
|||
kernelVer := rpmmd.GetVerStrFromPackageSpecListPanic(installerPackages, "kernel")
|
||||
ostreeRepoPath := "/ostree/repo"
|
||||
pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, t.Arch().Name(), ostreePayloadStages(options, ostreeRepoPath)))
|
||||
pipelines = append(pipelines, *bootISOTreePipeline(kernelVer, t.Arch().Name(), ostreeKickstartStageOptions(fmt.Sprintf("file://%s", ostreeRepoPath), options.OSTree.Ref)))
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(kspath, "", nil, nil, fmt.Sprintf("file://%s", ostreeRepoPath), options.OSTree.Ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pipelines = append(pipelines, *bootISOTreePipeline(kernelVer, t.Arch().Name(), kickstartOptions))
|
||||
pipelines = append(pipelines, *bootISOPipeline(t.Filename(), t.Arch().Name()))
|
||||
return pipelines, nil
|
||||
}
|
||||
|
|
@ -659,7 +663,11 @@ func tarInstallerPipelines(t *imageType, customizations *blueprint.Customization
|
|||
tarPath := "/liveimg.tar"
|
||||
tarPayloadStages := []*osbuild.Stage{tarStage("os", tarPath)}
|
||||
pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, t.Arch().Name(), tarPayloadStages))
|
||||
pipelines = append(pipelines, *bootISOTreePipeline(kernelVer, t.Arch().Name(), tarKickstartStageOptions(fmt.Sprintf("file://%s", tarPath))))
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(kspath, fmt.Sprintf("file://%s", tarPath), nil, nil, "", "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pipelines = append(pipelines, *bootISOTreePipeline(kernelVer, t.Arch().Name(), kickstartOptions))
|
||||
pipelines = append(pipelines, *bootISOPipeline(t.Filename(), t.Arch().Name()))
|
||||
return pipelines, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,27 +161,6 @@ func dracutStageOptions(kernelVer string) *osbuild.DracutStageOptions {
|
|||
}
|
||||
}
|
||||
|
||||
func tarKickstartStageOptions(tarURL string) *osbuild.KickstartStageOptions {
|
||||
return &osbuild.KickstartStageOptions{
|
||||
Path: kspath,
|
||||
LiveIMG: &osbuild.LiveIMG{
|
||||
URL: tarURL,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ostreeKickstartStageOptions(ostreeURL, ostreeRef string) *osbuild.KickstartStageOptions {
|
||||
return &osbuild.KickstartStageOptions{
|
||||
Path: kspath,
|
||||
OSTree: &osbuild.OSTreeOptions{
|
||||
OSName: "rhel",
|
||||
URL: ostreeURL,
|
||||
Ref: ostreeRef,
|
||||
GPG: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func bootISOMonoStageOptions(kernelVer string, arch string) *osbuild.BootISOMonoStageOptions {
|
||||
comprOptions := new(osbuild.FSCompressionOptions)
|
||||
if bcj := osbuild.BCJOption(arch); bcj != "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue