Skip to content

Commit 634b306

Browse files
committed
ART: Use rpm-ostree --repo with YUM_REPO_NAMES for extensions
Similar to the node image build (PR openshift#1935), modify the extensions build to use --repo="${YUM_REPO_NAMES}" instead of relying on hardcoded repo names in the extensions yaml files. Changes: - extensions/Containerfile: Add YUM_REPO_NAMES build arg - extensions/build.sh: Mount repos, strip repos: sections from yaml, use --repo flag with rpm-ostree compose extensions - extensions/build-args-*.conf: Define YUM_REPO_NAMES for each RHEL version This allows ART to inject the correct repo names (e.g., rhel-9-baseos-rpms) instead of the extensions yaml files using version-specific names (e.g., rhel-9.8-baseos) that don't match what ART provides. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED
1 parent d75a447 commit 634b306

4 files changed

Lines changed: 35 additions & 1 deletion

File tree

extensions/Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ WORKDIR /os
66
ADD . .
77
ARG OPENSHIFT_CI=0
88
ARG OPENSHIFT_VERSION=overridden
9+
ARG YUM_REPO_NAMES=overridden
910
RUN --mount=type=secret,id=yumrepos,target=/os/secret.repo extensions/build.sh
1011

1112
## Creates the repo metadata for the extensions.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
OPENSHIFT_VERSION=5.0
2+
3+
# The names of the yum repos to use for the extensions build.
4+
YUM_REPO_NAMES=rhel-10.2-baseos,rhel-10.2-appstream,rhel-10.2-fast-datapath,rhel-10.2-server-ose-5.0

extensions/build-args-9.8-5.0.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
OPENSHIFT_VERSION=5.0
2+
3+
# The names of the yum repos to use for the extensions build.
4+
YUM_REPO_NAMES=rhel-9.8-baseos,rhel-9.8-appstream,rhel-9.8-fast-datapath,rhel-9.8-server-ose-5.0,rhel-9.8-nfv,rhel-9.8-highavailability

extensions/build.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,41 @@ if [ "${OPENSHIFT_CI}" != 0 ]; then
66
ci/get-ocp-repo.sh ocp.repo
77
fi
88

9+
# add all the repos from the current directory (including mounted in secret.repo)
10+
# into `/etc/yum.repos.d` so dnf sees them
11+
cat /os/*.repo >> /etc/yum.repos.d/git.repo
12+
913
# just to parse the treefile, rpm-ostree still wants to read referenced "externals" (e.g. passwd, group)
1014
# hack around this for now by deleting the problematic bits; we should tweak rpm-ostree instead
1115
jq 'del(.["check-passwd","check-groups"])' /usr/share/rpm-ostree/treefile.json > filtered.json
1216

13-
1417
. /etc/os-release
1518
extensions_yaml="extensions/${ID}-${VERSION_ID}.yaml"
1619
# Replace the __OCP_VERSION__ placeholder with the actual OpenShift version.
1720
# This allows the same YAML file to be used across different OCP versions
1821
# (e.g. 4.23 and 5.0) without duplication.
1922
sed -i "s/__OCP_VERSION__/${OPENSHIFT_VERSION}/g" "$extensions_yaml"
23+
24+
# Strip out any repos: sections from the extensions yaml file since we'll
25+
# use --repo instead to specify repos explicitly via YUM_REPO_NAMES
26+
python3 <<EOF
27+
import yaml
28+
29+
with open('$extensions_yaml', 'r') as fh:
30+
d = yaml.safe_load(fh)
31+
32+
# Remove top-level repos section
33+
d.pop('repos', None)
34+
35+
# Remove repos sections from individual extensions
36+
for ext in d.get('extensions', {}).values():
37+
if isinstance(ext, dict):
38+
ext.pop('repos', None)
39+
40+
with open('$extensions_yaml', 'w') as fh:
41+
yaml.dump(d, fh, default_flow_style=False)
42+
EOF
43+
2044
rpm-ostree compose extensions filtered.json "$extensions_yaml" \
45+
--repo="${YUM_REPO_NAMES}" \
2146
--rootfs=/ --output-dir=/usr/share/rpm-ostree/extensions/

0 commit comments

Comments
 (0)