Skip to content

Commit e5ceb97

Browse files
install/composefs: Update composefs install options
Signed-off-by: Pragyan Poudyal <[email protected]>
1 parent 394fa50 commit e5ceb97

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
@@ -233,6 +233,18 @@ pub(crate) struct InstallConfigOpts {
233233
pub(crate) stateroot: Option<String>,
234234
}
235235

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

260272
#[clap(long)]
261-
pub(crate) composefs: bool,
273+
pub(crate) composefs_experimental: bool,
274+
275+
#[clap(flatten)]
276+
pub(crate) composefs_opts: InstallComposefsOptions,
262277
}
263278

264279
#[derive(ValueEnum, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
@@ -540,6 +555,17 @@ impl FromStr for MountSpec {
540555
}
541556
}
542557

558+
impl InstallToDiskOpts {
559+
pub(crate) fn validate(&self) {
560+
if !self.composefs_experimental {
561+
// Reject using --boot without --composefs
562+
if self.composefs_opts.boot != BootType::default() {
563+
panic!("--boot must not be provided without --composefs");
564+
}
565+
}
566+
}
567+
}
568+
543569
impl InstallAleph {
544570
#[context("Creating aleph data")]
545571
pub(crate) fn new(
@@ -1643,6 +1669,8 @@ fn installation_complete() {
16431669
#[context("Installing to disk")]
16441670
#[cfg(feature = "install-to-disk")]
16451671
pub(crate) async fn install_to_disk(mut opts: InstallToDiskOpts) -> Result<()> {
1672+
opts.validate();
1673+
16461674
let mut block_opts = opts.block_opts;
16471675
let target_blockdev_meta = block_opts
16481676
.device
@@ -1685,7 +1713,7 @@ pub(crate) async fn install_to_disk(mut opts: InstallToDiskOpts) -> Result<()> {
16851713
(rootfs, loopback_dev)
16861714
};
16871715

1688-
install_to_filesystem_impl(&state, &mut rootfs, Cleanup::Skip, opts.composefs).await?;
1716+
install_to_filesystem_impl(&state, &mut rootfs, Cleanup::Skip, opts.composefs_experimental).await?;
16891717

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

0 commit comments

Comments
 (0)