diff --git a/lib/src/cli.rs b/lib/src/cli.rs index c5bf5a1e..f61d6b9f 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -100,6 +100,9 @@ pub(crate) struct SwitchOpts { /// Target image to use for the next boot. pub(crate) target: String, + + #[clap(long)] + pub(crate) stateroot: Option, } /// Options controlling rollback @@ -713,7 +716,9 @@ async fn switch(opts: SwitchOpts) -> Result<()> { } } - let stateroot = booted_deployment.osname(); + let osname = booted_deployment.osname(); + let stateroot = opts.stateroot.as_deref().unwrap_or_else(|| osname.as_str()); + crate::deploy::stage(sysroot, &stateroot, &fetched, &new_spec).await?; if opts.apply { diff --git a/lib/src/install.rs b/lib/src/install.rs index 607623f6..1a62e0c6 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -171,6 +171,9 @@ pub(crate) struct InstallConfigOpts { #[clap(long, hide = true)] #[serde(default)] pub(crate) skip_bound_images: bool, + + #[clap(long)] + pub(crate) stateroot: Option, } #[derive(Debug, Clone, clap::Parser, Serialize, Deserialize, PartialEq, Eq)] @@ -567,8 +570,11 @@ async fn initialize_ostree_root(state: &State, root_setup: &RootSetup) -> Result // Another implementation: https://github.com/coreos/coreos-assembler/blob/3cd3307904593b3a131b81567b13a4d0b6fe7c90/src/create_disk.sh#L295 crate::lsm::ensure_dir_labeled(rootfs_dir, "", Some("/".into()), 0o755.into(), sepolicy)?; - // TODO: make configurable? - let stateroot = STATEROOT_DEFAULT; + let stateroot = state + .config_opts + .stateroot + .as_deref() + .unwrap_or(STATEROOT_DEFAULT); Task::new_and_run( "Initializing ostree layout", "ostree",