Skip to content

Conversation

@cgwalters
Copy link
Member

No description provided.

This is a thin helper to aid in debugging
coreos#5436
@openshift-ci
Copy link

openshift-ci bot commented Jul 28, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

#!/bin/bash
set -euo pipefail

dn=$(cd $(dirname $0) && pwd)

Check warning

Code scanning / shellcheck

Quote this to prevent word splitting. Warning test

Quote this to prevent word splitting.
echo someerr 1>&2
echo world
EOF
rpm-ostree internals bwrap-script / /bin/bash $(pwd)/script >out.txt

Check warning

Code scanning / shellcheck

Quote this to prevent word splitting. Warning test

Quote this to prevent word splitting.
Copy link

@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 refactors the internals command from C to Rust and adds a new bwrap-script subcommand. The changes are well-structured and include a new test case for the added functionality. The supporting changes in the build system and module wiring are correct. I've identified a couple of areas for improvement in the new Rust code related to maintainability and robustness, specifically regarding the use of magic numbers and a hardcoded path.

let root = &Dir::open_ambient_dir(&self.root, authority)?;
let mut bwrap =
bwrap::Bubblewrap::new_with_mutability(root, BubblewrapMutability::MutateFreely)?;
let td = Dir::open_ambient_dir("/var/tmp", authority)?;

Choose a reason for hiding this comment

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

medium

Hardcoding /var/tmp might reduce portability. This will fail if the tool is run in an environment where /var/tmp does not exist or is not writable. Using std::env::temp_dir() is more robust as it returns a platform-specific temporary directory.

Suggested change
let td = Dir::open_ambient_dir("/var/tmp", authority)?;
let td = Dir::open_ambient_dir(std::env::temp_dir(), authority)?;

Comment on lines +82 to +83
bwrap.take_fd(mfd.into_raw_fd(), 5);
bwrap.append_child_arg("/proc/self/fd/5");

Choose a reason for hiding this comment

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

medium

The file descriptor 5 is used as a magic number here and on the next line. It's better to define it as a constant to improve readability and maintainability.

Suggested change
bwrap.take_fd(mfd.into_raw_fd(), 5);
bwrap.append_child_arg("/proc/self/fd/5");
const SCRIPT_FD: i32 = 5;
bwrap.take_fd(mfd.into_raw_fd(), SCRIPT_FD);
bwrap.append_child_arg(&format!("/proc/self/fd/{}", SCRIPT_FD));

@openshift-merge-robot
Copy link
Collaborator

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@jlebon
Copy link
Member

jlebon commented Jul 31, 2025

Nice. In https://github.com/coreos/fedora-coreos-config/blob/5603f9a31091b4ddef4eb3368ada64f88f2b05c4/build-rootfs#L138, one idea I had was actually exposing bwrap as bootc-base-imagectl runroot /rootfs <cmd>.

@cgwalters
Copy link
Member Author

one idea I had was actually exposing bwrap as bootc-base-imagectl runroot /rootfs .

cc rpm-software-management/dnf5#2270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants