-
Notifications
You must be signed in to change notification settings - Fork 192
loader-entries: Add set-options-for-source for source-tracked kargs #2114
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
Draft
jmarrero
wants to merge
2
commits into
bootc-dev:main
Choose a base branch
from
jmarrero:kargs-source
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,16 @@ buildroot_base := env("BOOTC_buildroot_base", "quay.io/centos/centos:stream10") | |
| extra_src := env("BOOTC_extra_src", "") | ||
| # Set to "1" to disable auto-detection of local Rust dependencies | ||
| no_auto_local_deps := env("BOOTC_no_auto_local_deps", "") | ||
| # Optional: path to an ostree source tree to build and inject into the image. | ||
| # When set, ostree is built from source inside a container matching the base | ||
| # image distro, and the resulting RPMs override the stock ostree packages in | ||
| # both the buildroot (so bootc links against the patched libostree) and the | ||
| # final image. This pattern can be reused for other dependency overrides. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. Yeah, tricky. I'm ok to special case this one for now, but...OTOH...it really generalizes fast. Seems like it'd be cleanest with a cosa-style |
||
| # Example: BOOTC_ostree_src=/path/to/ostree just build | ||
| ostree_src := env("BOOTC_ostree_src", "") | ||
| # Version to assign to the override ostree RPMs. This should be set to the | ||
| # next unreleased ostree version so the override is always newer than stock. | ||
| ostree_version := env("BOOTC_ostree_version", "2026.1") | ||
|
|
||
| # Internal variables | ||
| nocache := env("BOOTC_nocache", "") | ||
|
|
@@ -64,13 +74,14 @@ buildargs := base_buildargs \ | |
|
|
||
| # Build container image from current sources (default target) | ||
| [group('core')] | ||
| build: package _keygen && _pull-lbi-images | ||
| build: _build-ostree-rpms package _keygen && _pull-lbi-images | ||
| #!/bin/bash | ||
| set -xeuo pipefail | ||
| test -d target/packages | ||
| pkg_path=$(realpath target/packages) | ||
| ostree_pkg_path=$(realpath target/ostree-packages) | ||
| eval $(just _git-build-vars) | ||
| podman build {{_nocache_arg}} --build-arg=image_version=${VERSION} --build-context "packages=${pkg_path}" -t {{base_img}} {{buildargs}} . | ||
| podman build {{_nocache_arg}} --build-arg=image_version=${VERSION} --build-context "packages=${pkg_path}" --build-context "ostree-packages=${ostree_pkg_path}" -t {{base_img}} {{buildargs}} . | ||
|
|
||
| # Show available build variants and current configuration | ||
| [group('core')] | ||
|
|
@@ -321,7 +332,9 @@ package: | |
| if [[ -z "{{no_auto_local_deps}}" ]]; then | ||
| local_deps_args=$(cargo xtask local-rust-deps) | ||
| fi | ||
| podman build {{base_buildargs}} --build-arg=SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} --build-arg=pkgversion=${VERSION} -t localhost/bootc-pkg --target=build $local_deps_args . | ||
| mkdir -p target/ostree-packages | ||
| ostree_pkg_path=$(realpath target/ostree-packages) | ||
| podman build {{base_buildargs}} --build-arg=SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} --build-arg=pkgversion=${VERSION} --build-context "ostree-packages=${ostree_pkg_path}" -t localhost/bootc-pkg --target=build $local_deps_args . | ||
| mkdir -p "${packages}" | ||
| rm -vf "${packages}"/*.rpm | ||
| podman run --rm localhost/bootc-pkg tar -C /out/ -cf - . | tar -C "${packages}"/ -xvf - | ||
|
|
@@ -359,6 +372,28 @@ _git-build-vars: | |
| echo "SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}" | ||
| echo "VERSION=${VERSION}" | ||
|
|
||
| # Build ostree RPMs from source if BOOTC_ostree_src is set. | ||
| # The RPMs are built inside a container matching the base image distro. | ||
| # When BOOTC_ostree_src is not set, this creates an empty directory (no-op). | ||
| _build-ostree-rpms: | ||
| #!/bin/bash | ||
| set -xeuo pipefail | ||
| mkdir -p target/ostree-packages | ||
| if [ -z "{{ostree_src}}" ]; then exit 0; fi | ||
| echo "Building ostree {{ostree_version}} from source: {{ostree_src}}" | ||
| rm -f target/ostree-packages/*.rpm | ||
| podman build \ | ||
| --build-context ostree-src={{ostree_src}} \ | ||
| --build-arg=base={{base}} \ | ||
| --build-arg=ostree_version={{ostree_version}} \ | ||
| -t localhost/ostree-build \ | ||
| -f contrib/packaging/Dockerfile.ostree-override . | ||
| cid=$(podman create localhost/ostree-build) | ||
| podman cp "${cid}:/" target/ostree-packages/ | ||
| podman rm "${cid}" | ||
| echo "ostree override RPMs:" | ||
| ls -la target/ostree-packages/ | ||
|
|
||
| _keygen: | ||
| ./hack/generate-secureboot-keys | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| # Build ostree RPMs from source, matching the base image distro. | ||
| # | ||
| # This Dockerfile is used by the BOOTC_ostree_src mechanism in the Justfile | ||
| # to build a patched ostree and inject it into the bootc test image. It builds | ||
| # ostree RPMs inside a container matching the base image so the resulting RPMs | ||
| # are compatible with the target distro. | ||
| # | ||
| # The ostree source is provided via the `ostree-src` build context. | ||
| # The version is overridden to ensure the built RPMs are always newer than | ||
| # the stock packages. | ||
| # | ||
| # Usage (via Justfile): | ||
| # BOOTC_ostree_src=/path/to/ostree just build | ||
| # | ||
| # Direct usage: | ||
| # podman build --build-context ostree-src=/path/to/ostree \ | ||
| # --build-arg=base=quay.io/centos-bootc/centos-bootc:stream10 \ | ||
| # --build-arg=ostree_version=2026.1 \ | ||
| # -f contrib/packaging/Dockerfile.ostree-override . | ||
|
|
||
| ARG base=quay.io/centos-bootc/centos-bootc:stream10 | ||
|
|
||
| FROM $base as ostree-build | ||
| # Install ostree build dependencies | ||
| RUN <<EORUN | ||
| set -xeuo pipefail | ||
| . /usr/lib/os-release | ||
| case "${ID}${ID_LIKE:-}" in | ||
| *centos*|*rhel*) | ||
| dnf config-manager --set-enabled crb | ||
| ;; | ||
| esac | ||
| dnf -y builddep ostree | ||
| dnf -y install git rpm-build autoconf automake libtool make xz | ||
| EORUN | ||
|
|
||
| # Copy ostree source from build context | ||
| COPY --from=ostree-src / /ostree-src | ||
| WORKDIR /ostree-src | ||
|
|
||
| # Build ostree RPMs with the specified version | ||
| ARG ostree_version=2026.1 | ||
| RUN <<EORUN | ||
| set -xeuo pipefail | ||
| git config --global --add safe.directory /ostree-src | ||
|
|
||
| # Initialize submodules if needed | ||
| if ! test -f libglnx/README.md || ! test -f bsdiff/README.md; then | ||
| git submodule update --init | ||
| fi | ||
|
|
||
| # Clean up any stale build artifacts from the source tree | ||
| rm -rf ostree-distgit *.tar.xz *.src.rpm x86_64/ ostree.spec | ||
|
|
||
| # Create source tarball with the target version as the directory prefix. | ||
| # We can't use ci/make-git-snapshot.sh because it hardcodes the directory | ||
| # name from git-describe, which won't match our overridden version. | ||
| GITREV=$(git rev-parse HEAD) | ||
| PKG_VER="libostree-${ostree_version}" | ||
| git archive --format=tar --prefix="${PKG_VER}/" "${GITREV}" > "${PKG_VER}.tar.tmp" | ||
| git submodule status | while read line; do | ||
| rev=$(echo ${line} | cut -f 1 -d ' ') | ||
| path=$(echo ${line} | cut -f 2 -d ' ') | ||
| (cd "${path}"; git archive --format=tar --prefix="${PKG_VER}/${path}/" "${rev}") > submodule.tar | ||
| tar -A -f "${PKG_VER}.tar.tmp" submodule.tar | ||
| rm submodule.tar | ||
| done | ||
| mv "${PKG_VER}.tar.tmp" "${PKG_VER}.tar" | ||
| xz "${PKG_VER}.tar" | ||
|
|
||
| # Get spec file: use local one if present, otherwise fetch from dist-git | ||
| if ! test -f ostree.spec; then | ||
| rm -rf ostree-distgit | ||
| . /usr/lib/os-release | ||
| case "${ID}" in | ||
| centos|rhel) | ||
| git clone --depth=1 https://gitlab.com/redhat/centos-stream/rpms/ostree.git ostree-distgit || \ | ||
| git clone --depth=1 https://src.fedoraproject.org/rpms/ostree ostree-distgit | ||
| ;; | ||
| *) | ||
| git clone --depth=1 https://src.fedoraproject.org/rpms/ostree ostree-distgit | ||
| ;; | ||
| esac | ||
| cp ostree-distgit/ostree.spec . | ||
| fi | ||
|
|
||
| # Set the target version and strip any distro patches | ||
| sed -i -e '/^Patch/d' -e "s,^Version:.*,Version: ${ostree_version}," ostree.spec | ||
|
|
||
| # Build SRPM | ||
| ci/rpmbuild-cwd -bs ostree.spec | ||
|
|
||
| # Install any missing build deps from the SRPM | ||
| if test "$(id -u)" = 0; then | ||
| dnf builddep -y *.src.rpm | ||
| fi | ||
|
|
||
| # Build binary RPMs | ||
| ci/rpmbuild-cwd --rebuild *.src.rpm | ||
|
|
||
| # Collect the RPMs we need | ||
| mkdir -p /out | ||
| cp x86_64/ostree-${ostree_version}*.rpm \ | ||
| x86_64/ostree-libs-${ostree_version}*.rpm \ | ||
| x86_64/ostree-devel-${ostree_version}*.rpm \ | ||
| /out/ | ||
| echo "Built ostree override RPMs:" | ||
| ls -la /out/ | ||
| EORUN | ||
|
|
||
| # Final stage: just the RPMs | ||
| FROM scratch | ||
| COPY --from=ostree-build /out/ / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this one looks not at all ostree specific.
BTW...since right now we always build a "from scratch" image the other way we could do this is synthesize a dnf repo with a priority I think