1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
From 005ea8b7f69e4d38026bab6a3b1c98a95a3f8d6a Mon Sep 17 00:00:00 2001
From: Hec <hec@heccraft.com>
Date: Mon, 1 Jun 2026 12:17:44 -0400
Subject: [PATCH] Modify grub paths to match Arch Linux
---
src/bios.rs | 24 ++++++++++++------------
src/bootupd.rs | 14 +++++++-------
src/grub2/grub-static-efi.cfg | 6 +++---
src/grub2/grub-static-pre.cfg | 6 +++---
src/grubconfigs.rs | 16 ++++++++--------
5 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/src/bios.rs b/src/bios.rs
index f341f99..2462aa5 100644
--- a/src/bios.rs
+++ b/src/bios.rs
@@ -15,7 +15,7 @@ use crate::model::*;
use crate::packagesystem;
// grub2-install file path
-pub(crate) const GRUB_BIN: &str = "usr/sbin/grub2-install";
+pub(crate) const GRUB_BIN: &str = "usr/bin/grub-install";
#[cfg(target_arch = "powerpc64")]
fn target_device(device: &Device) -> Result<String> {
@@ -148,14 +148,14 @@ impl Component for Bios {
}
// 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"
+ // - Backup "/boot/loader/grub.cfg" to "/boot/grub/grub.cfg.bak"
+ // - Remove symlink "/boot/grub/grub.cfg"
+ // - Replace "/boot/grub/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";
+ let grub = "boot/grub";
// 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_dir = destdir.sub_dir(grub).context("Opening boot/grub")?;
let grub_config = grub_config_path.join(grubconfigs::GRUBCONFIG);
@@ -164,14 +164,14 @@ impl Component for Bios {
}
let mut current_config;
- // If /boot/grub2/grub.cfg is not symlink, we need to keep going
+ // If /boot/grub/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
+ // If /boot/grub/grub.cfg is symlink to /boot/loader/grub.cfg,
+ // backup it to /boot/grub/grub.cfg.bak
+ // Get real file for symlink /boot/grub/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");
@@ -194,13 +194,13 @@ impl Component for Bios {
crate::grubconfigs::install(&destdir, None, None, true)?;
// Remove the real config if it is symlink and will not
- // if /boot/grub2/grub.cfg is file
+ // if /boot/grub/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.
+ // Synchronize the filesystem containing /boot/grub to disk.
fsfreeze_thaw_cycle(grub_config_dir.open_file(".")?)?;
Ok(())
diff --git a/src/bootupd.rs b/src/bootupd.rs
index e01ce92..1bf69f9 100644
--- a/src/bootupd.rs
+++ b/src/bootupd.rs
@@ -337,7 +337,7 @@ pub(crate) fn update(name: &str, rootcxt: &RootContext) -> Result<ComponentUpdat
{
let grub2dir = &sysroot
.sub_dir(format!("boot/{GRUB2DIR}"))
- .context("Opening /boot/grub2")?;
+ .context("Opening /boot/grub")?;
ensure_grub_permissions(grub2dir)?;
}
@@ -389,7 +389,7 @@ pub(crate) fn adopt_and_update(
{
let grub2dir = &sysroot
.sub_dir(format!("boot/{GRUB2DIR}"))
- .context("Opening /boot/grub2")?;
+ .context("Opening /boot/grub")?;
ensure_grub_permissions(grub2dir)?;
}
@@ -737,8 +737,8 @@ pub(crate) fn client_run_migrate_static_grub_config() -> Result<()> {
// Remount /boot read write just for this unit (we are called in a slave mount namespace by systemd)
ensure_writable_boot()?;
- let grub_config_dir = PathBuf::from("/boot/grub2");
- let dirfd = openat::Dir::open(&grub_config_dir).context("Opening /boot/grub2")?;
+ let grub_config_dir = PathBuf::from("/boot/grub");
+ let dirfd = openat::Dir::open(&grub_config_dir).context("Opening /boot/grub")?;
// We mark the bootloader as BLS capable to disable the ostree-grub2 logic.
// We can do that as we know that we are run after the bootloader has been
@@ -747,10 +747,10 @@ pub(crate) fn client_run_migrate_static_grub_config() -> Result<()> {
// manually overwrites the (soon) static GRUB config by calling `grub2-mkconfig`.
// We need this until we can rely on ostree-grub2 being removed from the image.
println!("Marking bootloader as BLS capable...");
- _ = File::create("/boot/grub2/.grub2-blscfg-supported");
+ _ = File::create("/boot/grub/.grub2-blscfg-supported");
// Migrate /boot/grub2/grub.cfg to a static GRUB config if it is a symlink
- let grub_config_filename = PathBuf::from("/boot/grub2/grub.cfg");
+ let grub_config_filename = PathBuf::from("/boot/grub/grub.cfg");
match dirfd.read_link("grub.cfg") {
Err(_) => {
println!(
@@ -766,7 +766,7 @@ pub(crate) fn client_run_migrate_static_grub_config() -> Result<()> {
current_config.push(path);
// Backup the current GRUB config which is hopefully working right now
- let backup_config = PathBuf::from("/boot/grub2/grub.cfg.backup");
+ let backup_config = PathBuf::from("/boot/grub/grub.cfg.backup");
println!(
"Creating a backup of the current GRUB config '{}' in '{}'...",
current_config.display(),
diff --git a/src/grub2/grub-static-efi.cfg b/src/grub2/grub-static-efi.cfg
index 3d552c3..8b0f5b7 100644
--- a/src/grub2/grub-static-efi.cfg
+++ b/src/grub2/grub-static-efi.cfg
@@ -13,11 +13,11 @@ else
search --label boot --set prefix --no-floppy
fi
fi
-if [ -d ($prefix)/grub2 ]; then
- set prefix=($prefix)/grub2
+if [ -d ($prefix)/grub ]; then
+ set prefix=($prefix)/grub
configfile $prefix/grub.cfg
else
- set prefix=($prefix)/boot/grub2
+ set prefix=($prefix)/boot/grub
configfile $prefix/grub.cfg
fi
boot
diff --git a/src/grub2/grub-static-pre.cfg b/src/grub2/grub-static-pre.cfg
index a092008..5d6a358 100644
--- a/src/grub2/grub-static-pre.cfg
+++ b/src/grub2/grub-static-pre.cfg
@@ -2,10 +2,10 @@
# Changes:
# - Dropped Ignition glue, that can be injected into platform.cfg
# petitboot doesn't support -e and doesn't support an empty path part
-if [ -d (md/md-boot)/grub2 ]; then
+if [ -d (md/md-boot)/grub ]; then
# fcct currently creates /boot RAID with superblock 1.0, which allows
# component partitions to be read directly as filesystems. This is
- # necessary because transposefs doesn't yet rerun grub2-install on BIOS,
+ # necessary because transposefs doesn't yet rerun grub-install on BIOS,
# so GRUB still expects /boot to be a partition on the first disk.
#
# There are two consequences:
@@ -19,7 +19,7 @@ if [ -d (md/md-boot)/grub2 ]; then
# future module loads to come from the RAID, so we reset $prefix.
# (On UEFI, the stub grub.cfg has already set $prefix properly.)
set boot=md/md-boot
- set prefix=($boot)/grub2
+ set prefix=($boot)/grub
else
if [ -f ${config_directory}/bootuuid.cfg ]; then
source ${config_directory}/bootuuid.cfg
diff --git a/src/grubconfigs.rs b/src/grubconfigs.rs
index 65196c3..645b922 100644
--- a/src/grubconfigs.rs
+++ b/src/grubconfigs.rs
@@ -12,7 +12,7 @@ use openat_ext::OpenatDirExt;
use crate::freezethaw::fsfreeze_thaw_cycle;
/// The subdirectory of /boot we use
-pub(crate) const GRUB2DIR: &str = "grub2";
+pub(crate) const GRUB2DIR: &str = "grub";
const CONFIGDIR: &str = "/usr/lib/bootupd/grub2-static";
const DROPINDIR: &str = "configs.d";
// The related grub files
@@ -143,12 +143,12 @@ pub(crate) fn install(
Ok(())
}
-#[context("Create file boot/grub2/grubenv")]
+#[context("Create file boot/grub/grubenv")]
fn write_grubenv(grubdir: &openat::Dir) -> Result<()> {
if grubdir.exists(GRUBENV)? {
return Ok(());
}
- let editenv = Path::new("/usr/bin/grub2-editenv");
+ let editenv = Path::new("/usr/bin/grub-editenv");
if !editenv.exists() {
anyhow::bail!("Failed to find {:?}", editenv);
}
@@ -200,25 +200,25 @@ mod tests {
let td = tempfile::tempdir()?;
let tdp = td.path();
let td = openat::Dir::open(tdp)?;
- std::fs::create_dir_all(tdp.join("boot/grub2"))?;
+ std::fs::create_dir_all(tdp.join("boot/grub"))?;
std::fs::create_dir_all(tdp.join("boot/efi/EFI/BOOT"))?;
std::fs::create_dir_all(tdp.join("boot/efi/EFI/fedora"))?;
install(&td, None, Some("fedora"), false).unwrap();
- assert!(td.exists("boot/grub2/grub.cfg")?);
+ assert!(td.exists("boot/grub/grub.cfg")?);
assert!(td.exists("boot/efi/EFI/fedora/grub.cfg")?);
Ok(())
}
#[test]
fn test_write_grubenv() -> Result<()> {
// Skip this test if grub2-editenv is not installed
- let editenv = Path::new("/usr/bin/grub2-editenv");
+ let editenv = Path::new("/usr/bin/grub-editenv");
if !editenv.try_exists()? {
return Ok(());
}
let td = tempfile::tempdir()?;
let tdp = td.path();
- let grub = tdp.join("boot/grub2");
+ let grub = tdp.join("boot/grub");
std::fs::create_dir_all(&grub)?;
let td = openat::Dir::open(&grub)?;
write_grubenv(&td)?;
@@ -237,7 +237,7 @@ mod tests {
fn test_ensure_grub_permissions() -> Result<()> {
let td = tempfile::tempdir()?;
let tdp = td.path();
- let grub = tdp.join("boot/grub2");
+ let grub = tdp.join("boot/grub");
std::fs::create_dir_all(&grub)?;
let grub_dir = openat::Dir::open(&grub)?;
--
2.54.0
|