From bed88b053b61449058c60020c3405be6ef88fb51 Mon Sep 17 00:00:00 2001 From: Omer Tuchfeld Date: Fri, 21 Jun 2024 11:03:42 +0200 Subject: [PATCH] install: Make stateroot configurable This commit makes it so that the `bootc install` stateroot will be configurable (it defaults to `default`). For now this is a hidden CLI option until we decide whether we want to commit to this API. In the future we also want to make the stateroot of `bootc switch` be configurable (https://github.com/containers/bootc/pull/617) so that users can install an image to a new stateroot while they already have an existing stateroot Also removed the constant `STATEROOT_DEFAULT`, we're now simply taking it from the `ostree_ext` crate --- lib/src/install.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/src/install.rs b/lib/src/install.rs index 499db9320..59951492c 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -44,8 +44,6 @@ use crate::mount::Filesystem; use crate::task::Task; use crate::utils::sigpolicy_from_opts; -/// The default "stateroot" or "osname"; see https://github.com/ostreedev/ostree/issues/2794 -const STATEROOT_DEFAULT: &str = "default"; /// The toplevel boot directory const BOOT: &str = "boot"; /// Directory for transient runtime state @@ -159,6 +157,10 @@ pub(crate) struct InstallConfigOpts { #[clap(long)] #[serde(default)] pub(crate) generic_image: bool, + + /// The stateroot name to use. Defaults to `default`. + #[clap(long, default_value = ostree_ext::container::deploy::STATEROOT_DEFAULT, hide = true)] + pub(crate) stateroot: String, } #[derive(Debug, Clone, clap::Parser, Serialize, Deserialize, PartialEq, Eq)] @@ -546,8 +548,11 @@ async fn initialize_ostree_root_from_self( // 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",