From 578a23b3a1f5d2792165ef5cec2324f4924a0e5a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 30 Jul 2025 12:45:23 +0200 Subject: [PATCH] distro: fix bug in variable substitution for static distros This fixes a bug that when a distro is not found via the `match` mechanism but with an exact `name` match the variables where not substituted. This caused an error in image-builder-clis build. We also need a reverse dependency test for ibcli in images but that should be its own commit. --- pkg/distro/defs/loader.go | 9 +++++---- pkg/distro/defs/loader_test.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/distro/defs/loader.go b/pkg/distro/defs/loader.go index 360d7daef9..5587ef37dd 100644 --- a/pkg/distro/defs/loader.go +++ b/pkg/distro/defs/loader.go @@ -210,17 +210,18 @@ func NewDistroYAML(nameVer string) (*DistroYAML, error) { return nil, err } if found != "" { - if err := distro.runTemplates(found); err != nil { - return nil, err - } - foundDistro = &distro + // nameVer must be replaced with normalized name + nameVer = found break } } if foundDistro == nil { return nil, nil } + if err := foundDistro.runTemplates(nameVer); err != nil { + return nil, err + } // load imageTypes f, err := dataFS().Open(filepath.Join(foundDistro.DefsPath, "distro.yaml")) diff --git a/pkg/distro/defs/loader_test.go b/pkg/distro/defs/loader_test.go index 2a76fbc524..d893e281d8 100644 --- a/pkg/distro/defs/loader_test.go +++ b/pkg/distro/defs/loader_test.go @@ -795,7 +795,7 @@ distros: name: org.osbuild.fedora43 build_packages: ["glibc"] bootstrap_containers: - x86_64: "registry.fedoraproject.org/fedora-toolbox:43" + x86_64: "registry.fedoraproject.org/fedora-toolbox:{{.MajorVersion}}" oscap_profiles_allowlist: - "xccdf_org.ssgproject.content_profile_ospp"