Skip to content

Commit 52f49b5

Browse files
Johan-Liebert1cgwalters
authored andcommitted
system-reinstall: Add composefs-backend option
Signed-off-by: Pragyan Poudyal <[email protected]>
1 parent 05ed1c0 commit 52f49b5

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

crates/system-reinstall-bootc/src/config/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const CONFIG_VAR: &str = "BOOTC_REINSTALL_CONFIG";
1515
pub(crate) struct ReinstallConfig {
1616
/// The bootc image to install on the system.
1717
pub(crate) bootc_image: String,
18+
pub(crate) composefs_backend: bool,
1819
}
1920

2021
impl ReinstallConfig {

crates/system-reinstall-bootc/src/main.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,26 @@ const ROOT_KEY_MOUNT_POINT: &str = "/bootc_authorized_ssh_keys/root";
2424
/// file with a single member `bootc_image` that specifies the image to install.
2525
/// This will take precedence over the CLI.
2626
#[derive(clap::Parser)]
27-
struct Opts {
27+
pub(crate) struct ReinstallOpts {
2828
/// The bootc image to install
2929
pub(crate) image: String,
3030
// Note if we ever add any other options here,
31+
#[arg(long)]
32+
pub(crate) composefs_backend: bool,
3133
}
3234

3335
#[context("run")]
3436
fn run() -> Result<()> {
3537
// We historically supported an environment variable providing a config to override the image, so
3638
// keep supporting that. I'm considering deprecating that though.
3739
let opts = if let Some(config) = config::ReinstallConfig::load().context("loading config")? {
38-
Opts {
40+
ReinstallOpts {
3941
image: config.bootc_image,
42+
composefs_backend: config.composefs_backend,
4043
}
4144
} else {
4245
// Otherwise an image is required.
43-
Opts::parse()
46+
ReinstallOpts::parse()
4447
};
4548

4649
bootc_utils::initialize_tracing();
@@ -68,7 +71,7 @@ fn run() -> Result<()> {
6871

6972
prompt::mount_warning()?;
7073

71-
let mut reinstall_podman_command = podman::reinstall_command(&opts.image, ssh_key_file_path)?;
74+
let mut reinstall_podman_command = podman::reinstall_command(&opts, ssh_key_file_path)?;
7275

7376
println!();
7477
println!("Going to run command:");

crates/system-reinstall-bootc/src/podman.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::prompt;
1+
use crate::{prompt, ReinstallOpts};
22

33
use super::ROOT_KEY_MOUNT_POINT;
44
use anyhow::{ensure, Context, Result};
@@ -25,7 +25,7 @@ fn bootc_has_clean(image: &str) -> Result<bool> {
2525
}
2626

2727
#[context("reinstall_command")]
28-
pub(crate) fn reinstall_command(image: &str, ssh_key_file: &str) -> Result<Command> {
28+
pub(crate) fn reinstall_command(opts: &ReinstallOpts, ssh_key_file: &str) -> Result<Command> {
2929
let mut podman_command_and_args = [
3030
// We use podman to run the bootc container. This might change in the future to remove the
3131
// podman dependency.
@@ -72,11 +72,15 @@ pub(crate) fn reinstall_command(image: &str, ssh_key_file: &str) -> Result<Comma
7272
.map(String::from)
7373
.to_vec();
7474

75+
if opts.composefs_backend {
76+
bootc_command_and_args.push("--composefs-backend".into());
77+
}
78+
7579
// Enable the systemd service to cleanup the previous install after booting into the
7680
// bootc system for the first time.
7781
// This only happens if the bootc version in the image >= 1.1.8 (this is when the cleanup
7882
// feature was introduced)
79-
if bootc_has_clean(image)? {
83+
if bootc_has_clean(&opts.image)? {
8084
bootc_command_and_args.push("--cleanup".to_string());
8185
}
8286

@@ -88,7 +92,7 @@ pub(crate) fn reinstall_command(image: &str, ssh_key_file: &str) -> Result<Comma
8892

8993
let all_args = [
9094
podman_command_and_args,
91-
vec![image.to_string()],
95+
vec![opts.image.to_string()],
9296
bootc_command_and_args,
9397
]
9498
.concat();

0 commit comments

Comments
 (0)