-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initoverlayfs: Add initial initoverlayfs support #4721
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -9,8 +9,11 @@ use cap_std::fs_utf8::Dir as Utf8Dir; | |||||||||||||||||
use cap_std_ext::cap_std; | ||||||||||||||||||
use fn_error_context::context; | ||||||||||||||||||
use std::os::fd::AsRawFd; | ||||||||||||||||||
use std::path::Path; | ||||||||||||||||||
use std::process::Command; | ||||||||||||||||||
|
||||||||||||||||||
const INITOVERLAY_INSTALL_CMD: &str = "/usr/bin/initoverlayfs-install"; | ||||||||||||||||||
|
||||||||||||||||||
/// Primary entrypoint to running our wrapped `kernel-install` handling. | ||||||||||||||||||
#[context("rpm-ostree kernel-install wrapper")] | ||||||||||||||||||
pub(crate) fn main(argv: &[&str]) -> Result<()> { | ||||||||||||||||||
|
@@ -42,7 +45,7 @@ pub(crate) fn main(argv: &[&str]) -> Result<()> { | |||||||||||||||||
} | ||||||||||||||||||
if let Some(k) = new_kernel { | ||||||||||||||||||
undo_systemctl_wrap()?; | ||||||||||||||||||
run_dracut(&k)?; | ||||||||||||||||||
generate_initfs(&k)?; | ||||||||||||||||||
redo_systemctl_wrap()?; | ||||||||||||||||||
} | ||||||||||||||||||
Ok(()) | ||||||||||||||||||
|
@@ -64,13 +67,20 @@ fn redo_systemctl_wrap() -> Result<()> { | |||||||||||||||||
Ok(()) | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
#[context("Running dracut")] | ||||||||||||||||||
fn run_dracut(kernel_dir: &str) -> Result<()> { | ||||||||||||||||||
#[context("Generate initfs")] | ||||||||||||||||||
fn generate_initfs(kernel_dir: &str) -> Result<()> { | ||||||||||||||||||
let root_fs = Utf8Dir::open_ambient_dir("/", cap_std::ambient_authority())?; | ||||||||||||||||||
let tmp_dir = tempfile::tempdir()?; | ||||||||||||||||||
let tmp_initramfs_path = tmp_dir.path().join("initramfs.img"); | ||||||||||||||||||
|
||||||||||||||||||
let cliwrap_dracut = Utf8Path::new(cliwrap::CLIWRAP_DESTDIR).join("dracut"); | ||||||||||||||||||
let mut initfs_tool = String::new(); | ||||||||||||||||||
let initoverlayfs_path = Path::new(INITOVERLAY_INSTALL_CMD); | ||||||||||||||||||
if initoverlayfs_path.exists() { | ||||||||||||||||||
initfs_tool = INITOVERLAY_INSTALL_CMD.to_string() | ||||||||||||||||||
} else { | ||||||||||||||||||
initfs_tool = "dracut".to_string() | ||||||||||||||||||
} | ||||||||||||||||||
Comment on lines
+76
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be simplified to a one liner like this:
Suggested change
It's definitely more idiomatic to assign the result of a condition; the use of In fact an instance of this pattern is right below:
|
||||||||||||||||||
let cliwrap_dracut = Utf8Path::new(cliwrap::CLIWRAP_DESTDIR).join(initfs_tool); | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is right, because we aren't cliwrapping the initoverlay command. So combining with the above, we should just directly assign to |
||||||||||||||||||
let dracut_path = cliwrap_dracut | ||||||||||||||||||
.exists() | ||||||||||||||||||
.then(|| cliwrap_dracut) | ||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I should have mentioned this earlier but you have found a pre-existing confusing mess because we have two places that we run dracut, one here and the other in
rpmostree-kernel.cxx
. I am pretty sure what you really want is to modifyrpmostree-kernel.cxx
because it's the one that runs when creating a "base image" aka new commit. This code is trying to wrap thedracut
command when invoked on the client side (which can be convenient for testing I guess).