Skip to content

Add libkrun, libkrunfw, and build deps cpio + pyelftools - #271

Merged
norrietaylor merged 1 commit into
mainfrom
add-libkrun-libkrunfw
Jun 18, 2026
Merged

Add libkrun, libkrunfw, and build deps cpio + pyelftools#271
norrietaylor merged 1 commit into
mainfrom
add-libkrun-libkrunfw

Conversation

@norrietaylor

@norrietaylor norrietaylor commented Jun 18, 2026

Copy link
Copy Markdown
Member

Packages the libkrun KVM backend and its libkrunfw guest-kernel firmware (from gominimal/minimal's scripts/build-libkrun.sh), plus two missing build dependencies.

Packages

Package Version Role
libkrun 1.19.0 KVM backend, built --features blk
libkrunfw 5.5.0 Guest kernel firmware (bundles linux-6.12.91)
pyelftools 0.33 Build dep — bin2cbundle.py imports elftools
cpio 2.15 Build dep — kernel CONFIG_IKHEADERS needs it

Design

  • Two packages, not one. The script builds two distinct upstreams (containers/libkrunfw, containers/libkrun); libkrunfw is a dependency of libkrun.
  • libkrunfw is a runtime dep, not a link dep. libkrun dlopen()s libkrunfw.so.5 via libloading (src/libkrun/src/lib.rs), so it is in runtime_deps, not build_deps.
  • clang/libclang dropped. bindgen only feeds the input/display crates, which --features blk does not pull in.
  • Kernel tarball vendored as a second Source in libkrunfw, so the firmware build is hermetic. libkrun keeps needs.internet for cargo.

Build notes

  • cpio 2.15's K&R int xstat() breaks under GCC's C23 default → -std=gnu17.
  • ftp.gnu.org 403s the sandbox fetcher → cpio sourced from mirrors.kernel.org (byte-identical).
  • Both Makefiles link the final .so with bare cc (absent in sandbox) → CC=gcc, and install to lib64 by default → LIBDIR_Linux=lib override (keeps the .pc libdir consistent).

Verification

All four built via min patched-pkg and pass min check (50 checks, 0 failures) on the compiled outputs.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features
    • Added support for building cpio (v2.15)
    • Added support for building libkrun (v1.19.0)
    • Added support for building libkrunfw (v5.5.0)
    • Added support for building pyelftools (v0.33)

Packages the libkrun KVM backend and its libkrunfw guest-kernel firmware
(from gominimal/minimal's scripts/build-libkrun.sh), plus two missing
build dependencies.

- libkrun 1.19.0: built `--features blk` (exports krun_add_disk2).
  libkrunfw is dlopen()ed at runtime, so it is a runtime_dep, not a link
  dep. bindgen/libclang dropped (only feeds input/display crates, not blk).
- libkrunfw 5.5.0: compiles linux-6.12.91 into the firmware .so. Kernel
  tarball vendored as a Source so the build is hermetic.
- pyelftools 0.33: bin2cbundle.py imports elftools.
- cpio 2.15: required by the kernel's CONFIG_IKHEADERS. Built -std=gnu17
  for GCC's C23 default; sourced from mirrors.kernel.org (ftp.gnu.org
  403s the fetcher).

Both Makefiles install to lib (LIBDIR_Linux=lib override) and link with
CC=gcc since the sandbox has no cc symlink.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds four new package build definitions forming a dependency chain: cpio (GNU archiver, v2.15) and pyelftools (Python ELF parser, v0.33) are leaf packages consumed at build time by libkrunfw (v5.5.0, wraps a vendored Linux kernel), which is in turn a build and runtime dependency of libkrun (v1.19.0, lightweight virtualization library).

Changes

New package chain: cpio → pyelftools → libkrunfw → libkrun

Layer / File(s) Summary
cpio package spec and build script
packages/cpio/build.ncl, packages/cpio/build.sh
Defines the cpio 2.15 BuildSpec with a pinned GNU source tarball, glibc runtime dep, arch-aware CFLAGS (x86_64/aarch64), standard configure/make/install steps, output globs for the binary and manpages, source provenance, and a standaloneTest smoketest running /bin/cpio --version.
pyelftools package spec and build script
packages/pyelftools/build.ncl, packages/pyelftools/build.sh
Defines the pyelftools 0.33 BuildSpec with a pinned GitHub source tarball, python/setuptools runtime deps, pip3 wheel build into dist/ followed by offline pip3 install into $OUTPUT_DIR, output globs for site-packages contents and .dist-info metadata, and source provenance.
libkrunfw package spec and build script
packages/libkrunfw/build.ncl, packages/libkrunfw/build.sh
Defines the libkrunfw 5.5.0 BuildSpec importing cpio, pyelftools, and a broad set of toolchain deps; vendors a pinned linux-6.12.91.tar.xz as a hermetic Source; build script stages the kernel tarball into tarballs/, runs make CC=gcc -j$(nproc), and installs to $OUTPUT_DIR with LIBDIR_Linux=lib PREFIX=/usr.
libkrun package spec and build script
packages/libkrun/build.ncl, packages/libkrun/build.sh
Defines the libkrun 1.19.0 BuildSpec with a GitHub source tarball, rust/pkgconf/make/libkrunfw build deps, glibc+libkrunfw+gcc runtime deps, dns/internet build requirements; build script forces CC=gcc, sets RUSTFLAGS with linker and path-remap options, builds with BLK=1, and installs library, headers, and pkg-config file.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • twitchyliquid64

Poem

🐰 Hop hop, four packages appear today,
cpio and pyelftools lead the way,
libkrunfw wraps a kernel with care,
libkrun builds a VM from thin air,
The rabbit stamps SHA256 with delight — hermetic and fair! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding four packages (libkrun, libkrunfw, cpio, and pyelftools) to support the libkrun KVM backend.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-libkrun-libkrunfw

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cpio/build.sh`:
- Line 2: In the build.sh file, replace the `set -ex` command at the beginning
of the script with `set -euo pipefail`. The `-u` flag ensures unset variables
cause an error, the `-o pipefail` option makes pipe operations fail if any
command in the pipeline fails, and this combination provides the strict error
handling and variable expansion required for build scripts.

In `@packages/libkrun/build.sh`:
- Line 2: Update the shell options at the beginning of the build script from
`set -ex` to `set -euo pipefail` to enforce strict mode that includes error
handling for unset variables and pipeline failures. This ensures the build
script follows the required guidelines by making it exit on any error, treating
unset variables as an error, and ensuring pipelines fail if any command in the
pipeline fails.

In `@packages/libkrunfw/build.sh`:
- Around line 18-20: The make commands for kernel build do not export the
required KBUILD_* environment variables needed for reproducible builds. Before
executing both the make command on line 18 and the make install command on line
20, export the three required variables: KBUILD_BUILD_TIMESTAMP set to `@0`,
KBUILD_BUILD_USER set to builder, and KBUILD_BUILD_HOST set to minimal. These
can be exported as environment variables before the make commands or passed
directly to each make invocation to ensure deterministic kernel build metadata.
- Line 2: Replace the `set -ex` command at the beginning of the build.sh script
with `set -euo pipefail`. The current flags only enable echo mode and exit on
error, but the `-u` flag is needed to error on undefined variables and `-o
pipefail` is needed to ensure the script exits on failures within piped
commands, which aligns with the project's coding guidelines for shell scripts.

In `@packages/pyelftools/build.ncl`:
- Around line 26-31: The build specification in the pyelftools package is
missing the build_args field needed to forward the version variable to the build
script. Add a build_args field with the value { include version } at the same
level as the existing cmd and outputs fields to forward the version variable to
the build script as an environment variable for build consistency.

In `@packages/pyelftools/build.sh`:
- Around line 4-5: The Python build steps in the build.sh script are missing
reproducibility environment variables. Before the first pip3 wheel command,
export SOURCE_DATE_EPOCH=0 and PYTHONHASHSEED=0 environment variables to ensure
consistent builds across different environments and eliminate non-deterministic
behavior from Python's build process.
- Line 2: The build script in packages/pyelftools/build.sh uses set -ex on line
2, but this does not properly handle unset variables or pipe failures. Replace
the set -ex line with set -euo pipefail to enable strict mode with proper error
handling for unset variables (u flag) and pipe failures (o pipefail flag),
ensuring the script follows the build script guidelines.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c0983b25-082f-4690-bcea-f155d143eeab

📥 Commits

Reviewing files that changed from the base of the PR and between 724c7ad and 8c0efa9.

📒 Files selected for processing (8)
  • packages/cpio/build.ncl
  • packages/cpio/build.sh
  • packages/libkrun/build.ncl
  • packages/libkrun/build.sh
  • packages/libkrunfw/build.ncl
  • packages/libkrunfw/build.sh
  • packages/pyelftools/build.ncl
  • packages/pyelftools/build.sh

Comment thread packages/cpio/build.sh
Comment thread packages/libkrun/build.sh
Comment thread packages/libkrunfw/build.sh
Comment thread packages/libkrunfw/build.sh
Comment thread packages/pyelftools/build.ncl
Comment thread packages/pyelftools/build.sh
Comment thread packages/pyelftools/build.sh
@norrietaylor

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@norrietaylor
norrietaylor added this pull request to the merge queue Jun 18, 2026
Merged via the queue into main with commit 087287e Jun 18, 2026
4 checks passed
@norrietaylor
norrietaylor deleted the add-libkrun-libkrunfw branch June 18, 2026 04:45
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