feat: Add ext4 image creation - #16
Conversation
These images are handy when running integration tests targeting Linux.
976324b to
b127876
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Starlark rule to build Linux ext4 filesystem images (without journaling) for use in integration tests (e.g., attaching as a secondary QEMU disk), and updates repo documentation and Bazel versioning to align with other S-CORE repos.
Changes:
- Add
ext4Bazel rule (rules/linux/ext4.bzl) to construct an ext4 image fromrules_pkginputs. - Add a Bazel
sh_testvalidating the image contents and symlink behavior viadebugfs/tune2fs. - Update documentation and Bazel version/lockfile to reflect the new rule and Bazel 8.6.0.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
rules/linux/ext4.bzl |
Adds the new ext4 rule implementation that stages files/symlinks and runs mke2fs to produce an ext4 image. |
rules/linux/BUILD |
Exports ext4.bzl for external loading. |
rules/linux/test/BUILD |
Adds a small test package that builds an ext4 image and verifies it via sh_test. |
rules/linux/test/ext4_test.sh |
Implements runtime validation of the generated ext4 image using debugfs and tune2fs. |
rules/linux/test/hello.txt |
Adds a sample rootfs file used by the ext4 image test. |
README.md |
Documents the new ext4 rule and shows a usage example. |
.bazelversion |
Bumps Bazel to 8.6.0. |
MODULE.bazel.lock |
Updates the lockfile to match the Bazel/module version bump. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: lurtz <727209+lurtz@users.noreply.github.com>
- Introduce `//toolchains/linux:ext4_toolchain_type` and `ext4_toolchain_config` so `mke2fs`/`coreutils` are resolved via toolchain resolution instead of a hardcoded call; wire it up in the `imagefs` module extension for `type = "ext4"`, auto-provisioning hermetic `coreutils` via bazel_lib. - Split the ext4 rule's image-building logic into static `//rules/linux/tools:compute_size`/`:create_image` scripts driven by argv, replacing generated-script logic. - Move `imagefs_toolchain.bzl` from `rules/qnx/` to `rules/` since it's now shared across qnx and linux toolchain types. - Add `templates/linux/BUILD.template` for generating the linux/ext4 toolchain repo, mirroring the existing qnx template. - Extract the ext4 test into a separate nested Bazel module under `tests/` (score_rules_imagefs_tests) that depends on the root module via `local_path_override`, exercising the `imagefs` extension like a real external consumer. - Update README.md to document the ext4 toolchain setup, module extension usage, and current repository layout.
| while [ "$#" -gt 0 ]; do | ||
| case "$1" in | ||
| D) | ||
| "$coreutils" mkdir -p "$stage/$2" | ||
| shift 2 | ||
| ;; | ||
| F) | ||
| "$coreutils" cp "$3" "$stage/$2" | ||
| shift 3 | ||
| ;; | ||
| L) | ||
| "$coreutils" ln -s "$3" "$stage/$2" | ||
| shift 3 | ||
| ;; | ||
| *) | ||
| echo "compute_size: unknown entry type '$1'" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done |
There was a problem hiding this comment.
Now we have two scripts creating a scratch directory. This one does it for estimating the size of the ext4 image. The second one creates the same directory and then builds the image out of it.
Can those be merged so we avoid copying the files a second time? If that is not possible hard links might be a way to avoid expensive copies if files are large
To avoid copying files 2 times (for each action), implementation now uses only one script for generating the ext4 image type.
These images are handy when running integration tests targeting Linux. They can be created with user rights and given to QEMU as a second disk. This way we avoid having to modify the base image.
This also bumps bazel to version 8.6.0 to align with other S-CORE repos.