Skip to content

Commit ae0e86a

Browse files
committed
cmdlib.sh: add support for a fast-tracks.yaml in src config
We often want to be able to fast-track packages from later releases into earlier composes. But we can't just enable the whole repo because that'll pull in *every* package. So far, we've taken the approach of (1) asking ART to tag some package in the plashet, and then (2) add that package under a copy of the plashet definition in its `includepkgs=` directive so that it effectively becomes a "RHEL-versioned" view of the plashet. The problems with that are: 1. It's painful and slow to have to routinely tag packages via request tickets. 2. It's error-prone. Nothing prevents rpm-ostree from still picking an rhaos version of the package if it's higher NEVRA. 3. It's extremely painful to keep the production repo definitions and the CI definitions in sync. In practice, they just go out of skew. 4. It splits apart the definition of the packages that are being fast-tracked from the rest of the manifests. Let's just teach cosa to do this for us a better way. This patch add a new `fast-tracks.yaml` concept which can live in the source config repo, and which can then describe which packages to fast-tracks from which repos. cosa will then create a "filtered view" of those repos for us that can then be used as usual in the manifests. Example `fast-tracks.yaml` file: ```yaml rhel-9-appstream-fast-tracks: from: rhel-9-appstream packages: - ignition* ``` This will define a yum repo with id `rhel-9-appstream-fast-tracks` that's identical to `rhel-9-appstream`, but has `includepkgs=ignition*`. (In this theoretical example, `rhel-9-appstream` is the nightly RHEL compose still hooked to c9s. But it's equally useful to pull from e.g. 9.7 in the future for example.) I'm not super proud of this. But I do think it's still better than what we're currently doing.
1 parent b45a406 commit ae0e86a

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/cmdlib.sh

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ with open('$destination', 'w') as outfile:
372372
#
373373
# This function commits the contents of overlay.d/ as well
374374
# as overrides/{rootfs} to OSTree commits, and also handles
375-
# overrides/rpm.
375+
# overrides/rpm and fast-track repos.
376376
prepare_compose_overlays() {
377377
local with_cosa_overrides=1
378378
while [ $# -gt 0 ]; do
@@ -399,7 +399,7 @@ prepare_compose_overlays() {
399399
exit 1
400400
fi
401401

402-
if [ -d "${overridesdir}" ] || [ -d "${ovld}" ] || [ -d "${workdir}/src/yumrepos" ]; then
402+
if [ -d "${overridesdir}" ] || [ -d "${ovld}" ] || [ -d "${workdir}/src/yumrepos" ] || [ -e "${configdir}/fast-tracks.yaml" ]; then
403403
rm -rf "${tmp_overridesdir}"
404404
mkdir "${tmp_overridesdir}"
405405
cat > "${override_manifest}" <<EOF
@@ -501,6 +501,37 @@ EOF
501501
rm -vf "${local_overrides_lockfile}"
502502
fi
503503

504+
if [ -f "${configdir}/fast-tracks.yaml" ]; then
505+
cat "${tmp_overridesdir}"/*.repo > "${tmp_overridesdir}/all.repo"
506+
# shellcheck disable=SC2002
507+
cat "${configdir}/fast-tracks.yaml" | python3 -c "
508+
import sys, yaml, subprocess, glob
509+
fast_tracks = yaml.safe_load(sys.stdin)
510+
for (repo, spec) in fast_tracks.items():
511+
with open(f'${tmp_overridesdir}/{repo}.repo', 'w') as f:
512+
# yeah this is technically wasteful that we're reopening and scanning on each iteration. meh...
513+
with open('${tmp_overridesdir}/all.repo') as g:
514+
passthrough = False
515+
for line in g:
516+
line = line.strip()
517+
if line == f'[{spec['from']}]':
518+
line = f'[{repo}]'
519+
# we're in the repo definition
520+
passthrough = True
521+
elif passthrough and line.startswith('name='):
522+
line = f'name={repo}'
523+
elif line.startswith('['):
524+
# we left the repo definition
525+
if passthrough:
526+
break
527+
if passthrough:
528+
f.write(line + '\n')
529+
f.write('includepkgs=' + ','.join(spec['packages']) + '\n')
530+
"
531+
rm "${tmp_overridesdir}/all.repo"
532+
fi
533+
534+
504535
contentset_path=""
505536
if [ -e "${configdir}/content_sets.yaml" ]; then
506537
contentset_path="${configdir}/content_sets.yaml"

0 commit comments

Comments
 (0)