Skip to content

cmd-build-with-buildah: enhance version handling, add yumrepos support, add autolocking #4249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 12, 2025

Conversation

jlebon
Copy link
Member

@jlebon jlebon commented Aug 8, 2025

See individual commit messages

jlebon added 5 commits August 8, 2025 15:40
This drops a cmdlib.sh Python-baked function.
The `variant` variable is set by `prepare_build`, which we're purposely
not calling here.
This is for coreos/fedora-coreos-tracker#1996.
I initially wanted to just add another `LABEL` to our Containerfile
and hook that up to another build arg, but the problem is that our
Containerfile is shared with RHCOS/SCOS and there's no way to make
`LABEL` directives conditional.

I opened coreos/rpm-ostree#5454 which will fix
this but for now to not block on this, let's just slap it on from the
cosa side. Once it's folded back into the build process proper, then we
can rever this. But the label not existing shouldn't really affect the
majority of developers anyway.
I think it's still useful to have a `dev` marker in the version string
for development builds.

The versionary script recently learned a new `--dev` switch which will
spit out a development version string. Let's tweak the logic so that:
- by default, if `--versionary` is not passed, we call `versionary
  --dev` to get a development version string
- if `--versionary` is passed, we _don't_ pass `--dev` to get a
  production version string
- if `--version` is passed, it always wins

This is a bit confusing of course. E.g. ideally the `--versionary`
switch would be called `--prod-versionary` or something. But the intent
is to replicate the UX that exists today with `cosa build` so that this
becomes a drop-in replacement for it in the pipeline.

Once we cut over and don't need to support both, we could tweak things.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances version handling in cmd-build-with-buildah and adds support for yumrepos. The changes are generally good, introducing more explicit control over versioning and simplifying build existence checks. My review focuses on improving the robustness of the new logic, particularly around handling configuration values and file dependencies. I've suggested modifications to prevent silent failures with invalid configuration and to provide clearer error messages when required files are missing.

@jlebon jlebon force-pushed the pr/build-with-buildah-tweaks branch from 9ddd584 to 9908fb8 Compare August 10, 2025 17:35
@jlebon jlebon changed the title cmd-build-with-buildah: enhance version handling, add yumrepos support cmd-build-with-buildah: enhance version handling, add yumrepos support, add autolocking Aug 10, 2025
dustymabe
dustymabe previously approved these changes Aug 11, 2025
Copy link
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested this yet, but looks good to me.

# Apply autolock from another build for this version (or for another version if
# explicitly provided via --autolock) if no base lockfile exists.
lockfile="manifest-lock.${arch}.json"
if [ ! -f "src/config/${lockfile}" ] && { [ -n "${VERSION}" ] || [ -n "${AUTOLOCK_VERSION}" ]; }; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another way to do this that avoids the awkward {} but not sure it's better:

Suggested change
if [ ! -f "src/config/${lockfile}" ] && { [ -n "${VERSION}" ] || [ -n "${AUTOLOCK_VERSION}" ]; }; then
if [ ! -f "src/config/${lockfile}" ] && [ -n "${VERSION:-}${AUTOLOCK_VERSION:-}" ]; then

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree it's awkward. Not sure it's better either. :) That one is mostly copy/pasted from cmd-build so I'll keep it as is for consistency.

Comment on lines +73 to +77
if [ -z "${VERSIONARY}" ]; then
VERSION=$(src/config/versionary --dev)
else
VERSION=$(src/config/versionary)
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if another option here in the future is just drop the versionary switch at all and add a --prod or --pipeline switch and we'd just add that when we run in the pipeline similar to how we add --versionary in the pipeline today.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, absolutely. I mentioned this in the commit message. The --versionary switch is awkwardly named now, but trying to keep it "pipeline compatible" to minimize changes that would be needed there. But once we cut over, we could simplify things, yeah.

jlebon added 4 commits August 11, 2025 16:48
If there's a yumrepos source, hook that up to the build so that it
has access to the repo contents and the contentset. Also just mount in
`/etc/pki/ca-trust` because the repos may require a cert.
This is equivalent to `cosa build` which also runs `cosa prune` at the
end.
This matches `cosa build`, but also this is required for autolocking,
which makes use of this.
This matches `cosa build` support for it and is actively used by both
RHCOS and FCOS (rawhide).

Long-term I think this will become obsolete by hermetic builds in
Konflux which will require us to always have in-tree lockfiles.
@jlebon jlebon merged commit ca2dc2c into coreos:main Aug 12, 2025
6 checks passed
@jlebon jlebon deleted the pr/build-with-buildah-tweaks branch August 12, 2025 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants