Skip to content

Commit b9ccaca

Browse files
install/composefs: Update composefs install options
Signed-off-by: Pragyan Poudyal <[email protected]>
1 parent 3f0d7e1 commit b9ccaca

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

lib/src/install.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,18 @@ pub(crate) struct InstallConfigOpts {
232232
pub(crate) stateroot: Option<String>,
233233
}
234234

235+
#[derive(ValueEnum, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
236+
pub(crate) enum BootType {
237+
#[default]
238+
Bls,
239+
Uki,
240+
}
241+
242+
#[derive(Debug, Clone, clap::Parser, Serialize, Deserialize, PartialEq, Eq)]
243+
pub(crate) struct InstallComposefsOptions {
244+
pub(crate) boot: BootType,
245+
}
246+
235247
#[cfg(feature = "install-to-disk")]
236248
#[derive(Debug, Clone, clap::Parser, Serialize, Deserialize, PartialEq, Eq)]
237249
pub(crate) struct InstallToDiskOpts {
@@ -257,7 +269,10 @@ pub(crate) struct InstallToDiskOpts {
257269
pub(crate) via_loopback: bool,
258270

259271
#[clap(long)]
260-
pub(crate) composefs: bool,
272+
pub(crate) composefs_experimental: bool,
273+
274+
#[clap(flatten)]
275+
pub(crate) composefs_opts: InstallComposefsOptions,
261276
}
262277

263278
#[derive(ValueEnum, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
@@ -541,6 +556,17 @@ impl FromStr for MountSpec {
541556
}
542557
}
543558

559+
impl InstallToDiskOpts {
560+
pub(crate) fn validate(&self) {
561+
if !self.composefs_experimental {
562+
// Reject using --boot without --composefs
563+
if self.composefs_opts.boot != BootType::default() {
564+
panic!("--boot must not be provided without --composefs");
565+
}
566+
}
567+
}
568+
}
569+
544570
impl InstallAleph {
545571
#[context("Creating aleph data")]
546572
pub(crate) fn new(
@@ -1645,6 +1671,8 @@ fn installation_complete() {
16451671
#[context("Installing to disk")]
16461672
#[cfg(feature = "install-to-disk")]
16471673
pub(crate) async fn install_to_disk(mut opts: InstallToDiskOpts) -> Result<()> {
1674+
opts.validate();
1675+
16481676
let mut block_opts = opts.block_opts;
16491677
let target_blockdev_meta = block_opts
16501678
.device
@@ -1687,7 +1715,7 @@ pub(crate) async fn install_to_disk(mut opts: InstallToDiskOpts) -> Result<()> {
16871715
(rootfs, loopback_dev)
16881716
};
16891717

1690-
install_to_filesystem_impl(&state, &mut rootfs, Cleanup::Skip, opts.composefs).await?;
1718+
install_to_filesystem_impl(&state, &mut rootfs, Cleanup::Skip, opts.composefs_experimental).await?;
16911719

16921720
// Drop all data about the root except the bits we need to ensure any file descriptors etc. are closed.
16931721
let (root_path, luksdev) = rootfs.into_storage();

0 commit comments

Comments
 (0)