Skip to content

Commit 945a411

Browse files
committed
bib: add support for ID_LIKE when finding the distro YAML
This commit adds a fallback check when no direct match for the distro ID from the bootc image is found. As long as the bootc container sets a correct `ID_LIKE` we should automatically have the same behavior as before when we used symlinks as aliases. If needed we might need to reintroduce an explicit mapping like: ```go // mapping of distro IDs that are compatible with var distroCompat = map[string]string{ "almalinux": "rhel", "aurora": "fedora", "aurora-helium": "rhel", "bazzite": "fedora", "bluefin": "fedora", "heliumos": "rhel", "rocky": "rhel", } ``` but lets hope we don't need this.
1 parent 8aa2de9 commit 945a411

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

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

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,22 +222,51 @@ func labelForISO(os *osinfo.OSRelease, arch *arch.Arch) string {
222222
}
223223
}
224224

225+
// mapping of distro IDs that are compatible with
226+
var distroCompat = map[string]string{
227+
"almalinux": "rhel",
228+
"aurora": "fedora",
229+
"aurora-helium": "rhel",
230+
"bazzite": "fedora",
231+
"bluefin": "fedora",
232+
"heliumos": "rhel",
233+
"rocky": "rhel",
234+
}
235+
236+
// newDistroYAMLFrom() returns the distroYAML for the given sourceInfo,
237+
// if no direct match can be found it will it will use the variantID.
238+
// This should ensure we work on every bootc image that puts a correct
239+
// ID_LIKE= in /etc/os-release
240+
func newDistroYAMLFrom(sourceInfo *osinfo.Info) (*defs.DistroYAML, *distro.ID, error) {
241+
for _, distroID := range []string{
242+
sourceInfo.OSRelease.ID,
243+
sourceInfo.OSRelease.VariantID,
244+
} {
245+
nameVer := fmt.Sprintf("%s-%s", distroID, sourceInfo.OSRelease.VersionID)
246+
id, err := distro.ParseID(nameVer)
247+
if err != nil {
248+
return nil, nil, err
249+
}
250+
distroYAML, err := defs.NewDistroYAML(nameVer)
251+
if err != nil {
252+
return nil, nil, err
253+
}
254+
if distroYAML != nil {
255+
return distroYAML, id, nil
256+
}
257+
}
258+
return nil, nil, fmt.Errorf("cannot load distro definitions for %s-%s or %s-%s", sourceInfo.OSRelease.ID, sourceInfo.OSRelease.VersionID, sourceInfo.OSRelease.VariantID, sourceInfo.OSRelease.VersionID)
259+
}
260+
225261
func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, error) {
226262
if c.Imgref == "" {
227263
return nil, fmt.Errorf("pipeline: no base image defined")
228264
}
229-
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)
265+
distroYAML, id, err := newDistroYAMLFrom(c.SourceInfo)
238266
if err != nil {
239267
return nil, err
240268
}
269+
241270
// XXX: or "bootc-legacy-installer"?
242271
installerImgTypeName := "bootc-rpm-installer"
243272
imgType, ok := distroYAML.ImageTypes()[installerImgTypeName]

0 commit comments

Comments
 (0)