Skip to content

Commit cb34ad8

Browse files
authored
Merge pull request #199 from cgwalters/install-efi-uuid
install: Update to new bootupd uuid/EFI code
2 parents 0137dcc + c920cbd commit cb34ad8

File tree

4 files changed

+26
-45
lines changed

4 files changed

+26
-45
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
run: |
118118
set -xeuo pipefail
119119
sudo podman run --rm -ti --privileged -v /:/target -v ./usr/bin/bootc:/usr/bin/bootc --pid=host --security-opt label=disable \
120-
quay.io/centos-boot/fedora-tier-1:eln bootc install-to-filesystem --target-no-signature-verification \
120+
quay.io/centos-boot/fedora-tier-1-dev:eln bootc install-to-filesystem --target-no-signature-verification \
121121
--karg=foo=bar --disable-selinux --replace=alongside /target
122122
ls -al /boot/loader/
123123
sudo grep foo=bar /boot/loader/entries/*.conf

lib/src/bootloader.rs

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,31 @@
1-
use std::os::unix::prelude::PermissionsExt;
2-
3-
use anyhow::{Context, Result};
1+
use anyhow::Result;
42
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::*;
93
use fn_error_context::context;
104

115
use crate::task::Task;
126

13-
const GRUB_BOOT_UUID_FILE: &str = "bootuuid.cfg";
147
/// The name of the mountpoint for efi (as a subdirectory of /boot, or at the toplevel)
158
pub(crate) const EFI_DIR: &str = "efi";
169

1710
#[context("Installing bootloader")]
1811
pub(crate) fn install_via_bootupd(
1912
device: &Utf8Path,
2013
rootfs: &Utf8Path,
21-
boot_uuid: &str,
22-
is_alongside: bool,
14+
configopts: &crate::install::InstallConfigOpts,
2315
) -> Result<()> {
2416
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"]
2920
.into_iter()
3021
.chain(verbose)
31-
.chain(component_args)
22+
.chain(bootupd_opts.iter().copied().flatten())
3223
.chain([
3324
"--src-root",
3425
"/",
3526
"--device",
3627
device.as_str(),
3728
rootfs.as_str(),
3829
]);
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)
5731
}

lib/src/install.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ pub(crate) struct InstallConfigOpts {
105105
#[clap(long)]
106106
/// Add a kernel argument
107107
karg: Option<Vec<String>>,
108+
109+
/// Perform configuration changes suitable for a "generic" disk image.
110+
/// At the moment:
111+
///
112+
/// - All bootloader types will be installed
113+
/// - Changes to the system firmware will be skipped
114+
#[clap(long)]
115+
#[serde(default)]
116+
pub(crate) generic_image: bool,
108117
}
109118

110119
/// Perform an installation to a block device.
@@ -964,6 +973,13 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
964973
rootfs.kargs.push("selinux=0".to_string());
965974
}
966975

976+
// We verify this upfront because it's currently required by bootupd
977+
let boot_uuid = rootfs
978+
.get_boot_uuid()?
979+
.or(rootfs.rootfs_uuid.as_deref())
980+
.ok_or_else(|| anyhow!("No uuid for boot/root"))?;
981+
tracing::debug!("boot uuid={boot_uuid}");
982+
967983
// Write the aleph data that captures the system state at the time of provisioning for aid in future debugging.
968984
{
969985
let aleph = initialize_ostree_root_from_self(state, rootfs).await?;
@@ -976,16 +992,7 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
976992
.context("Writing aleph version")?;
977993
}
978994

979-
let boot_uuid = rootfs
980-
.get_boot_uuid()?
981-
.or(rootfs.rootfs_uuid.as_deref())
982-
.ok_or_else(|| anyhow!("No uuid for boot/root"))?;
983-
crate::bootloader::install_via_bootupd(
984-
&rootfs.device,
985-
&rootfs.rootfs,
986-
boot_uuid,
987-
rootfs.is_alongside,
988-
)?;
995+
crate::bootloader::install_via_bootupd(&rootfs.device, &rootfs.rootfs, &state.config_opts)?;
989996
tracing::debug!("Installed bootloader");
990997

991998
// ostree likes to have the immutable bit on the physical sysroot to ensure

tests/kolainst/install

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
set -xeuo pipefail
1212

13-
IMAGE=quay.io/centos-boot/fedora-tier-1:eln
13+
IMAGE=quay.io/centos-boot/fedora-tier-1-dev:eln
1414
# TODO: better detect this, e.g. look for an empty device
1515
DEV=/dev/vda
1616

0 commit comments

Comments
 (0)