@@ -3,7 +3,6 @@ package main
33import (
44 "fmt"
55 "math/rand"
6- "slices"
76 "strconv"
87 "strings"
98
@@ -15,6 +14,8 @@ import (
1514 "github.com/osbuild/images/pkg/customizations/kickstart"
1615 "github.com/osbuild/images/pkg/depsolvednf"
1716 "github.com/osbuild/images/pkg/disk"
17+ "github.com/osbuild/images/pkg/distro"
18+ "github.com/osbuild/images/pkg/distro/defs"
1819 "github.com/osbuild/images/pkg/image"
1920 "github.com/osbuild/images/pkg/manifest"
2021 "github.com/osbuild/images/pkg/osbuild"
@@ -24,19 +25,8 @@ import (
2425 "github.com/sirupsen/logrus"
2526
2627 podman_container "github.com/osbuild/images/pkg/bib/container"
27-
28- "github.com/osbuild/bootc-image-builder/bib/internal/distrodef"
2928)
3029
31- // all possible locations for the bib's distro definitions
32- // ./data/defs and ./bib/data/defs are for development
33- // /usr/share/bootc-image-builder/defs is for the production, containerized version
34- var distroDefPaths = []string {
35- "./data/defs" ,
36- "./bib/data/defs" ,
37- "/usr/share/bootc-image-builder/defs" ,
38- }
39-
4030type ManifestConfig struct {
4131 // OCI image path (without the transport, that is always docker://)
4232 Imgref string
@@ -134,7 +124,6 @@ func manifestFromCobraForLegacyISO(imgref, buildImgref, imgTypeStr, rootFs, rpmC
134124 Config : config ,
135125 Imgref : imgref ,
136126 BuildImgref : buildImgref ,
137- DistroDefPaths : distroDefPaths ,
138127 SourceInfo : sourceinfo ,
139128 BuildSourceInfo : buildSourceinfo ,
140129 RootFSType : rootfsType ,
@@ -233,45 +222,36 @@ func labelForISO(os *osinfo.OSRelease, arch *arch.Arch) string {
233222 }
234223}
235224
236- // from:https://github.com/osbuild/images/blob/v0.207.0/data/distrodefs/rhel-10/imagetypes.yaml#L169
237- var loraxRhelTemplates = []manifest.InstallerLoraxTemplate {
238- manifest.InstallerLoraxTemplate {Path : "80-rhel/runtime-postinstall.tmpl" },
239- manifest.InstallerLoraxTemplate {Path : "80-rhel/runtime-cleanup.tmpl" , AfterDracut : true },
240- }
241-
242- // from:https://github.com/osbuild/images/blob/v0.207.0/data/distrodefs/fedora/imagetypes.yaml#L408
243- var loraxFedoraTemplates = []manifest.InstallerLoraxTemplate {
244- manifest.InstallerLoraxTemplate {Path : "99-generic/runtime-postinstall.tmpl" },
245- manifest.InstallerLoraxTemplate {Path : "99-generic/runtime-cleanup.tmpl" , AfterDracut : true },
246- }
247-
248- func loraxTemplates (si osinfo.OSRelease ) []manifest.InstallerLoraxTemplate {
249- switch {
250- case si .ID == "rhel" || slices .Contains (si .IDLike , "rhel" ) || si .VersionID == "eln" :
251- return loraxRhelTemplates
252- default :
253- return loraxFedoraTemplates
254- }
255- }
256-
257- func loraxTemplatePackage (si osinfo.OSRelease ) string {
258- switch {
259- case si .ID == "rhel" || slices .Contains (si .IDLike , "rhel" ) || si .VersionID == "eln" :
260- return "lorax-templates-rhel"
261- default :
262- return "lorax-templates-generic"
263- }
264- }
265-
266225func manifestForISO (c * ManifestConfig , rng * rand.Rand ) (* manifest.Manifest , error ) {
267226 if c .Imgref == "" {
268227 return nil , fmt .Errorf ("pipeline: no base image defined" )
269228 }
270229
271- imageDef , err := distrodef .LoadImageDef (c .DistroDefPaths , c .SourceInfo .OSRelease .ID , c .SourceInfo .OSRelease .VersionID , "anaconda-iso" )
230+ nameVer := fmt .Sprintf ("%s-%s" , c .SourceInfo .OSRelease .ID , c .SourceInfo .OSRelease .VersionID )
231+ id , err := distro .ParseID (nameVer )
232+ if err != nil {
233+ return nil , err
234+ }
235+ // XXX: ensure all aliases we have for bib are available in
236+ // images
237+ distroYAML , err := defs .NewDistroYAML (nameVer )
272238 if err != nil {
273239 return nil , err
274240 }
241+ // XXX: or "bootc-legacy-installer"?
242+ installerImgTypeName := "bootc-rpm-installer"
243+ imgType , ok := distroYAML .ImageTypes ()[installerImgTypeName ]
244+ if ! ok {
245+ return nil , fmt .Errorf ("cannot find image definition for %v" , installerImgTypeName )
246+ }
247+ installerPkgSet , ok := imgType .PackageSets (* id , c .Architecture .String ())["installer" ]
248+ if ! ok {
249+ return nil , fmt .Errorf ("cannot find installer package set for %v" , installerImgTypeName )
250+ }
251+ installerConfig := imgType .InstallerConfig (* id , c .Architecture .String ())
252+ if installerConfig == nil {
253+ return nil , fmt .Errorf ("empty installer config for %s" , installerImgTypeName )
254+ }
275255
276256 containerSource := container.SourceSpec {
277257 Source : c .Imgref ,
@@ -316,10 +296,7 @@ func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, erro
316296 img .InstallerCustomizations .Product = c .SourceInfo .OSRelease .Name
317297 img .InstallerCustomizations .OSVersion = c .SourceInfo .OSRelease .VersionID
318298 img .InstallerCustomizations .ISOLabel = labelForISO (& c .SourceInfo .OSRelease , & c .Architecture )
319-
320- img .ExtraBasePackages = rpmmd.PackageSet {
321- Include : imageDef .Packages ,
322- }
299+ img .ExtraBasePackages = installerPkgSet
323300
324301 var customizations * blueprint.Customizations
325302 if c .Config != nil {
@@ -358,8 +335,10 @@ func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, erro
358335 img .Kickstart .OSTree = & kickstart.OSTree {
359336 OSName : "default" ,
360337 }
361- img .InstallerCustomizations .LoraxTemplates = loraxTemplates (c .SourceInfo .OSRelease )
362- img .InstallerCustomizations .LoraxTemplatePackage = loraxTemplatePackage (c .SourceInfo .OSRelease )
338+ img .InstallerCustomizations .LoraxTemplates = installerConfig .LoraxTemplates
339+ if installerConfig .LoraxTemplatePackage != nil {
340+ img .InstallerCustomizations .LoraxTemplatePackage = * installerConfig .LoraxTemplatePackage
341+ }
363342
364343 // see https://github.com/osbuild/bootc-image-builder/issues/733
365344 img .InstallerCustomizations .ISORootfsType = manifest .SquashfsRootfs
0 commit comments