Skip to content

Commit 4ec8a85

Browse files
Johan-Liebert1cgwalters
authored andcommitted
cli: Only allow some arguments if composefs-backend is true
Currently the cli accepts `--insecure`, `--bootloader`, `--uki-addon` for ostree installs as well, which is not quite right as in the best case scenario they won't do anything and in the worst case scenario they might leave the install in undefined state Also, update the bootloader docs to specify systemd-boot is only available for composefs backend Xref: #1989 Signed-off-by: Johan-Liebert1 <pragyanpoudyal41999@gmail.com>
1 parent 90e535b commit 4ec8a85

2 files changed

Lines changed: 5 additions & 19 deletions

File tree

crates/lib/src/install.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -383,18 +383,18 @@ pub(crate) struct InstallComposefsOpts {
383383
pub(crate) composefs_backend: bool,
384384

385385
/// Make fs-verity validation optional in case the filesystem doesn't support it
386-
#[clap(long, default_value_t)]
386+
#[clap(long, default_value_t, requires = "composefs_backend")]
387387
#[serde(default)]
388388
pub(crate) insecure: bool,
389389

390390
/// The bootloader to use.
391-
#[clap(long)]
391+
#[clap(long, requires = "composefs_backend")]
392392
#[serde(default)]
393393
pub(crate) bootloader: Option<Bootloader>,
394394

395395
/// Name of the UKI addons to install without the ".efi.addon" suffix.
396396
/// This option can be provided multiple times if multiple addons are to be installed.
397-
#[clap(long)]
397+
#[clap(long, requires = "composefs_backend")]
398398
#[serde(default)]
399399
pub(crate) uki_addon: Option<Vec<String>>,
400400
}
@@ -804,20 +804,6 @@ impl FromStr for MountSpec {
804804
}
805805
}
806806

807-
#[cfg(feature = "install-to-disk")]
808-
impl InstallToDiskOpts {
809-
pub(crate) fn validate(&self) -> Result<()> {
810-
if !self.composefs_opts.composefs_backend {
811-
// Reject using --insecure without --composefs-backend
812-
if self.composefs_opts.insecure != false {
813-
anyhow::bail!("--insecure must not be provided without --composefs-backend");
814-
}
815-
}
816-
817-
Ok(())
818-
}
819-
}
820-
821807
impl SourceInfo {
822808
// Inspect container information and convert it to an ostree image reference
823809
// that pulls from containers-storage.
@@ -1928,8 +1914,6 @@ fn installation_complete() {
19281914
#[context("Installing to disk")]
19291915
#[cfg(feature = "install-to-disk")]
19301916
pub(crate) async fn install_to_disk(mut opts: InstallToDiskOpts) -> Result<()> {
1931-
opts.validate()?;
1932-
19331917
// Log the disk installation operation to systemd journal
19341918
const INSTALL_DISK_JOURNAL_ID: &str = "8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d3e2";
19351919
let source_image = opts

docs/src/bootloaders.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Currently, `bootc` only runs `bootupd` during the installation process. It does
1313

1414
## systemd-boot
1515

16+
NOTE: systemd-boot is only supported for Composefs Backend and not for Ostree
17+
1618
If bootupd is not present in the input container image, then systemd-boot will be used
1719
by default (except on s390x).
1820

0 commit comments

Comments
 (0)