Skip to content

Commit 3bd779c

Browse files
committed
install: Support bootloader install config options
This allows you to set a non-default ostree bootloader backend. In particular, this is needed for aboot images, as otherwise the deploy will not shell out to aboot-deploy to create the required A/B boot symlinks.
1 parent 7ddb361 commit 3bd779c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

crates/lib/src/install.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,17 @@ async fn initialize_ostree_root(state: &State, root_setup: &RootSetup) -> Result
624624
.run_capture_stderr()?;
625625
}
626626

627+
if let Some(install_config) = &state.install_config {
628+
if let Some(bootloader) = &install_config.bootloader {
629+
tracing::debug!("Setting bootloader to {bootloader}");
630+
Command::new("ostree")
631+
.args(["config", "--repo", "ostree/repo", "set", "sysroot.bootloader", &bootloader])
632+
.cwd_dir(rootfs_dir.try_clone()?)
633+
.run_capture_stderr()
634+
.context("Setting bootloader config")?;
635+
}
636+
}
637+
627638
let sysroot = {
628639
let path = format!("/proc/{}/fd/{}", process::id(), rootfs_dir.as_fd().as_raw_fd());
629640
ostree::Sysroot::new(Some(&gio::File::for_path(path)))

crates/lib/src/install/config.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ pub(crate) struct InstallConfiguration {
7373
pub(crate) kargs: Option<Vec<String>>,
7474
/// Supported architectures for this configuration
7575
pub(crate) match_architectures: Option<Vec<String>>,
76+
/// Bootloader backend to use
77+
pub(crate) bootloader: Option<String>,
7678
}
7779

7880
fn merge_basic<T>(s: &mut Option<T>, o: Option<T>, _env: &EnvProperties) {
@@ -138,6 +140,7 @@ impl Mergeable for InstallConfiguration {
138140
.get_or_insert_with(Default::default)
139141
.extend(other_kargs)
140142
}
143+
merge_basic(&mut self.bootloader, other.bootloader, env);
141144
}
142145
}
143146
}
@@ -276,6 +279,7 @@ root-fs-type = "xfs"
276279
r##"[install]
277280
root-fs-type = "ext4"
278281
kargs = ["console=ttyS0", "foo=bar"]
282+
bootloader = "aboot"
279283
"##,
280284
)
281285
.unwrap();
@@ -302,7 +306,8 @@ kargs = ["console=ttyS0", "foo=bar"]
302306
.map(ToOwned::to_owned)
303307
.collect()
304308
)
305-
)
309+
);
310+
assert_eq!(install.bootloader, Some("aboot".to_string()));
306311
}
307312

308313
#[test]

0 commit comments

Comments
 (0)