Skip to content

Conversation

@tvsfx
Copy link
Contributor

@tvsfx tvsfx commented Jan 26, 2026

No description provided.

@tvsfx tvsfx requested review from raoulstrackx and sardok January 26, 2026 15:53

/// Run the `ukify` tool after validation of the passed-in arguments
fn build_uki(cli: &ValidatedCli, initramfs_path: &Path) -> Result<()> {
let mut command = Command::new(UKIFY_PATH);
Copy link
Contributor

@sardok sardok Jan 27, 2026

Choose a reason for hiding this comment

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

So the README.md installation steps require you to create a virtual env directory (.venv) to install the ukify.py. But here, there is a direct invocation of UKIFY_PATH which would fail i believe if user does not invoke source .venv/bin/activate before doing cargo run.
There some alternatives, IMO better than what we have;
1- install ukify via package manager. For example, we as a company use ubuntu and ubuntu has systemd-ukify package. So you don't need to think about installing this scripts dependencies (pefile). You can invoke ukify just like here.

2- create a small project in build_init and create a small project there with uv package manager and a wrapper shell script. The wrapper shell script would do something like the following;

#!/bin/bash

PARSED_ARGS=()
parse_args() {
  --linux) ..
  --initrd)..
 --stub)..
}

uv run --project . ./ukify.py "${PARSED_ARGS[@]}"

In general, elf2uki tool doesn't have to be a rust project. I think, if we add cli tool for initramfs crate, It could be python project or could even be a bash script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed offline with Sinan and we'll assume ukify is installed externally for now.

@@ -0,0 +1 @@
target/
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't think this is necessary, its alread listed in <repo_root>/.gitignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the repo root only ignored /target at the top-level; if you start a path with / it's anchored where the .gitignore is.
I didn't know why we did that so left it alone for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this .gitignore again, because I added elf2uki to the top-level workspace, so it doesn't have its own target folder anymore

help = "String to pass as the kernel command line",
value_name = "STRING"
)]
kernel_cmdline: Option<PathBuf>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldnt this be Option<String>?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also if this is a required value, shouldn't we remove Option<> type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not required; you can pass nothing and then the --cmdline argument will not be passed to ukify. It did need to be String, indeed; fixed.

/// --kernel /tmp/kernel \
/// --app /tmp/application \
/// --uefi-stub /usr/lib/systemd/boot/efi/linuxx64.efi.stub \
/// --cmdline "console=ttyS0 earlyprintk=serial" \
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can make this value console=ttyS0 ... as default value, don't think that it would be changed often.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure we always want a cmdline value; this value is specifically good for debugging, so not sure we should default to it? It's fine to pass nothing; I removed the --cmdline from the example to illustrate that.

@tvsfx tvsfx force-pushed the thomasvs/RTE-710-elf2uki branch from edeb5ac to c9310bb Compare January 29, 2026 18:35
@tvsfx tvsfx force-pushed the thomasvs/RTE-710-elf2uki branch from 8ee6765 to 0b285d0 Compare January 30, 2026 01:06
Taowyoo
Taowyoo previously approved these changes Jan 30, 2026
Copy link
Collaborator

@Taowyoo Taowyoo left a comment

Choose a reason for hiding this comment

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

except some nit pick, LGTM

@Taowyoo Taowyoo self-requested a review January 30, 2026 07:51
Copy link
Collaborator

@Taowyoo Taowyoo left a comment

Choose a reason for hiding this comment

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

Since GH ubuntu has docker installed, could we add a separate GH job to test building this tool?
Ref: https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md

@Taowyoo Taowyoo self-requested a review January 30, 2026 07:53
initramfs_file = initramfs::build(application_elf, init, initramfs_file)
.context("failed to create initramfs")?;

build_uki(&validated_args, initramfs_file.path())?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: if the process exits with an error code or crashes the created temporary files are not deleted : https://docs.rs/tempfile/latest/tempfile/struct.NamedTempFile.html#resource-leaking.
This behaviour is beneficial if you have a failing ukify command and you want to give it a try manually.

Copy link
Contributor Author

@tvsfx tvsfx Feb 2, 2026

Choose a reason for hiding this comment

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

That's true, but I dont call exit(n) or similar in my code, nor do I expect anyone to run the binary with panic = 'abort', so I don't think a scenario where the \tmp files are not cleaned up will easily occur. I guess the main risk would be someone e.g. using Ctrl-C in the terminal. We could mitigate this by catching that signal (and potentially others), but that does seems like a pretty niche scenario

Copy link
Contributor Author

@tvsfx tvsfx Feb 2, 2026

Choose a reason for hiding this comment

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

This behaviour is beneficial if you have a failing ukify command and you want to give it a try manually.

If this turns out to be a problem, we can always make a persist flag or similar in the future, so that we don't delete the tmp files and log where they are.

sardok
sardok previously approved these changes Jan 30, 2026
@tvsfx tvsfx dismissed stale reviews from sardok and Taowyoo via 8503529 February 2, 2026 10:23
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.

4 participants