diff --git a/bib/cmd/bootc-image-builder/image.go b/bib/cmd/bootc-image-builder/image.go index 9efd0792..641fa533 100644 --- a/bib/cmd/bootc-image-builder/image.go +++ b/bib/cmd/bootc-image-builder/image.go @@ -216,7 +216,7 @@ func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, erro return nil, fmt.Errorf("pipeline: no base image defined") } - imageDef, err := distrodef.LoadImageDef(c.DistroDefPaths, c.SourceInfo.OSRelease.ID, "anaconda-iso") + imageDef, err := distrodef.LoadImageDef(c.DistroDefPaths, c.SourceInfo.OSRelease.ID, c.SourceInfo.OSRelease.VersionID, "anaconda-iso") if err != nil { return nil, err } diff --git a/bib/data/defs/centos.yaml b/bib/data/defs/centos-9.yaml similarity index 100% rename from bib/data/defs/centos.yaml rename to bib/data/defs/centos-9.yaml diff --git a/bib/data/defs/fedora.yaml b/bib/data/defs/fedora-40.yaml similarity index 100% rename from bib/data/defs/fedora.yaml rename to bib/data/defs/fedora-40.yaml diff --git a/bib/data/defs/fedora-41.yaml b/bib/data/defs/fedora-41.yaml new file mode 120000 index 00000000..b77da575 --- /dev/null +++ b/bib/data/defs/fedora-41.yaml @@ -0,0 +1 @@ +fedora-40.yaml \ No newline at end of file diff --git a/bib/data/defs/rhel-9.yaml b/bib/data/defs/rhel-9.yaml new file mode 120000 index 00000000..f09a8726 --- /dev/null +++ b/bib/data/defs/rhel-9.yaml @@ -0,0 +1 @@ +centos-9.yaml \ No newline at end of file diff --git a/bib/data/defs/rhel.yaml b/bib/data/defs/rhel.yaml deleted file mode 120000 index eb64f493..00000000 --- a/bib/data/defs/rhel.yaml +++ /dev/null @@ -1 +0,0 @@ -./centos.yaml \ No newline at end of file diff --git a/bib/internal/distrodef/distrodef.go b/bib/internal/distrodef/distrodef.go index 18d0b000..bb1f2b6a 100644 --- a/bib/internal/distrodef/distrodef.go +++ b/bib/internal/distrodef/distrodef.go @@ -3,7 +3,7 @@ package distrodef import ( "fmt" "os" - "path" + "path/filepath" "strings" "golang.org/x/exp/maps" @@ -17,28 +17,26 @@ type ImageDef struct { Packages []string `yaml:"packages"` } -func loadFile(defDirs []string, distro string) ([]byte, error) { +func loadFile(defDirs []string, distro, ver string) ([]byte, error) { for _, loc := range defDirs { - p := path.Join(loc, distro+".yaml") + p := filepath.Join(loc, fmt.Sprintf("%s-%s.yaml", distro, ver)) content, err := os.ReadFile(p) if os.IsNotExist(err) { continue } if err != nil { - return nil, fmt.Errorf("could not read def file %s for distro %s: %v", p, distro, err) + return nil, fmt.Errorf("could not read def file %s for distro %s-%s: %v", p, distro, ver, err) } return content, nil } - return nil, fmt.Errorf("could not find def file for distro %s", distro) + return nil, fmt.Errorf("could not find def file for distro %s-%s", distro, ver) } // Loads a definition file for a given distro and image type -// -// TODO: We should probably support multiple distro versions as well in the future. -func LoadImageDef(defDirs []string, distro, it string) (*ImageDef, error) { - data, err := loadFile(defDirs, distro) +func LoadImageDef(defDirs []string, distro, ver, it string) (*ImageDef, error) { + data, err := loadFile(defDirs, distro, ver) if err != nil { return nil, err } diff --git a/bib/internal/distrodef/distrodef_test.go b/bib/internal/distrodef/distrodef_test.go index 2affbe0b..3e94fe38 100644 --- a/bib/internal/distrodef/distrodef_test.go +++ b/bib/internal/distrodef/distrodef_test.go @@ -10,16 +10,18 @@ import ( const testDefLocation = "test_defs" func TestLoad(t *testing.T) { - def, err := LoadImageDef([]string{testDefLocation}, "fedoratest", "anaconda-iso") + def, err := LoadImageDef([]string{testDefLocation}, "fedoratest", "41", "anaconda-iso") require.NoError(t, err) assert.NotEmpty(t, def.Packages) } func TestLoadUnhappy(t *testing.T) { - _, err := LoadImageDef([]string{testDefLocation}, "lizard", "anaconda-iso") - assert.ErrorContains(t, err, "could not find def file for distro lizard") + _, err := LoadImageDef([]string{testDefLocation}, "lizard", "42", "anaconda-iso") + assert.ErrorContains(t, err, "could not find def file for distro lizard-42") + _, err = LoadImageDef([]string{testDefLocation}, "fedoratest", "0", "anaconda-iso") + assert.ErrorContains(t, err, "could not find def file for distro fedoratest-0") - _, err = LoadImageDef([]string{testDefLocation}, "fedoratest", "anaconda-disk") + _, err = LoadImageDef([]string{testDefLocation}, "fedoratest", "41", "anaconda-disk") assert.ErrorContains(t, err, "could not find def for distro fedoratest and image type anaconda-disk") } diff --git a/bib/internal/distrodef/test_defs/fedoratest.yaml b/bib/internal/distrodef/test_defs/fedoratest-41.yaml similarity index 100% rename from bib/internal/distrodef/test_defs/fedoratest.yaml rename to bib/internal/distrodef/test_defs/fedoratest-41.yaml