Skip to content

Commit 018dc9d

Browse files
committed
many: drop custom distrodefs and use images DistroYAML
Instead of having a separate implementation of the required packages and the required lorax templates and similar we now reuse the images `data/distrodefs` YAML so that all the packages/definitions are maintained in a central place.
1 parent 63c2d6f commit 018dc9d

21 files changed

+29
-627
lines changed

Containerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ COPY ./group_osbuild-osbuild-fedora.repo /etc/yum.repos.d/
1616
COPY ./package-requires.txt .
1717
RUN grep -vE '^#' package-requires.txt | xargs dnf install -y && rm -f package-requires.txt && dnf clean all
1818
COPY --from=builder /build/bin/* /usr/bin/
19-
COPY bib/data /usr/share/bootc-image-builder
2019

2120
ENTRYPOINT ["/usr/bin/bootc-image-builder"]
2221
VOLUME /output

bib/cmd/bootc-image-builder/legacy_iso.go

Lines changed: 29 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
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-
4030
type 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-
266225
func 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

bib/data/defs/almalinux-10.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

bib/data/defs/almalinux-9.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

bib/data/defs/aurora-40.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

bib/data/defs/aurora-helium-10.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

bib/data/defs/bazzite-40.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

bib/data/defs/bluefin-40.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

bib/data/defs/centos-10.yaml

Lines changed: 0 additions & 93 deletions
This file was deleted.

bib/data/defs/centos-9.yaml

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)