Skip to content

Commit 0c1cb6b

Browse files
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]>
1 parent 66222e9 commit 0c1cb6b

File tree

7 files changed

+39
-60
lines changed

7 files changed

+39
-60
lines changed

crates/lib/src/bootc_composefs/boot.rs

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

356-
match &state.composefs_options {
357-
Some(opt) if opt.insecure => {
358-
cmdline_options.push_str(&format!(" {COMPOSEFS_CMDLINE}=?{id_hex}"));
359-
}
360-
None | Some(..) => {
361-
cmdline_options.push_str(&format!(" {COMPOSEFS_CMDLINE}={id_hex}"));
362-
}
363-
};
356+
if state.composefs_options.insecure {
357+
cmdline_options.push_str(&format!(" {COMPOSEFS_CMDLINE}=?{id_hex}"));
358+
} else {
359+
cmdline_options.push_str(&format!(" {COMPOSEFS_CMDLINE}={id_hex}"));
360+
}
364361

365362
// Locate ESP partition device
366363
let esp_part = root_setup
@@ -375,11 +372,7 @@ pub(crate) fn setup_composefs_bls_boot(
375372
esp_part.node.clone(),
376373
cmdline_options,
377374
fs,
378-
state
379-
.composefs_options
380-
.as_ref()
381-
.map(|opts| opts.bootloader.clone())
382-
.unwrap_or(Bootloader::default()),
375+
state.composefs_options.bootloader.clone(),
383376
)
384377
}
385378

@@ -828,10 +821,6 @@ pub(crate) fn setup_composefs_uki_boot(
828821
}
829822
}
830823

831-
let Some(cfs_opts) = &state.composefs_options else {
832-
anyhow::bail!("ComposeFS options not found");
833-
};
834-
835824
let esp_part = root_setup
836825
.device_info
837826
.partitions
@@ -842,9 +831,9 @@ pub(crate) fn setup_composefs_uki_boot(
842831
(
843832
root_setup.physical_root_path.clone(),
844833
esp_part.node.clone(),
845-
cfs_opts.bootloader.clone(),
846-
cfs_opts.insecure,
847-
cfs_opts.uki_addon.as_ref(),
834+
state.composefs_options.bootloader.clone(),
835+
state.composefs_options.insecure,
836+
state.composefs_options.uki_addon.as_ref(),
848837
)
849838
}
850839

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
@@ -31,7 +31,7 @@ use serde::{Deserialize, Serialize};
3131

3232
#[cfg(feature = "composefs-backend")]
3333
use crate::bootc_composefs::{
34-
finalize::{composefs_native_finalize, get_etc_diff},
34+
finalize::{composefs_backend_finalize, get_etc_diff},
3535
rollback::composefs_rollback,
3636
state::composefs_usr_overlay,
3737
status::composefs_booted,
@@ -1544,7 +1544,7 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
15441544
},
15451545

15461546
#[cfg(feature = "composefs-backend")]
1547-
Opt::ComposefsFinalizeStaged => composefs_native_finalize().await,
1547+
Opt::ComposefsFinalizeStaged => composefs_backend_finalize().await,
15481548

15491549
#[cfg(feature = "composefs-backend")]
15501550
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: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,21 @@ pub(crate) struct InstallConfigOpts {
249249

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

262+
/// The bootloader to use.
263+
/// Currently supported:
264+
///
265+
/// - systemd-boot
266+
/// - grub
256267
#[clap(long, default_value_t)]
257268
#[serde(default)]
258269
pub(crate) bootloader: Bootloader,
@@ -288,11 +299,6 @@ pub(crate) struct InstallToDiskOpts {
288299
#[serde(default)]
289300
pub(crate) via_loopback: bool,
290301

291-
#[clap(long)]
292-
#[serde(default)]
293-
#[cfg(feature = "composefs-backend")]
294-
pub(crate) composefs_native: bool,
295-
296302
#[clap(flatten)]
297303
#[serde(flatten)]
298304
#[cfg(feature = "composefs-backend")]
@@ -373,10 +379,6 @@ pub(crate) struct InstallToFilesystemOpts {
373379
#[clap(flatten)]
374380
pub(crate) config_opts: InstallConfigOpts,
375381

376-
#[clap(long)]
377-
#[cfg(feature = "composefs-backend")]
378-
pub(crate) composefs_native: bool,
379-
380382
#[cfg(feature = "composefs-backend")]
381383
#[clap(flatten)]
382384
pub(crate) compoesfs_opts: InstallComposefsOpts,
@@ -446,9 +448,9 @@ pub(crate) struct State {
446448
pub(crate) container_root: Dir,
447449
pub(crate) tempdir: TempDir,
448450

449-
// If Some, then --composefs_native is passed
451+
// If Some, then --composefs-backend is passed
450452
#[cfg(feature = "composefs-backend")]
451-
pub(crate) composefs_options: Option<InstallComposefsOpts>,
453+
pub(crate) composefs_options: InstallComposefsOpts,
452454
}
453455

454456
impl State {
@@ -578,10 +580,10 @@ impl FromStr for MountSpec {
578580
#[cfg(all(feature = "install-to-disk", feature = "composefs-backend"))]
579581
impl InstallToDiskOpts {
580582
pub(crate) fn validate(&self) -> Result<()> {
581-
if !self.composefs_native {
582-
// Reject using --insecure without --composefs
583+
if !self.composefs_opts.composefs_backend {
584+
// Reject using --insecure without --composefs-backend
583585
if self.composefs_opts.insecure != false {
584-
anyhow::bail!("--insecure must not be provided without --composefs");
586+
anyhow::bail!("--insecure must not be provided without --composefs-backend");
585587
}
586588
}
587589

@@ -1234,7 +1236,7 @@ async fn prepare_install(
12341236
config_opts: InstallConfigOpts,
12351237
source_opts: InstallSourceOpts,
12361238
target_opts: InstallTargetOpts,
1237-
_composefs_opts: Option<InstallComposefsOpts>,
1239+
#[cfg(feature = "composefs-backend")] composefs_options: InstallComposefsOpts,
12381240
) -> Result<Arc<State>> {
12391241
tracing::trace!("Preparing install");
12401242
let rootfs = cap_std::fs::Dir::open_ambient_dir("/", cap_std::ambient_authority())
@@ -1380,7 +1382,7 @@ async fn prepare_install(
13801382
tempdir,
13811383
host_is_container,
13821384
#[cfg(feature = "composefs-backend")]
1383-
composefs_options: _composefs_opts,
1385+
composefs_options,
13841386
});
13851387

13861388
Ok(state)
@@ -1545,7 +1547,7 @@ async fn install_to_filesystem_impl(
15451547
}
15461548

15471549
#[cfg(feature = "composefs-backend")]
1548-
if state.composefs_options.is_some() {
1550+
if state.composefs_options.composefs_backend {
15491551
// Load a fd for the mounted target physical root
15501552

15511553
let (id, verity) = initialize_composefs_repository(state, rootfs).await?;
@@ -1622,21 +1624,12 @@ pub(crate) async fn install_to_disk(mut opts: InstallToDiskOpts) -> Result<()> {
16221624
anyhow::bail!("Not a block device: {}", block_opts.device);
16231625
}
16241626

1625-
#[cfg(feature = "composefs-backend")]
1626-
let composefs_arg = if opts.composefs_native {
1627-
Some(opts.composefs_opts)
1628-
} else {
1629-
None
1630-
};
1631-
1632-
#[cfg(not(feature = "composefs-backend"))]
1633-
let composefs_arg = None;
1634-
16351627
let state = prepare_install(
16361628
opts.config_opts,
16371629
opts.source_opts,
16381630
opts.target_opts,
1639-
composefs_arg,
1631+
#[cfg(feature = "composefs-backend")]
1632+
opts.composefs_opts,
16401633
)
16411634
.await?;
16421635

@@ -1874,9 +1867,7 @@ pub(crate) async fn install_to_filesystem(
18741867
opts.source_opts,
18751868
opts.target_opts,
18761869
#[cfg(feature = "composefs-backend")]
1877-
opts.composefs_native.then_some(opts.compoesfs_opts),
1878-
#[cfg(not(feature = "composefs-backend"))]
1879-
None,
1870+
opts.compoesfs_opts,
18801871
)
18811872
.await?;
18821873

@@ -2148,9 +2139,8 @@ pub(crate) async fn install_to_existing_root(opts: InstallToExistingRootOpts) ->
21482139
target_opts: opts.target_opts,
21492140
config_opts: opts.config_opts,
21502141
#[cfg(feature = "composefs-backend")]
2151-
composefs_native: false,
2152-
#[cfg(feature = "composefs-backend")]
21532142
compoesfs_opts: InstallComposefsOpts {
2143+
composefs_backend: true,
21542144
insecure: false,
21552145
bootloader: Bootloader::Grub,
21562146
uki_addon: None,

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)