Skip to content

feat: Add ext4 image creation - #16

Open
lurtz wants to merge 5 commits into
mainfrom
add-ext4-image-creation
Open

feat: Add ext4 image creation#16
lurtz wants to merge 5 commits into
mainfrom
add-ext4-image-creation

Conversation

@lurtz

@lurtz lurtz commented Aug 24, 2026

Copy link
Copy Markdown

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.

lurtz added 2 commits August 24, 2026 13:52
These images are handy when running integration tests targeting Linux.

Copilot AI 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.

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 ext4 Bazel rule (rules/linux/ext4.bzl) to construct an ext4 image from rules_pkg inputs.
  • Add a Bazel sh_test validating the image contents and symlink behavior via debugfs/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.

Comment thread tests/ext4/ext4_test.sh
Comment thread rules/linux/ext4.bzl Outdated
Comment thread rules/linux/ext4.bzl
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.
Comment thread rules/linux/tools/compute_size.sh Outdated
Comment on lines +33 to +52
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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants