Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
951 changes: 597 additions & 354 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ path = "src/main.rs"

[dependencies]
anyhow = "1.0"
bootc-internal-blockdev = "0.1.0"
bootc-internal-blockdev = "0.2.0"
bootc-internal-utils = "0.1.0"
cap-std-ext = "5.0.0"
camino = "1.2.2"
Expand Down
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ FROM $base
# Clean out the default to ensure we're using our updated content
RUN rpm -e bootupd
COPY --from=build /out/ /
# Install bootc from copr
RUN <<EORUN
set -xeuo pipefail
dnf -y install dnf-plugins-core
dnf -y copr enable rhcontainerbot/bootc centos-stream-9-x86_64
dnf -y install bootc
dnf clean all
rm -rf /var/log
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah...at some point we'll need to do rpm-software-management/dnf5#2011 (comment)

rm -rf /var/lib
rm -rf /var/cache
rm -rf /run/rhsm
EORUN
# Remove /var/roothome as workaround
RUN <<EORUN
set -xeuo pipefail
Expand Down
1 change: 1 addition & 0 deletions contrib/packaging/bootupd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Summary: %{summary}
# Unlicense OR MIT
License: Apache-2.0 AND (Apache-2.0 WITH LLVM-exception) AND BSD-3-Clause AND MIT AND (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND (Unlicense OR MIT)
%{?systemd_requires}
Conflicts: bootc < 1.14.1

%description -n %{crate} %{_description}

Expand Down
32 changes: 20 additions & 12 deletions src/bios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use std::io::prelude::*;
use std::path::Path;
use std::process::Command;

use crate::blockdev;
use bootc_internal_blockdev::Device;

use crate::bootupd::RootContext;
use crate::component::*;
use crate::freezethaw::fsfreeze_thaw_cycle;
Expand Down Expand Up @@ -110,16 +111,20 @@ impl Component for Bios {
&self,
src_root: &str,
dest_root: &str,
device: &str,
device: Option<&Device>,
_update_firmware: bool,
) -> Result<InstalledContent> {
let device =
device.ok_or_else(|| anyhow::anyhow!("BIOS component requires a target device"))?;
let src_dir = openat::Dir::open(src_root)
.with_context(|| format!("opening source directory {src_root}"))?;
let Some(meta) = get_component_update(&src_dir, self)? else {
anyhow::bail!("No update metadata for component {} found", self.name());
};

self.run_grub_install(dest_root, device)?;
self.run_grub_install(dest_root, &device.path())
.with_context(|| format!("installing GRUB on {}", device.path()))?;

Ok(InstalledContent {
meta,
filetree: None,
Expand All @@ -140,7 +145,7 @@ impl Component for Bios {
Ok(Some(meta))
}

fn query_adopt(&self, devices: &Option<Vec<String>>) -> Result<Option<Adoptable>> {
fn query_adopt(&self, devices: &Option<Vec<Device>>) -> Result<Option<Adoptable>> {
#[cfg(target_arch = "x86_64")]
if crate::efi::is_efi_booted()? && devices.is_none() {
log::debug!("Skip BIOS adopt");
Expand Down Expand Up @@ -214,14 +219,17 @@ impl Component for Bios {
update: &ContentMetadata,
with_static_config: bool,
) -> Result<Option<InstalledContent>> {
let bios_devices = blockdev::find_colocated_bios_boot(&rootcxt.devices)?;
let bios_devices = rootcxt.device.find_colocated_bios_boot()?;
let Some(meta) = self.query_adopt(&bios_devices)? else {
return Ok(None);
};

for parent in rootcxt.devices.iter() {
self.run_grub_install(rootcxt.path.as_str(), &parent)?;
log::debug!("Installed grub modules on {parent}");
// Install grub onto each parent (whole-disk) device. For BIOS boot on
// multi-disk setups (e.g. RAID), grub must be written to every backing
// disk's MBR/BIOS-boot partition so the system can boot from any one.
for parent in rootcxt.device.find_all_roots()? {
self.run_grub_install(rootcxt.path.as_str(), &parent.path())?;
log::debug!("Installed grub modules on {}", parent.path());
}

if with_static_config {
Expand Down Expand Up @@ -256,9 +264,9 @@ impl Component for Bios {
.query_update(&rootcxt.sysroot)?
.expect("update available");

for parent in rootcxt.devices.iter() {
self.run_grub_install(rootcxt.path.as_str(), &parent)?;
log::debug!("Installed grub modules on {parent}");
for parent in rootcxt.device.find_all_roots()? {
self.run_grub_install(rootcxt.path.as_str(), &parent.path())?;
log::debug!("Installed grub modules on {}", parent.path());
}

let adopted_from = None;
Expand All @@ -269,7 +277,7 @@ impl Component for Bios {
})
}

fn validate(&self, _: &InstalledContent) -> Result<ValidationResult> {
fn validate(&self, _: &InstalledContent, _device: &Device) -> Result<ValidationResult> {
Ok(ValidationResult::Skip)
}

Expand Down
137 changes: 0 additions & 137 deletions src/blockdev.rs

This file was deleted.

Loading
Loading