import OL rust-bootupd-0.2.27-4.el9_6
This commit is contained in:
parent
4fd865a4a2
commit
3bb46671c2
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,2 @@
|
||||
SOURCES/bootupd-0.2.18-vendor.tar.zstd
|
||||
SOURCES/bootupd-0.2.18.crate
|
||||
SOURCES/bootupd-0.2.27-vendor.tar.zstd
|
||||
SOURCES/bootupd-0.2.27.tar.zstd
|
||||
|
@ -1,2 +1,2 @@
|
||||
cca30f4f8451b627534258f7c23fa360cec45b4a SOURCES/bootupd-0.2.18-vendor.tar.zstd
|
||||
3746d3d9ce696228515b3bc400811c55ec8ae515 SOURCES/bootupd-0.2.18.crate
|
||||
bd5472e5dec9ece6e15ee8b0e234dd147bc77eff SOURCES/bootupd-0.2.27-vendor.tar.zstd
|
||||
560917781f901145a9d17b2b844fb0c898e82752 SOURCES/bootupd-0.2.27.tar.zstd
|
||||
|
@ -1,31 +0,0 @@
|
||||
From 38b971647d126f9c51545553d2a55cc77ff01d08 Mon Sep 17 00:00:00 2001
|
||||
From: Dusty Mabe <dusty@dustymabe.com>
|
||||
Date: Mon, 19 Feb 2024 14:33:17 -0500
|
||||
Subject: [PATCH] grub2: source in a console.cfg file if exists
|
||||
|
||||
This will allow users or distro builders place console settings
|
||||
here that will get picked up on boot. This was discussed as part
|
||||
of https://github.com/coreos/fedora-coreos-tracker/issues/1671
|
||||
---
|
||||
src/grub2/grub-static-pre.cfg | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/src/grub2/grub-static-pre.cfg b/src/grub2/grub-static-pre.cfg
|
||||
index 7784834..9717cfb 100644
|
||||
--- a/src/grub2/grub-static-pre.cfg
|
||||
+++ b/src/grub2/grub-static-pre.cfg
|
||||
@@ -38,6 +38,11 @@ elif [ -s $prefix/grubenv ]; then
|
||||
load_env
|
||||
fi
|
||||
|
||||
+if [ -f $prefix/console.cfg ]; then
|
||||
+ # Source in any GRUB console settings if provided by the user/platform
|
||||
+ source $prefix/console.cfg
|
||||
+fi
|
||||
+
|
||||
if [ x"${feature_menuentry_id}" = xy ]; then
|
||||
menuentry_id_option="--id"
|
||||
else
|
||||
--
|
||||
2.43.0
|
||||
|
@ -0,0 +1,70 @@
|
||||
From b21f81246e1d2d2c2b6b667c0ee441e10ec1f12f Mon Sep 17 00:00:00 2001
|
||||
From: Huijing Hei <hhei@redhat.com>
|
||||
Date: Thu, 26 Jun 2025 21:36:43 +0800
|
||||
Subject: [PATCH 1/3] ostreeutil: add `get_ostree_bootloader()` and
|
||||
`set_ostree_bootloader(value)`
|
||||
|
||||
Partiatly from https://github.com/coreos/bootupd/pull/947
|
||||
---
|
||||
src/ostreeutil.rs | 41 ++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 40 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/ostreeutil.rs b/src/ostreeutil.rs
|
||||
index 8aaf3ec..8b970d8 100644
|
||||
--- a/src/ostreeutil.rs
|
||||
+++ b/src/ostreeutil.rs
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
-use anyhow::Result;
|
||||
+use anyhow::{Context, Result};
|
||||
use log::debug;
|
||||
|
||||
/// https://github.com/coreos/rpm-ostree/pull/969/commits/dc0e8db5bd92e1f478a0763d1a02b48e57022b59
|
||||
@@ -59,3 +59,42 @@ pub(crate) fn rpm_cmd<P: AsRef<Path>>(sysroot: P) -> Result<std::process::Comman
|
||||
}
|
||||
Ok(c)
|
||||
}
|
||||
+
|
||||
+/// Get sysroot.bootloader in ostree repo config.
|
||||
+pub(crate) fn get_ostree_bootloader() -> Result<Option<String>> {
|
||||
+ let mut cmd = std::process::Command::new("ostree");
|
||||
+ let result = cmd
|
||||
+ .args([
|
||||
+ "config",
|
||||
+ "--repo=/sysroot/ostree/repo",
|
||||
+ "get",
|
||||
+ "sysroot.bootloader",
|
||||
+ ])
|
||||
+ .output()
|
||||
+ .context("Querying ostree sysroot.bootloader")?;
|
||||
+ if !result.status.success() {
|
||||
+ // ostree will exit with a none zero return code if the key does not exists
|
||||
+ return Ok(None);
|
||||
+ } else {
|
||||
+ let res = String::from_utf8(result.stdout)
|
||||
+ .with_context(|| "decoding as UTF-8 output of ostree command")?;
|
||||
+ let bootloader = res.trim_end().to_string();
|
||||
+ return Ok(Some(bootloader));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+pub(crate) fn set_ostree_bootloader(bootloader: &str) -> Result<()> {
|
||||
+ let status = std::process::Command::new("ostree")
|
||||
+ .args([
|
||||
+ "config",
|
||||
+ "--repo=/sysroot/ostree/repo",
|
||||
+ "set",
|
||||
+ "sysroot.bootloader",
|
||||
+ bootloader,
|
||||
+ ])
|
||||
+ .status()?;
|
||||
+ if !status.success() {
|
||||
+ anyhow::bail!("Failed to set 'sysroot.bootloader' to '{bootloader}' in ostree repo config");
|
||||
+ }
|
||||
+ Ok(())
|
||||
+}
|
||||
--
|
||||
2.49.0
|
||||
|
@ -0,0 +1,50 @@
|
||||
From afa2291afe49e580d010eff59355371378044a29 Mon Sep 17 00:00:00 2001
|
||||
From: Huijing Hei <hhei@redhat.com>
|
||||
Date: Fri, 6 Jun 2025 11:43:58 +0800
|
||||
Subject: [PATCH 2/3] Add function `get_static_config_meta()` to reuse code
|
||||
|
||||
(cherry picked from commit cf1703f37f907399e14b5e22c4df6eedc631d5ae)
|
||||
---
|
||||
src/bootupd.rs | 19 ++++++++++++-------
|
||||
1 file changed, 12 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/bootupd.rs b/src/bootupd.rs
|
||||
index 5169221..1213654 100644
|
||||
--- a/src/bootupd.rs
|
||||
+++ b/src/bootupd.rs
|
||||
@@ -103,13 +103,8 @@ pub(crate) fn install(
|
||||
|
||||
match configs.enabled_with_uuid() {
|
||||
Some(uuid) => {
|
||||
- let self_bin_meta =
|
||||
- std::fs::metadata("/proc/self/exe").context("Querying self meta")?;
|
||||
- let self_meta = ContentMetadata {
|
||||
- timestamp: self_bin_meta.modified()?.into(),
|
||||
- version: crate_version!().into(),
|
||||
- };
|
||||
- state.static_configs = Some(self_meta);
|
||||
+ let meta = get_static_config_meta()?;
|
||||
+ state.static_configs = Some(meta);
|
||||
#[cfg(any(
|
||||
target_arch = "x86_64",
|
||||
target_arch = "aarch64",
|
||||
@@ -133,6 +128,16 @@ pub(crate) fn install(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+#[context("Get static config metadata")]
|
||||
+fn get_static_config_meta() -> Result<ContentMetadata> {
|
||||
+ let self_bin_meta = std::fs::metadata("/proc/self/exe").context("Querying self meta")?;
|
||||
+ let self_meta = ContentMetadata {
|
||||
+ timestamp: self_bin_meta.modified()?.into(),
|
||||
+ version: crate_version!().into(),
|
||||
+ };
|
||||
+ Ok(self_meta)
|
||||
+}
|
||||
+
|
||||
type Components = BTreeMap<&'static str, Box<dyn Component>>;
|
||||
|
||||
#[allow(clippy::box_default)]
|
||||
--
|
||||
2.49.0
|
||||
|
@ -0,0 +1,371 @@
|
||||
From 3bcae6b37fbaa92fe9bc58ba2ea649e9610b4a92 Mon Sep 17 00:00:00 2001
|
||||
From: Huijing Hei <hhei@redhat.com>
|
||||
Date: Thu, 26 Jun 2025 21:43:02 +0800
|
||||
Subject: [PATCH 3/3] adopt: add tag to install static GRUB config from tree
|
||||
|
||||
Add `bootupctl adopt-and-update --with-static-config` to migrate
|
||||
RHCOS system to use static GRUB config, for example 4.1/4.2 born
|
||||
RHCOS nodes.
|
||||
|
||||
Fixes: https://issues.redhat.com/browse/OCPBUGS-52485
|
||||
(cherry picked from commit 52ff0f987501a31951931add7bb8312b8934c3b0)
|
||||
---
|
||||
src/bios.rs | 82 ++++++++++++++++++++++++++++++++++++++++++--
|
||||
src/bootupd.rs | 19 +++++++---
|
||||
src/cli/bootupctl.rs | 15 +++++---
|
||||
src/component.rs | 4 +++
|
||||
src/efi.rs | 49 ++++++++++++++++++++++++--
|
||||
src/grubconfigs.rs | 5 +++
|
||||
6 files changed, 161 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/bios.rs b/src/bios.rs
|
||||
index 6e528b8..0a65dcf 100644
|
||||
--- a/src/bios.rs
|
||||
+++ b/src/bios.rs
|
||||
@@ -1,4 +1,6 @@
|
||||
-use anyhow::{bail, Result};
|
||||
+use anyhow::{bail, Context, Result};
|
||||
+use camino::Utf8PathBuf;
|
||||
+use openat_ext::OpenatDirExt;
|
||||
#[cfg(target_arch = "powerpc64")]
|
||||
use std::borrow::Cow;
|
||||
use std::io::prelude::*;
|
||||
@@ -8,6 +10,7 @@ use std::process::Command;
|
||||
|
||||
use crate::blockdev;
|
||||
use crate::component::*;
|
||||
+use crate::grubconfigs;
|
||||
use crate::model::*;
|
||||
use crate::packagesystem;
|
||||
|
||||
@@ -156,7 +159,71 @@ impl Component for Bios {
|
||||
crate::component::query_adopt_state()
|
||||
}
|
||||
|
||||
- fn adopt_update(&self, _: &openat::Dir, update: &ContentMetadata) -> Result<InstalledContent> {
|
||||
+ // Backup the current grub.cfg and replace with new static config
|
||||
+ // - Backup "/boot/loader/grub.cfg" to "/boot/grub2/grub.cfg.bak"
|
||||
+ // - Remove symlink "/boot/grub2/grub.cfg"
|
||||
+ // - Replace "/boot/grub2/grub.cfg" symlink with new static "grub.cfg"
|
||||
+ fn migrate_static_grub_config(&self, sysroot_path: &str, destdir: &openat::Dir) -> Result<()> {
|
||||
+ let grub = "boot/grub2";
|
||||
+ // sysroot_path is /, destdir is Dir of /
|
||||
+ let grub_config_path = Utf8PathBuf::from(sysroot_path).join(grub);
|
||||
+ let grub_config_dir = destdir.sub_dir(grub).context("Opening boot/grub2")?;
|
||||
+
|
||||
+ let grub_config = grub_config_path.join(grubconfigs::GRUBCONFIG);
|
||||
+
|
||||
+ if !grub_config.exists() {
|
||||
+ anyhow::bail!("Could not find '{}'", grub_config);
|
||||
+ }
|
||||
+
|
||||
+ let mut current_config;
|
||||
+ // If /boot/grub2/grub.cfg is not symlink, we need to keep going
|
||||
+ if !grub_config.is_symlink() {
|
||||
+ println!("'{}' is not a symlink", grub_config);
|
||||
+ current_config = grub_config.clone();
|
||||
+ } else {
|
||||
+ // If /boot/grub2/grub.cfg is symlink to /boot/loader/grub.cfg,
|
||||
+ // backup it to /boot/grub2/grub.cfg.bak
|
||||
+ // Get real file for symlink /boot/grub2/grub.cfg
|
||||
+ let real_config = grub_config_dir.read_link(grubconfigs::GRUBCONFIG)?;
|
||||
+ let real_config =
|
||||
+ Utf8PathBuf::from_path_buf(real_config).expect("Path should be valid UTF-8");
|
||||
+ // Resolve symlink location
|
||||
+ current_config = grub_config_path.clone();
|
||||
+ current_config.push(real_config);
|
||||
+ }
|
||||
+
|
||||
+ let backup_config = grub_config_path.join(grubconfigs::GRUBCONFIG_BACKUP);
|
||||
+ if !backup_config.exists() {
|
||||
+ // Backup the current GRUB config which is hopefully working right now
|
||||
+ println!(
|
||||
+ "Creating a backup of the current GRUB config '{}' in '{}'...",
|
||||
+ current_config, backup_config
|
||||
+ );
|
||||
+ std::fs::copy(¤t_config, &backup_config)
|
||||
+ .context("Failed to backup GRUB config")?;
|
||||
+ }
|
||||
+
|
||||
+ crate::grubconfigs::install(&destdir, None, true)?;
|
||||
+
|
||||
+ // Remove the real config if it is symlink and will not
|
||||
+ // if /boot/grub2/grub.cfg is file
|
||||
+ if current_config != grub_config {
|
||||
+ println!("Removing {}", current_config);
|
||||
+ grub_config_dir.remove_file_optional(current_config.as_std_path())?;
|
||||
+ }
|
||||
+
|
||||
+ // Synchronize the filesystem containing /boot/grub2 to disk.
|
||||
+ let _ = grub_config_dir.syncfs();
|
||||
+
|
||||
+ Ok(())
|
||||
+ }
|
||||
+
|
||||
+ fn adopt_update(
|
||||
+ &self,
|
||||
+ _: &openat::Dir,
|
||||
+ update: &ContentMetadata,
|
||||
+ with_static_config: bool,
|
||||
+ ) -> Result<InstalledContent> {
|
||||
let Some(meta) = self.query_adopt()? else {
|
||||
anyhow::bail!("Failed to find adoptable system")
|
||||
};
|
||||
@@ -165,6 +232,17 @@ impl Component for Bios {
|
||||
let device = blockdev::get_single_device(&target_root)?;
|
||||
self.run_grub_install(target_root, &device)?;
|
||||
log::debug!("Install grub modules on {device}");
|
||||
+ if with_static_config {
|
||||
+ // Install the static config if the OSTree bootloader is not set.
|
||||
+ if let Some(bootloader) = crate::ostreeutil::get_ostree_bootloader()? {
|
||||
+ println!(
|
||||
+ "ostree repo 'sysroot.bootloader' config option is currently set to: '{bootloader}'",
|
||||
+ );
|
||||
+ } else {
|
||||
+ println!("ostree repo 'sysroot.bootloader' config option is not set yet");
|
||||
+ self.migrate_static_grub_config(target_root, &openat::Dir::open(target_root)?)?;
|
||||
+ };
|
||||
+ }
|
||||
Ok(InstalledContent {
|
||||
meta: update.clone(),
|
||||
filetree: None,
|
||||
diff --git a/src/bootupd.rs b/src/bootupd.rs
|
||||
index 1213654..0e0a00e 100644
|
||||
--- a/src/bootupd.rs
|
||||
+++ b/src/bootupd.rs
|
||||
@@ -256,7 +256,7 @@ pub(crate) fn update(name: &str) -> Result<ComponentUpdateResult> {
|
||||
}
|
||||
|
||||
/// daemon implementation of component adoption
|
||||
-pub(crate) fn adopt_and_update(name: &str) -> Result<ContentMetadata> {
|
||||
+pub(crate) fn adopt_and_update(name: &str, with_static_config: bool) -> Result<ContentMetadata> {
|
||||
let sysroot = openat::Dir::open("/")?;
|
||||
let mut state = SavedState::load_from_disk("/")?.unwrap_or_default();
|
||||
let component = component::new_from_name(name)?;
|
||||
@@ -273,10 +273,19 @@ pub(crate) fn adopt_and_update(name: &str) -> Result<ContentMetadata> {
|
||||
SavedState::acquire_write_lock(sysroot).context("Failed to acquire write lock")?;
|
||||
|
||||
let inst = component
|
||||
- .adopt_update(&state_guard.sysroot, &update)
|
||||
+ .adopt_update(&state_guard.sysroot, &update, with_static_config)
|
||||
.context("Failed adopt and update")?;
|
||||
state.installed.insert(component.name().into(), inst);
|
||||
|
||||
+ // Set static_configs metadata and save
|
||||
+ if with_static_config && state.static_configs.is_none() {
|
||||
+ let meta = get_static_config_meta()?;
|
||||
+ state.static_configs = Some(meta);
|
||||
+ // Set bootloader to none
|
||||
+ crate::ostreeutil::set_ostree_bootloader("none")?;
|
||||
+
|
||||
+ println!("Static GRUB configuration has been adopted successfully.");
|
||||
+ }
|
||||
state_guard.update_state(&state)?;
|
||||
Ok(update)
|
||||
}
|
||||
@@ -445,7 +454,7 @@ pub(crate) fn client_run_update() -> Result<()> {
|
||||
}
|
||||
for (name, adoptable) in status.adoptable.iter() {
|
||||
if adoptable.confident {
|
||||
- let r: ContentMetadata = adopt_and_update(name)?;
|
||||
+ let r: ContentMetadata = adopt_and_update(name, false)?;
|
||||
println!("Adopted and updated: {}: {}", name, r.version);
|
||||
updated = true;
|
||||
} else {
|
||||
@@ -458,13 +467,13 @@ pub(crate) fn client_run_update() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
-pub(crate) fn client_run_adopt_and_update() -> Result<()> {
|
||||
+pub(crate) fn client_run_adopt_and_update(with_static_config: bool) -> Result<()> {
|
||||
let status: Status = status()?;
|
||||
if status.adoptable.is_empty() {
|
||||
println!("No components are adoptable.");
|
||||
} else {
|
||||
for (name, _) in status.adoptable.iter() {
|
||||
- let r: ContentMetadata = adopt_and_update(name)?;
|
||||
+ let r: ContentMetadata = adopt_and_update(name, with_static_config)?;
|
||||
println!("Adopted and updated: {}: {}", name, r.version);
|
||||
}
|
||||
}
|
||||
diff --git a/src/cli/bootupctl.rs b/src/cli/bootupctl.rs
|
||||
index 0b79054..4e831fe 100644
|
||||
--- a/src/cli/bootupctl.rs
|
||||
+++ b/src/cli/bootupctl.rs
|
||||
@@ -56,7 +56,7 @@ pub enum CtlVerb {
|
||||
#[clap(name = "update", about = "Update all components")]
|
||||
Update,
|
||||
#[clap(name = "adopt-and-update", about = "Update all adoptable components")]
|
||||
- AdoptAndUpdate,
|
||||
+ AdoptAndUpdate(AdoptAndUpdateOpts),
|
||||
#[clap(name = "validate", about = "Validate system state")]
|
||||
Validate,
|
||||
#[clap(
|
||||
@@ -88,13 +88,20 @@ pub struct StatusOpts {
|
||||
json: bool,
|
||||
}
|
||||
|
||||
+#[derive(Debug, Parser)]
|
||||
+pub struct AdoptAndUpdateOpts {
|
||||
+ /// Install the static GRUB config files
|
||||
+ #[clap(long, action)]
|
||||
+ with_static_config: bool,
|
||||
+}
|
||||
+
|
||||
impl CtlCommand {
|
||||
/// Run CLI application.
|
||||
pub fn run(self) -> Result<()> {
|
||||
match self.cmd {
|
||||
CtlVerb::Status(opts) => Self::run_status(opts),
|
||||
CtlVerb::Update => Self::run_update(),
|
||||
- CtlVerb::AdoptAndUpdate => Self::run_adopt_and_update(),
|
||||
+ CtlVerb::AdoptAndUpdate(opts) => Self::run_adopt_and_update(opts),
|
||||
CtlVerb::Validate => Self::run_validate(),
|
||||
CtlVerb::Backend(CtlBackend::Generate(opts)) => {
|
||||
super::bootupd::DCommand::run_generate_meta(opts)
|
||||
@@ -133,9 +140,9 @@ impl CtlCommand {
|
||||
}
|
||||
|
||||
/// Runner for `update` verb.
|
||||
- fn run_adopt_and_update() -> Result<()> {
|
||||
+ fn run_adopt_and_update(opts: AdoptAndUpdateOpts) -> Result<()> {
|
||||
ensure_running_in_systemd()?;
|
||||
- bootupd::client_run_adopt_and_update()
|
||||
+ bootupd::client_run_adopt_and_update(opts.with_static_config)
|
||||
}
|
||||
|
||||
/// Runner for `validate` verb.
|
||||
diff --git a/src/component.rs b/src/component.rs
|
||||
index dfff20d..cb3b355 100644
|
||||
--- a/src/component.rs
|
||||
+++ b/src/component.rs
|
||||
@@ -31,11 +31,15 @@ pub(crate) trait Component {
|
||||
/// and "synthesize" content metadata from it.
|
||||
fn query_adopt(&self) -> Result<Option<Adoptable>>;
|
||||
|
||||
+ // Backup the current grub config, and install static grub config from tree
|
||||
+ fn migrate_static_grub_config(&self, sysroot_path: &str, destdir: &openat::Dir) -> Result<()>;
|
||||
+
|
||||
/// Given an adoptable system and an update, perform the update.
|
||||
fn adopt_update(
|
||||
&self,
|
||||
sysroot: &openat::Dir,
|
||||
update: &ContentMetadata,
|
||||
+ with_static_config: bool,
|
||||
) -> Result<InstalledContent>;
|
||||
|
||||
/// Implementation of `bootupd install` for a given component. This should
|
||||
diff --git a/src/efi.rs b/src/efi.rs
|
||||
index f7a0daa..bd94868 100644
|
||||
--- a/src/efi.rs
|
||||
+++ b/src/efi.rs
|
||||
@@ -20,9 +20,10 @@ use walkdir::WalkDir;
|
||||
use widestring::U16CString;
|
||||
|
||||
use crate::filetree;
|
||||
+use crate::grubconfigs;
|
||||
use crate::model::*;
|
||||
use crate::ostreeutil;
|
||||
-use crate::util::{self, CommandRunExt};
|
||||
+use crate::util::*;
|
||||
use crate::{component::*, packagesystem};
|
||||
|
||||
/// Well-known paths to the ESP that may have been mounted external to us.
|
||||
@@ -108,7 +109,7 @@ impl Efi {
|
||||
if st.f_type != libc::MSDOS_SUPER_MAGIC {
|
||||
continue;
|
||||
}
|
||||
- util::ensure_writable_mount(&mnt)?;
|
||||
+ ensure_writable_mount(&mnt)?;
|
||||
log::debug!("Reusing existing {mnt:?}");
|
||||
return Ok(mnt);
|
||||
}
|
||||
@@ -257,11 +258,41 @@ impl Component for Efi {
|
||||
crate::component::query_adopt_state()
|
||||
}
|
||||
|
||||
+ // Backup "/boot/efi/EFI/{vendor}/grub.cfg" to "/boot/efi/EFI/{vendor}/grub.cfg.bak"
|
||||
+ // Replace "/boot/efi/EFI/{vendor}/grub.cfg" with new static "grub.cfg"
|
||||
+ fn migrate_static_grub_config(&self, sysroot_path: &str, destdir: &openat::Dir) -> Result<()> {
|
||||
+ let sysroot =
|
||||
+ openat::Dir::open(sysroot_path).with_context(|| format!("Opening {sysroot_path}"))?;
|
||||
+ let Some(vendor) = self.get_efi_vendor(&sysroot)? else {
|
||||
+ anyhow::bail!("Failed to find efi vendor");
|
||||
+ };
|
||||
+
|
||||
+ // destdir is /boot/efi/EFI
|
||||
+ let efidir = destdir
|
||||
+ .sub_dir(&vendor)
|
||||
+ .with_context(|| format!("Opening EFI/{}", vendor))?;
|
||||
+
|
||||
+ if !efidir.exists(grubconfigs::GRUBCONFIG_BACKUP)? {
|
||||
+ println!("Creating a backup of the current GRUB config on EFI");
|
||||
+ efidir
|
||||
+ .copy_file(grubconfigs::GRUBCONFIG, grubconfigs::GRUBCONFIG_BACKUP)
|
||||
+ .context("Failed to backup GRUB config")?;
|
||||
+ }
|
||||
+
|
||||
+ grubconfigs::install(&sysroot, Some(&vendor), true)?;
|
||||
+ // Synchronize the filesystem containing /boot/efi/EFI/{vendor} to disk.
|
||||
+ // (ignore failures)
|
||||
+ let _ = efidir.syncfs();
|
||||
+
|
||||
+ Ok(())
|
||||
+ }
|
||||
+
|
||||
/// Given an adoptable system and an update, perform the update.
|
||||
fn adopt_update(
|
||||
&self,
|
||||
sysroot: &openat::Dir,
|
||||
updatemeta: &ContentMetadata,
|
||||
+ with_static_config: bool,
|
||||
) -> Result<InstalledContent> {
|
||||
let Some(meta) = self.query_adopt()? else {
|
||||
anyhow::bail!("Failed to find adoptable system")
|
||||
@@ -277,6 +308,20 @@ impl Component for Efi {
|
||||
let diff = updatef.relative_diff_to(&esp)?;
|
||||
log::trace!("applying adoption diff: {}", &diff);
|
||||
filetree::apply_diff(&updated, &esp, &diff, None).context("applying filesystem changes")?;
|
||||
+
|
||||
+ // Backup current config and install static config
|
||||
+ if with_static_config {
|
||||
+ // Install the static config if the OSTree bootloader is not set.
|
||||
+ if let Some(bootloader) = crate::ostreeutil::get_ostree_bootloader()? {
|
||||
+ println!(
|
||||
+ "ostree repo 'sysroot.bootloader' config option is currently set to: '{bootloader}'",
|
||||
+ );
|
||||
+ } else {
|
||||
+ println!("ostree repo 'sysroot.bootloader' config option is not set yet");
|
||||
+ self.migrate_static_grub_config("/", &esp)?;
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
Ok(InstalledContent {
|
||||
meta: updatemeta.clone(),
|
||||
filetree: Some(updatef),
|
||||
diff --git a/src/grubconfigs.rs b/src/grubconfigs.rs
|
||||
index 09aeebf..f3c70d6 100644
|
||||
--- a/src/grubconfigs.rs
|
||||
+++ b/src/grubconfigs.rs
|
||||
@@ -9,6 +9,9 @@ use openat_ext::OpenatDirExt;
|
||||
const GRUB2DIR: &str = "grub2";
|
||||
const CONFIGDIR: &str = "/usr/lib/bootupd/grub2-static";
|
||||
const DROPINDIR: &str = "configs.d";
|
||||
+// The related grub files
|
||||
+pub(crate) const GRUBCONFIG: &str = "grub.cfg";
|
||||
+pub(crate) const GRUBCONFIG_BACKUP: &str = "grub.cfg.backup";
|
||||
|
||||
/// Install the static GRUB config files.
|
||||
#[context("Installing static GRUB configs")]
|
||||
@@ -100,6 +103,8 @@ pub(crate) fn install(
|
||||
.copy_file_at(uuid_path, &efidir, target)
|
||||
.context("Writing bootuuid.cfg to efi dir")?;
|
||||
}
|
||||
+ } else {
|
||||
+ println!("Could not find /boot/efi/EFI when installing {target:?}");
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.49.0
|
||||
|
@ -1,26 +1,32 @@
|
||||
%bcond_without check
|
||||
%global __cargo_skip_build 0
|
||||
|
||||
%global crate bootupd
|
||||
|
||||
Name: rust-%{crate}
|
||||
Version: 0.2.18
|
||||
Release: 1%{?dist}
|
||||
Version: 0.2.27
|
||||
Release: 4%{?dist}
|
||||
Summary: Bootloader updater
|
||||
|
||||
License: ASL 2.0
|
||||
URL: https://crates.io/crates/bootupd
|
||||
Source0: https://github.com/coreos/bootupd/releases/download/v%{version}/bootupd-%{version}.crate
|
||||
Source1: https://github.com/coreos/%{crate}/releases/download/v%{version}/%{crate}-%{version}-vendor.tar.zstd
|
||||
License: Apache-2.0
|
||||
URL: https://github.com/coreos/bootupd
|
||||
Source0: %{url}/releases/download/v%{version}/bootupd-%{version}.tar.zstd
|
||||
Source1: %{url}/releases/download/v%{version}/bootupd-%{version}-vendor.tar.zstd
|
||||
%if 0%{?fedora} || 0%{?rhel} >= 10
|
||||
ExcludeArch: %{ix86}
|
||||
%endif
|
||||
|
||||
Patch0: 0001-grub2-source-in-a-console.cfg-file-if-exists.patch
|
||||
Patch01: 0001-ostreeutil-add-get_ostree_bootloader-and-set_ostree_.patch
|
||||
Patch02: 0002-Add-function-get_static_config_meta-to-reuse-code.patch
|
||||
Patch03: 0003-adopt-add-tag-to-install-static-GRUB-config-from-tre.patch
|
||||
|
||||
BuildRequires: git
|
||||
# For now, see upstream
|
||||
BuildRequires: make
|
||||
BuildRequires: openssl-devel
|
||||
%if 0%{?rhel} && !0%{?eln}
|
||||
%if 0%{?rhel}
|
||||
BuildRequires: rust-toolset
|
||||
%else
|
||||
BuildRequires: rust-packaging
|
||||
BuildRequires: cargo-rpm-macros >= 25
|
||||
%endif
|
||||
BuildRequires: systemd
|
||||
|
||||
@ -30,48 +36,75 @@ Bootloader updater}
|
||||
|
||||
%package -n %{crate}
|
||||
Summary: %{summary}
|
||||
License: ASL 2.0
|
||||
# Apache-2.0
|
||||
# Apache-2.0 OR BSL-1.0
|
||||
# Apache-2.0 OR MIT
|
||||
# Apache-2.0 WITH LLVM-exception
|
||||
# Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
|
||||
# BSD-3-Clause
|
||||
# MIT
|
||||
# MIT OR Apache-2.0
|
||||
# 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}
|
||||
|
||||
%description -n %{crate} %{_description}
|
||||
|
||||
%files -n %{crate}
|
||||
%license LICENSE
|
||||
%license LICENSE.dependencies
|
||||
%license cargo-vendor.txt
|
||||
%doc README.md
|
||||
%{_bindir}/bootupctl
|
||||
%{_libexecdir}/bootupd
|
||||
%{_unitdir}/*
|
||||
%{_prefix}/lib/bootupd/grub2-static/
|
||||
%{_unitdir}/bootloader-update.service
|
||||
|
||||
%prep
|
||||
%autosetup -n %{crate}-%{version} -p1
|
||||
tar -xv -f %{SOURCE1}
|
||||
mkdir -p .cargo
|
||||
cat >.cargo/config << EOF
|
||||
[source.crates-io]
|
||||
replace-with = "vendored-sources"
|
||||
|
||||
[source.vendored-sources]
|
||||
directory = "vendor"
|
||||
EOF
|
||||
%autosetup -n %{crate}-%{version} -p1 -Sgit -a1
|
||||
# Default -v vendor config doesn't support non-crates.io deps (i.e. git)
|
||||
cp .cargo/vendor-config.toml .
|
||||
%cargo_prep -N
|
||||
cat vendor-config.toml >> .cargo/config.toml
|
||||
rm vendor-config.toml
|
||||
|
||||
%build
|
||||
%cargo_build
|
||||
%cargo_vendor_manifest
|
||||
# https://pagure.io/fedora-rust/rust-packaging/issue/33
|
||||
sed -i -e '/https:\/\//d' cargo-vendor.txt
|
||||
%cargo_license_summary
|
||||
%{cargo_license} > LICENSE.dependencies
|
||||
|
||||
%install
|
||||
%make_install INSTALL="install -p -c"
|
||||
make install-grub-static DESTDIR=%{?buildroot} INSTALL="%{__install} -p"
|
||||
|
||||
%post -n %{crate}
|
||||
%systemd_post bootupd.service bootupd.socket
|
||||
|
||||
%preun -n %{crate}
|
||||
%systemd_preun bootupd.service bootupd.socket
|
||||
|
||||
%postun -n %{crate}
|
||||
%systemd_postun bootupd.service bootupd.socket
|
||||
%{__make} install-grub-static DESTDIR=%{?buildroot} INSTALL="%{__install} -p"
|
||||
%{__make} install-systemd-unit DESTDIR=%{?buildroot} INSTALL="%{__install} -p"
|
||||
|
||||
%changelog
|
||||
* Fri Jun 27 2025 HuijingHei <hhei@redhat.com> - 0.2.27-4
|
||||
- Backport https://github.com/coreos/bootupd/pull/945
|
||||
Resolves: #RHEL-100702, #OCPBUGS-52485
|
||||
|
||||
* Wed Feb 12 2025 Joseph Marrero <jmarrero@fedoraproject.org> - 0.2.27-3
|
||||
- spec: remove ExcludeArch ix86 as this is c9s
|
||||
Resolves: #RHEL-77736, #RHEL-79091
|
||||
|
||||
* Wed Feb 12 2025 Joseph Marrero <jmarrero@fedoraproject.org> - 0.2.27-2
|
||||
- Add git to the build requires
|
||||
Resolves: #RHEL-77736, #RHEL-79091
|
||||
|
||||
* Wed Feb 12 2025 Joseph Marrero <jmarrero@fedoraproject.org> - 0.2.27-1
|
||||
- https://github.com/coreos/bootupd/releases/tag/v0.2.27
|
||||
Resolves: #RHEL-77736
|
||||
|
||||
* Thu Dec 12 2024 HuijingHei <hhei@redhat.com> - 0.2.25-1
|
||||
- new version
|
||||
|
||||
* Fri May 17 2024 Joseph Marrero <jmarrero@fedoraproject.org> - 0.2.19-1
|
||||
- https://github.com/coreos/bootupd/releases/tag/v0.2.19
|
||||
Resolves: RHEL-35887
|
||||
|
||||
* Thu Feb 22 2024 Joseph Marrero <jmarrero@fedoraproject.org> - 0.2.18-1
|
||||
- https://github.com/coreos/bootupd/releases/tag/v0.2.18
|
||||
backport patch to support GRUB console.cfg
|
||||
|
Loading…
Reference in New Issue
Block a user