From 42502fa9aef4b3a24e8b8479dfbde41bae554115 Mon Sep 17 00:00:00 2001 From: Omer Tuchfeld Date: Thu, 24 Oct 2024 15:57:09 +0200 Subject: [PATCH] Retain --- lib/src/install.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/src/install.rs b/lib/src/install.rs index 2fb988dc..c020d354 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -173,6 +173,10 @@ pub(crate) struct InstallConfigOpts { /// The stateroot name to use. Defaults to `default`. #[clap(long)] pub(crate) stateroot: Option, + + /// Whether to retain the existing bootloader configuration. + #[clap(long)] + pub(crate) retain: bool, } #[derive(Debug, Clone, clap::Parser, Serialize, Deserialize, PartialEq, Eq)] @@ -1649,6 +1653,8 @@ pub(crate) async fn install_to_filesystem( fsopts }; + let retain = opts.config_opts.retain; + // Gather global state, destructuring the provided options. // IMPORTANT: We might re-execute the current process in this function (for SELinux among other things) // IMPORTANT: and hence anything that is done before MUST BE IDEMPOTENT. @@ -1674,7 +1680,11 @@ pub(crate) async fn install_to_filesystem( }) .await??; } - Some(ReplaceMode::Alongside) => clean_boot_directories(&rootfs_fd)?, + Some(ReplaceMode::Alongside) => { + if !retain { + clean_boot_directories(&rootfs_fd)? + } + } None => require_empty_rootdir(&rootfs_fd)?, }