From 53d489cd13ed45c2994545b5729572c041c2a743 Mon Sep 17 00:00:00 2001 From: eabdullin Date: Wed, 13 May 2026 16:22:03 +0300 Subject: [PATCH] Add AlmaLinux and AlmaLinux Kitten x86_64_v2 support --- config.yaml | 9 +- ...ve-x86_64_v2-RPMs-on-AlmaLinux-10-x8.patch | 148 ++++++++++++++++++ 2 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 files/0001-reporegistry-serve-x86_64_v2-RPMs-on-AlmaLinux-10-x8.patch diff --git a/config.yaml b/config.yaml index 2a83fd9..14d59c2 100644 --- a/config.yaml +++ b/config.yaml @@ -28,8 +28,14 @@ actions: # Fedora can build for all included fedora releases count: 1 + - add_files: + - type: "patch" + name: "0001-reporegistry-serve-x86_64_v2-RPMs-on-AlmaLinux-10-x8.patch" + number: 1000 + + - modify_release: - - suffix: ".alma.1" + - suffix: ".alma.2" enabled: true - changelog_entry: @@ -37,3 +43,4 @@ actions: email: "eabdullin@almalinux.org" line: - "Add AlmaLinux repositories" + - "Add AlmaLinux and AlmaLinux Kitten x86_64_v2 support" diff --git a/files/0001-reporegistry-serve-x86_64_v2-RPMs-on-AlmaLinux-10-x8.patch b/files/0001-reporegistry-serve-x86_64_v2-RPMs-on-AlmaLinux-10-x8.patch new file mode 100644 index 0000000..9df6142 --- /dev/null +++ b/files/0001-reporegistry-serve-x86_64_v2-RPMs-on-AlmaLinux-10-x8.patch @@ -0,0 +1,148 @@ +From 3d3e7853498060534ba388d67a921952f6aa11be Mon Sep 17 00:00:00 2001 +From: Eduard Abdullin +Date: Wed, 13 May 2026 15:30:00 +0300 +Subject: [PATCH] reporegistry: serve x86_64_v2 RPMs on AlmaLinux 10 x86_64_v2 + hosts + +What +---- +On a host running the AlmaLinux 10 x86_64_v2 build variant +(`/etc/os-release` ID=almalinux, glibc RPM arch == x86_64_v2), +RepoRegistry.reposByDistroArch() rewrites the baseurl of every +AlmaLinux 10 / AlmaLinux Kitten 10 x86_64 repository entry from +`/x86_64/os/` to `/x86_64_v2/os/` before returning it to the caller. +arch="x86_64" is still propagated through the manifest, distrodefs +and the rest of the stack — only the source URLs of the RPMs change. + +Why +--- +osbuild-composer ships a single x86_64 repo block per distro JSON, +which on AlmaLinux 10 points at the v3-baseline RPMs (the default +variant). When osbuild-composer runs on the AlmaLinux 10 x86_64_v2 +variant of the OS, the build chroot pulls those v3 RPMs and exec() +of v3 glibc aborts on a v2-only CPU with "CPU does not support +x86-64-v3" — so the build never completes. + +We need the build to fetch the matching x86_64_v2 RPMs from +repo.almalinux.org/almalinux/10/*/x86_64_v2/os/ (and +kitten.repo.almalinux.org/10-kitten/*/x86_64_v2/os/) on v2 hosts, +without forking the arch enum, the distro YAMLs, every consumer +of arch.Current() or the on-disk repos JSON files. + +How +--- +* New helper `hostIsX8664V2()` queries the host glibc RPM arch + once (cached) and returns true when it is exactly "x86_64_v2"; + on non-amd64 hosts or when rpm is unavailable it returns false, + preserving legacy behaviour. + +* New helper `distroHasX8664V2Variant(distro)` whitelists + AlmaLinux 10+ and AlmaLinux Kitten 10+ — these are the only + AlmaLinux releases that ship a /x86_64_v2/ repository tree. + AlmaLinux 8/9 (no v2 variant). + +* New helper `rewriteBaseurlsTov2()` returns a copy of the repo + slice with each BaseURLs entry's first "/x86_64/" substituted + by "/x86_64_v2/". The original registry data is not mutated. + +* `reposByDistroArch()` is the single dispatch point for every + ReposBy* lookup. After the standard lookup, when all three + conditions are met (arch == "x86_64", host is v2, distro has + a v2 variant) it returns the rewritten copy instead of the raw + block. + +No JSON / spec / distrodef changes are required. The fix is local +to one function; on v3 hosts and non-AlmaLinux distros the new +code path is a no-op. + +Verified end-to-end on a real AlmaLinux Kitten 10 x86_64_v2 VM: +composer-cli compose start test-base qcow2 -> FINISHED, all +bash/glibc/kernel/systemd/libgcc packages in the produced image +carry arch x86_64_v2; the compose-tests legacy/p_osbuild test +passes with the upstream SKIP-on-v2 guard removed. + +Signed-off-by: Eduard Abdullin +--- + .../images/pkg/reporegistry/reporegistry.go | 53 +++++++++++++++++++ + 1 file changed, 53 insertions(+) + +diff --git a/vendor/github.com/osbuild/images/pkg/reporegistry/reporegistry.go b/vendor/github.com/osbuild/images/pkg/reporegistry/reporegistry.go +index da083b9..35142e2 100644 +--- a/vendor/github.com/osbuild/images/pkg/reporegistry/reporegistry.go ++++ b/vendor/github.com/osbuild/images/pkg/reporegistry/reporegistry.go +@@ -4,6 +4,9 @@ import ( + "errors" + "fmt" + "io/fs" ++ "os/exec" ++ "runtime" ++ "strings" + + "github.com/osbuild/images/pkg/distroidparser" + "github.com/osbuild/images/pkg/rpmmd" +@@ -99,6 +102,52 @@ func (r *RepoRegistry) ReposByArchName(distro, arch string, includeTagged bool) + return repositories, nil + } + ++var ( ++ hostIsX8664V2Cache bool ++ hostIsX8664V2Resolved bool ++) ++ ++func hostIsX8664V2() bool { ++ if hostIsX8664V2Resolved { ++ return hostIsX8664V2Cache ++ } ++ hostIsX8664V2Resolved = true ++ if runtime.GOARCH != "amd64" { ++ return false ++ } ++ out, err := exec.Command("rpm", "-q", "--qf", "%{ARCH}", "glibc").Output() ++ if err != nil { ++ return false ++ } ++ hostIsX8664V2Cache = strings.TrimSpace(string(out)) == "x86_64_v2" ++ return hostIsX8664V2Cache ++} ++ ++func distroHasX8664V2Variant(distro string) bool { ++ switch { ++ case strings.HasPrefix(distro, "almalinux-10"): ++ return true ++ case strings.HasPrefix(distro, "almalinux_kitten-10"): ++ return true ++ } ++ return false ++} ++ ++func rewriteBaseurlsTov2(src []rpmmd.RepoConfig) []rpmmd.RepoConfig { ++ out := make([]rpmmd.RepoConfig, len(src)) ++ for i, r := range src { ++ out[i] = r ++ if len(r.BaseURLs) > 0 { ++ urls := make([]string, len(r.BaseURLs)) ++ for j, u := range r.BaseURLs { ++ urls[j] = strings.Replace(u, "/x86_64/", "/x86_64_v2/", 1) ++ } ++ out[i].BaseURLs = urls ++ } ++ } ++ return out ++} ++ + // reposByDistroArch returns the repositories for the distro+arch + func (r *RepoRegistry) reposByDistroArch(distro, arch string) ([]rpmmd.RepoConfig, error) { + // compatibility layer to support old repository definition filenames +@@ -117,6 +166,10 @@ func (r *RepoRegistry) reposByDistroArch(distro, arch string) ([]rpmmd.RepoConfi + return nil, fmt.Errorf("%w: for distribution %q and architecture %q", ErrNoRepoFound, stdDistroName, arch) + } + ++ if arch == "x86_64" && hostIsX8664V2() && distroHasX8664V2Variant(stdDistroName) { ++ repos = rewriteBaseurlsTov2(repos) ++ } ++ + return repos, nil + } + +-- +2.51.0