Skip to content

Commit a6d8861

Browse files
Johan-Liebert1cgwalters
authored andcommitted
composefs-backend: Rename 'composefs-native' to 'composefs-backend'
We were using composefs-native and composefs-backend interchangeably. Replace all instances of `composefs-native` with `composefs-backend` Move all composefs-backend options to a single struct so that we can test for boolean instead of testing for Some/None for composefs-backend options Signed-off-by: Pragyan Poudyal <[email protected]> Signed-off-by: Colin Walters <[email protected]>
1 parent 1579c7d commit a6d8861

File tree

8 files changed

+39
-63
lines changed

8 files changed

+39
-63
lines changed

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,11 @@ pub(crate) fn setup_composefs_bls_boot(
369369
// root_setup.kargs has [root=UUID=<UUID>, "rw"]
370370
let mut cmdline_options = String::from(root_setup.kargs.join(" "));
371371

372-
match &state.composefs_options {
373-
Some(opt) if opt.insecure => {
374-
cmdline_options.push_str(&format!(" {COMPOSEFS_CMDLINE}=?{id_hex}"));
375-
}
376-
None | Some(..) => {
377-
cmdline_options.push_str(&format!(" {COMPOSEFS_CMDLINE}={id_hex}"));
378-
}
379-
};
372+
if state.composefs_options.insecure {
373+
cmdline_options.push_str(&format!(" {COMPOSEFS_CMDLINE}=?{id_hex}"));
374+
} else {
375+
cmdline_options.push_str(&format!(" {COMPOSEFS_CMDLINE}={id_hex}"));
376+
}
380377

381378
// Locate ESP partition device
382379
let esp_part = esp_in(&root_setup.device_info)?;
@@ -835,18 +832,14 @@ pub(crate) fn setup_composefs_uki_boot(
835832
}
836833
}
837834

838-
let Some(cfs_opts) = &state.composefs_options else {
839-
anyhow::bail!("ComposeFS options not found");
840-
};
841-
842835
let esp_part = esp_in(&root_setup.device_info)?;
843836

844837
(
845838
root_setup.physical_root_path.clone(),
846839
esp_part.node.clone(),
847840
state.detected_bootloader.clone(),
848-
cfs_opts.insecure,
849-
cfs_opts.uki_addon.as_ref(),
841+
state.composefs_options.insecure,
842+
state.composefs_options.uki_addon.as_ref(),
850843
)
851844
}
852845

crates/lib/src/bootc_composefs/finalize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub(crate) async fn get_etc_diff() -> Result<()> {
3939
Ok(())
4040
}
4141

42-
pub(crate) async fn composefs_native_finalize() -> Result<()> {
42+
pub(crate) async fn composefs_backend_finalize() -> Result<()> {
4343
let host = composefs_deployment_status().await?;
4444

4545
let booted_composefs = host.require_composefs_booted()?;

crates/lib/src/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use tempfile::tempdir_in;
3535

3636
#[cfg(feature = "composefs-backend")]
3737
use crate::bootc_composefs::{
38-
finalize::{composefs_native_finalize, get_etc_diff},
38+
finalize::{composefs_backend_finalize, get_etc_diff},
3939
rollback::composefs_rollback,
4040
state::composefs_usr_overlay,
4141
status::composefs_booted,
@@ -1605,7 +1605,7 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
16051605
},
16061606

16071607
#[cfg(feature = "composefs-backend")]
1608-
Opt::ComposefsFinalizeStaged => composefs_native_finalize().await,
1608+
Opt::ComposefsFinalizeStaged => composefs_backend_finalize().await,
16091609

16101610
#[cfg(feature = "composefs-backend")]
16111611
Opt::ConfigDiff => get_etc_diff().await,

crates/lib/src/composefs_consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ pub(crate) const COMPOSEFS_TRANSIENT_STATE_DIR: &str = "/run/composefs";
88
/// File created in /run/composefs to record a staged-deployment
99
pub(crate) const COMPOSEFS_STAGED_DEPLOYMENT_FNAME: &str = "staged-deployment";
1010

11-
/// Absolute path to composefs-native state directory
11+
/// Absolute path to composefs-backend state directory
1212
pub(crate) const STATE_DIR_ABS: &str = "/sysroot/state/deploy";
13-
/// Relative path to composefs-native state directory. Relative to /sysroot
13+
/// Relative path to composefs-backend state directory. Relative to /sysroot
1414
pub(crate) const STATE_DIR_RELATIVE: &str = "state/deploy";
1515
/// Relative path to the shared 'var' directory. Relative to /sysroot
1616
pub(crate) const SHARED_VAR_PATH: &str = "state/os/default/var";

crates/lib/src/install.rs

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,17 @@ pub(crate) struct InstallConfigOpts {
247247

248248
#[derive(Debug, Default, Clone, clap::Parser, Serialize, Deserialize, PartialEq, Eq)]
249249
pub(crate) struct InstallComposefsOpts {
250+
/// If true, composefs backend is used, else ostree backend is used
251+
#[clap(long, default_value_t)]
252+
#[serde(default)]
253+
pub(crate) composefs_backend: bool,
254+
255+
/// Make fs-verity validation optional in case the filesystem doesn't support it
250256
#[clap(long, default_value_t)]
251257
#[serde(default)]
252258
pub(crate) insecure: bool,
253259

260+
/// The bootloader to use.
254261
#[clap(long)]
255262
#[serde(default)]
256263
pub(crate) bootloader: Option<Bootloader>,
@@ -286,11 +293,6 @@ pub(crate) struct InstallToDiskOpts {
286293
#[serde(default)]
287294
pub(crate) via_loopback: bool,
288295

289-
#[clap(long)]
290-
#[serde(default)]
291-
#[cfg(feature = "composefs-backend")]
292-
pub(crate) composefs_native: bool,
293-
294296
#[clap(flatten)]
295297
#[serde(flatten)]
296298
#[cfg(feature = "composefs-backend")]
@@ -371,10 +373,6 @@ pub(crate) struct InstallToFilesystemOpts {
371373
#[clap(flatten)]
372374
pub(crate) config_opts: InstallConfigOpts,
373375

374-
#[clap(long)]
375-
#[cfg(feature = "composefs-backend")]
376-
pub(crate) composefs_native: bool,
377-
378376
#[cfg(feature = "composefs-backend")]
379377
#[clap(flatten)]
380378
pub(crate) composefs_opts: InstallComposefsOpts,
@@ -450,7 +448,7 @@ pub(crate) struct State {
450448

451449
// If Some, then --composefs_native is passed
452450
#[cfg(feature = "composefs-backend")]
453-
pub(crate) composefs_options: Option<InstallComposefsOpts>,
451+
pub(crate) composefs_options: InstallComposefsOpts,
454452

455453
/// Detected bootloader type for the target system
456454
pub(crate) detected_bootloader: crate::spec::Bootloader,
@@ -583,10 +581,10 @@ impl FromStr for MountSpec {
583581
#[cfg(all(feature = "install-to-disk", feature = "composefs-backend"))]
584582
impl InstallToDiskOpts {
585583
pub(crate) fn validate(&self) -> Result<()> {
586-
if !self.composefs_native {
587-
// Reject using --insecure without --composefs
584+
if !self.composefs_opts.composefs_backend {
585+
// Reject using --insecure without --composefs-backend
588586
if self.composefs_opts.insecure != false {
589-
anyhow::bail!("--insecure must not be provided without --composefs");
587+
anyhow::bail!("--insecure must not be provided without --composefs-backend");
590588
}
591589
}
592590

@@ -1248,7 +1246,7 @@ async fn prepare_install(
12481246
config_opts: InstallConfigOpts,
12491247
source_opts: InstallSourceOpts,
12501248
target_opts: InstallTargetOpts,
1251-
composefs_options: Option<InstallComposefsOpts>,
1249+
#[cfg(feature = "composefs-backend")] composefs_options: InstallComposefsOpts,
12521250
) -> Result<Arc<State>> {
12531251
tracing::trace!("Preparing install");
12541252
let rootfs = cap_std::fs::Dir::open_ambient_dir("/", cap_std::ambient_authority())
@@ -1321,8 +1319,6 @@ async fn prepare_install(
13211319
false
13221320
};
13231321
tracing::debug!("Composefs required: {composefs_required}");
1324-
let composefs_options =
1325-
composefs_options.or_else(|| composefs_required.then_some(InstallComposefsOpts::default()));
13261322

13271323
// We need to access devices that are set up by the host udev
13281324
bootc_mount::ensure_mirrored_host_mount("/dev")?;
@@ -1394,10 +1390,7 @@ async fn prepare_install(
13941390
// Priority: user-specified > bootupd availability > systemd-boot fallback
13951391
#[cfg(feature = "composefs-backend")]
13961392
let detected_bootloader = {
1397-
if let Some(bootloader) = composefs_options
1398-
.as_ref()
1399-
.and_then(|opts| opts.bootloader.clone())
1400-
{
1393+
if let Some(bootloader) = composefs_options.bootloader.clone() {
14011394
bootloader
14021395
} else {
14031396
if crate::bootloader::supports_bootupd(None)? {
@@ -1426,9 +1419,9 @@ async fn prepare_install(
14261419
tempdir,
14271420
host_is_container,
14281421
composefs_required,
1422+
detected_bootloader,
14291423
#[cfg(feature = "composefs-backend")]
14301424
composefs_options,
1431-
detected_bootloader,
14321425
});
14331426

14341427
Ok(state)
@@ -1600,7 +1593,7 @@ async fn install_to_filesystem_impl(
16001593
}
16011594

16021595
#[cfg(feature = "composefs-backend")]
1603-
if state.composefs_options.is_some() {
1596+
if state.composefs_options.composefs_backend {
16041597
// Load a fd for the mounted target physical root
16051598

16061599
let (id, verity) = initialize_composefs_repository(state, rootfs).await?;
@@ -1677,21 +1670,12 @@ pub(crate) async fn install_to_disk(mut opts: InstallToDiskOpts) -> Result<()> {
16771670
anyhow::bail!("Not a block device: {}", block_opts.device);
16781671
}
16791672

1680-
#[cfg(feature = "composefs-backend")]
1681-
let composefs_arg = if opts.composefs_native {
1682-
Some(opts.composefs_opts)
1683-
} else {
1684-
None
1685-
};
1686-
1687-
#[cfg(not(feature = "composefs-backend"))]
1688-
let composefs_arg = None;
1689-
16901673
let state = prepare_install(
16911674
opts.config_opts,
16921675
opts.source_opts,
16931676
opts.target_opts,
1694-
composefs_arg,
1677+
#[cfg(feature = "composefs-backend")]
1678+
opts.composefs_opts,
16951679
)
16961680
.await?;
16971681

@@ -1929,9 +1913,7 @@ pub(crate) async fn install_to_filesystem(
19291913
opts.source_opts,
19301914
opts.target_opts,
19311915
#[cfg(feature = "composefs-backend")]
1932-
opts.composefs_native.then_some(opts.composefs_opts),
1933-
#[cfg(not(feature = "composefs-backend"))]
1934-
None,
1916+
opts.composefs_opts,
19351917
)
19361918
.await?;
19371919

@@ -2203,12 +2185,11 @@ pub(crate) async fn install_to_existing_root(opts: InstallToExistingRootOpts) ->
22032185
target_opts: opts.target_opts,
22042186
config_opts: opts.config_opts,
22052187
#[cfg(feature = "composefs-backend")]
2206-
composefs_native: false,
2207-
#[cfg(feature = "composefs-backend")]
22082188
composefs_opts: InstallComposefsOpts {
2189+
composefs_backend: true,
22092190
insecure: false,
2210-
bootloader: Bootloader::Grub,
22112191
uki_addon: None,
2192+
bootloader: None,
22122193
},
22132194
};
22142195

crates/lib/src/spec.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,14 @@ pub struct BootEntryOstree {
164164
}
165165

166166
/// Bootloader type to determine whether system was booted via Grub or Systemd
167-
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
167+
#[derive(
168+
clap::ValueEnum, Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, JsonSchema,
169+
)]
168170
pub enum Bootloader {
169-
/// Booted via Grub
171+
/// Use Grub as the booloader
170172
#[default]
171173
Grub,
172-
/// Booted via Systemd
174+
/// Use SystemdBoot as the bootloader
173175
Systemd,
174176
}
175177

tmt/tests/examples/bootc-uki/install-grub.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ podman run \
1919
--security-opt label=type:unconfined_t \
2020
"${IMAGE}" \
2121
bootc install to-disk \
22-
--composefs-native \
22+
--composefs-backend \
2323
--boot=uki \
2424
--source-imgref="containers-storage:${IMAGE}" \
2525
--target-imgref="${IMAGE}" \

tmt/tests/examples/bootc-uki/install-systemd-boot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ podman run \
2424
--security-opt label=type:unconfined_t \
2525
"${IMAGE}" \
2626
bootc install to-disk \
27-
--composefs-native \
27+
--composefs-backend \
2828
--boot=uki \
2929
--source-imgref="containers-storage:${IMAGE}" \
3030
--target-imgref="${IMAGE}" \

0 commit comments

Comments
 (0)