|
1 |
| -use std::os::unix::prelude::PermissionsExt; |
2 |
| - |
3 |
| -use anyhow::{Context, Result}; |
| 1 | +use anyhow::Result; |
4 | 2 | use camino::Utf8Path;
|
5 |
| -use cap_std::fs::Dir; |
6 |
| -use cap_std::fs::Permissions; |
7 |
| -use cap_std_ext::cap_std; |
8 |
| -use cap_std_ext::prelude::*; |
9 | 3 | use fn_error_context::context;
|
10 | 4 |
|
11 | 5 | use crate::task::Task;
|
12 | 6 |
|
13 |
| -const GRUB_BOOT_UUID_FILE: &str = "bootuuid.cfg"; |
14 | 7 | /// The name of the mountpoint for efi (as a subdirectory of /boot, or at the toplevel)
|
15 | 8 | pub(crate) const EFI_DIR: &str = "efi";
|
16 | 9 |
|
17 | 10 | #[context("Installing bootloader")]
|
18 | 11 | pub(crate) fn install_via_bootupd(
|
19 | 12 | device: &Utf8Path,
|
20 | 13 | rootfs: &Utf8Path,
|
21 |
| - boot_uuid: &str, |
22 |
| - is_alongside: bool, |
| 14 | + configopts: &crate::install::InstallConfigOpts, |
23 | 15 | ) -> Result<()> {
|
24 | 16 | let verbose = std::env::var_os("BOOTC_BOOTLOADER_DEBUG").map(|_| "-vvvv");
|
25 |
| - // If we're doing an alongside install, only match the host boot method because Anaconda defaults |
26 |
| - // to only doing that. |
27 |
| - let component_args = is_alongside.then_some("--auto"); |
28 |
| - let args = ["backend", "install", "--with-static-configs"] |
| 17 | + // bootc defaults to only targeting the platform boot method. |
| 18 | + let bootupd_opts = (!configopts.generic_image).then_some(["--update-firmware", "--auto"]); |
| 19 | + let args = ["backend", "install", "--write-uuid"] |
29 | 20 | .into_iter()
|
30 | 21 | .chain(verbose)
|
31 |
| - .chain(component_args) |
| 22 | + .chain(bootupd_opts.iter().copied().flatten()) |
32 | 23 | .chain([
|
33 | 24 | "--src-root",
|
34 | 25 | "/",
|
35 | 26 | "--device",
|
36 | 27 | device.as_str(),
|
37 | 28 | rootfs.as_str(),
|
38 | 29 | ]);
|
39 |
| - Task::new_and_run("Running bootupctl to install bootloader", "bootupctl", args)?; |
40 |
| - |
41 |
| - let grub2_uuid_contents = format!("set BOOT_UUID=\"{boot_uuid}\"\n"); |
42 |
| - |
43 |
| - let bootfs = &rootfs.join("boot"); |
44 |
| - let bootfs = |
45 |
| - Dir::open_ambient_dir(bootfs, cap_std::ambient_authority()).context("Opening boot")?; |
46 |
| - let grub2 = bootfs.open_dir("grub2").context("Opening boot/grub2")?; |
47 |
| - |
48 |
| - grub2 |
49 |
| - .atomic_write_with_perms( |
50 |
| - GRUB_BOOT_UUID_FILE, |
51 |
| - grub2_uuid_contents, |
52 |
| - Permissions::from_mode(0o644), |
53 |
| - ) |
54 |
| - .with_context(|| format!("Writing {GRUB_BOOT_UUID_FILE}"))?; |
55 |
| - |
56 |
| - Ok(()) |
| 30 | + Task::new_and_run("Running bootupctl to install bootloader", "bootupctl", args) |
57 | 31 | }
|
0 commit comments