Skip to content

Conversation

@jeckersb
Copy link
Collaborator

Add a new bootc container compute-composefs-digest command that computes
the bootable composefs digest directly from a filesystem directory path,
defaulting to /target. This enables computing digests in container
environments without requiring access to container storage or a booted
host system.

The existing container-storage-based behavior is preserved and renamed
to compute-composefs-digest-from-storage (hidden). The hack/compute-composefs-digest
script is updated to use the renamed command.

Computing the digest on / is explicitly rejected with a clear error
message, as this is not supported.

Closes: #1862

Assisted-by: OpenCode (Claude Opus 4.5)
Signed-off-by: John Eckersberg jeckersb@redhat.com

@bootc-bot bootc-bot bot requested a review from ckyrouac December 17, 2025 17:06
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 introduces a new bootc container compute-composefs-digest command to compute the digest from a filesystem path, which is a useful addition for containerized environments. The existing functionality is preserved under a new name, compute-composefs-digest-from-storage, and the related script is updated accordingly. The changes are well-structured and the implementation of the new command is solid.

My main feedback is regarding a piece of duplicated code for setting up a temporary ComposefsRepository. I've left a comment with a suggestion to refactor this into a helper function to improve maintainability. Overall, this is a good change.

@jeckersb
Copy link
Collaborator Author

Worth noting explicitly that these two approaches do not agree, which is mostly (or entirely?) due to containers/composefs-rs#132 and all that mess.

jeckersb@toolbx bootc> podman run --rm -it --mount=type=image,src=localhost/bootc,dst=/target localhost/bootc bootc container compute-composefs-digest                                                                                    12/17/2025 12:08:17 PM
66a8f3ba996bdfa70dd908ffe78412bae1102189bc4207cdb5990904004551f83d897a421fd6f1f9b81bae256c45068e28ad02a7bb10c57a0d5a0da77f59525a
jeckersb@toolbx bootc> hack/compute-composefs-digest localhost/bootc                                                                                                                                                                      12/17/2025 12:08:30 PM
71203ee0983088b9d50b1f909cfff16b569826b2fcc7a764f9b1c06e2215a9f50f24c94e4569187937fa9a0f28cf690f5f8912d49c024db672c5653ae655229f

But... progress.

Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Of all of this stuff I think tests of some form are needed pre-merge, let's all try to hold ourselves to that standard.

@jeckersb jeckersb force-pushed the compute-composefs-in-target branch from b2418b6 to 6fa5bc3 Compare December 18, 2025 21:26
Add a new `bootc container compute-composefs-digest` command that computes
the bootable composefs digest directly from a filesystem directory path,
defaulting to `/target`. This enables computing digests in container
environments without requiring access to container storage or a booted
host system.

The existing container-storage-based behavior is preserved and renamed
to `compute-composefs-digest-from-storage` (hidden). The `hack/compute-composefs-digest`
script is updated to use the renamed command.

The core digest computation logic is extracted into a new
`bootc_composefs::digest` module with:
- `new_temp_composefs_repo()` helper for DRY temp repository creation
- `compute_composefs_digest()` function with "/" path rejection

Unit tests and an integration test verify the command works correctly,
producing valid SHA-512 hex digests with consistent results across
multiple invocations. Exact digest values are not asserted due to
environmental variations (SELinux labels, timestamps, etc.).

Closes: bootc-dev#1862

Assisted-by: OpenCode (Claude Opus 4.5)
Signed-off-by: John Eckersberg <jeckersb@redhat.com>
@jeckersb jeckersb force-pushed the compute-composefs-in-target branch from 6fa5bc3 to d05be98 Compare December 18, 2025 21:28
@jeckersb
Copy link
Collaborator Author

/gemini review

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 introduces a new path-based compute-composefs-digest command, which is a valuable addition for containerized environments. The existing storage-based functionality has been cleanly refactored into a new hidden command, compute-composefs-digest-from-storage. The implementation is well-structured, with the core logic neatly encapsulated in the new digest.rs module, complete with its own unit tests. An integration test is also included to validate the new command. Overall, the changes are logical and well-executed. I have one suggestion to improve maintainability by reducing code duplication in the tests.

Comment on lines +136 to +152
// Create directories required by transform_for_boot
fs::create_dir_all(root.join("boot"))?;
fs::create_dir_all(root.join("sysroot"))?;

// Create usr/bin/hello (executable)
let usr_bin = root.join("usr/bin");
fs::create_dir_all(&usr_bin)?;
let hello_path = usr_bin.join("hello");
fs::write(&hello_path, "test\n")?;
fs::set_permissions(&hello_path, fs::Permissions::from_mode(0o755))?;

// Create etc/config (regular file)
let etc = root.join("etc");
fs::create_dir_all(&etc)?;
let config_path = etc.join("config");
fs::write(&config_path, "test\n")?;
fs::set_permissions(&config_path, fs::Permissions::from_mode(0o644))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logic to create a test filesystem here is a duplicate of the create_test_filesystem helper function in crates/lib/src/bootc_composefs/digest.rs. To improve maintainability and avoid having to update two places for any future changes to the test filesystem structure, consider extracting this logic into a shared test utility. Since bootc and tests-integration are separate crates, this might involve creating a small, shared test-only crate or exposing the helper from bootc under a test-util feature flag.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Per discussion I'd actually like to adapt the fixture.rs code from the ostree side - another option though is composefs dumpfile format.

use std::os::unix::fs::PermissionsExt;

// Create temp directory with test filesystem structure
let td = tempfile::tempdir()?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is fine as is but I think cap-std is a great choice for the test use cases. It's really easy to accidentally forget to prepend the rootdir and then suddenly your unit tests are writing to the current working directory etc.

@cgwalters
Copy link
Collaborator

cgwalters commented Dec 18, 2025

We have this as hide = true for now, but it's probably worth adding to the composefs.md experimental docs at least.

(edit I mean as a followup)

@cgwalters cgwalters enabled auto-merge (rebase) December 18, 2025 21:53
@cgwalters cgwalters merged commit 72f1f27 into bootc-dev:main Dec 19, 2025
59 of 65 checks passed
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.

bootc internals cfs compute-id requires a booted system

2 participants