Skip to content

Commit 7cd20c3

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 7cd20c3

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

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

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

225+
// newDistroYAMLFrom() returns the distroYAML for the given sourceInfo,
226+
// if no direct match can be found it will it will use the variantID.
227+
// This should ensure we work on every bootc image that puts a correct
228+
// ID_LIKE= in /etc/os-release
229+
func newDistroYAMLFrom(sourceInfo *osinfo.Info) (*defs.DistroYAML, *distro.ID, error) {
230+
for _, distroID := range []string{
231+
sourceInfo.OSRelease.ID,
232+
sourceInfo.OSRelease.VariantID,
233+
} {
234+
nameVer := fmt.Sprintf("%s-%s", distroID, sourceInfo.OSRelease.VersionID)
235+
id, err := distro.ParseID(nameVer)
236+
if err != nil {
237+
return nil, nil, err
238+
}
239+
distroYAML, err := defs.NewDistroYAML(nameVer)
240+
if err != nil {
241+
return nil, nil, err
242+
}
243+
if distroYAML != nil {
244+
return distroYAML, id, nil
245+
}
246+
}
247+
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)
248+
}
249+
225250
func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, error) {
226251
if c.Imgref == "" {
227252
return nil, fmt.Errorf("pipeline: no base image defined")
228253
}
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)
254+
distroYAML, id, err := newDistroYAMLFrom(c.SourceInfo)
238255
if err != nil {
239256
return nil, err
240257
}
258+
241259
// XXX: or "bootc-legacy-installer"?
242260
installerImgTypeName := "bootc-rpm-installer"
243261
imgType, ok := distroYAML.ImageTypes()[installerImgTypeName]

0 commit comments

Comments
 (0)