Skip to content
66 changes: 36 additions & 30 deletions crates/lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1707,12 +1707,12 @@ async fn prepare_install(
println!("Digest: {digest}");
}

let root_filesystem = target_fs
.or(install_config
.as_ref()
.and_then(|c| c.filesystem_root())
.and_then(|r| r.fstype))
.ok_or_else(|| anyhow::anyhow!("No root filesystem specified"))?;
// Don't error out if a filesystem is not passed in via cli as we could have
// repart.d definitions available
let root_filesystem = target_fs.or(install_config
.as_ref()
.and_then(|c| c.filesystem_root())
.and_then(|r| r.fstype));

let mut is_uki = false;

Expand All @@ -1723,37 +1723,43 @@ async fn prepare_install(
// we hard require it in that particular case
//
// NOTE: This isn't really 100% accurate 100% of the time as the cmdline can be in an addon
match kernel {
Some(k) => match k.k_type {
crate::kernel::KernelType::Uki { cmdline, .. } => {
let allow_missing_fsverity = cmdline.is_some_and(|cmd| {
ComposefsCmdline::find_in_cmdline(&cmd)
.is_some_and(|cfs_cmdline| cfs_cmdline.allow_missing_fsverity)
});

if !allow_missing_fsverity {
anyhow::ensure!(
root_filesystem.supports_fsverity(),
"Specified filesystem {root_filesystem} does not support fs-verity"
);
}
if let Some(root_filesystem) = root_filesystem {
match kernel {
Some(k) => match k.k_type {
crate::kernel::KernelType::Uki { cmdline, .. } => {
let allow_missing_fsverity = cmdline.is_some_and(|cmd| {
ComposefsCmdline::find_in_cmdline(&cmd)
.is_some_and(|cfs_cmdline| cfs_cmdline.allow_missing_fsverity)
});

if !allow_missing_fsverity {
anyhow::ensure!(
root_filesystem.supports_fsverity(),
"Specified filesystem {root_filesystem} does not support fs-verity"
);
}

composefs_options.allow_missing_verity = allow_missing_fsverity;
is_uki = true;
}
composefs_options.allow_missing_verity = allow_missing_fsverity;
is_uki = true;
}

crate::kernel::KernelType::Vmlinuz { .. } => {}
},
crate::kernel::KernelType::Vmlinuz { .. } => {}
},

None => {}
}
None => {}
}

// If `--allow-missing-verity` is already passed via CLI, don't modify
if composefs_options.composefs_backend && !composefs_options.allow_missing_verity && !is_uki {
composefs_options.allow_missing_verity = !root_filesystem.supports_fsverity();
// If `--allow-missing-verity` is already passed via CLI, don't modify
if composefs_options.composefs_backend && !composefs_options.allow_missing_verity && !is_uki
{
composefs_options.allow_missing_verity = !root_filesystem.supports_fsverity();
}
}

tracing::info!(
root_filesystem = root_filesystem
.map(|f| f.to_string())
.unwrap_or("None".into()),
allow_missing_fsverity = composefs_options.allow_missing_verity,
uki = is_uki,
"ComposeFS install prep",
Expand Down
Loading