Skip to content

Commit 1805136

Browse files
committed
Filter out BLS entries not managed by bootc
1 parent 5476871 commit 1805136

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

crates/lib/src/bootc_composefs/status.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::{
1919
composefs_consts::{
2020
COMPOSEFS_CMDLINE, ORIGIN_KEY_BOOT_DIGEST, ORIGIN_KEY_IMAGE, ORIGIN_KEY_MANIFEST_DIGEST,
2121
TYPE1_ENT_PATH, TYPE1_ENT_PATH_STAGED, USER_CFG, USER_CFG_STAGED,
22+
BLS_ENTRY_PREFIX,
2223
},
2324
install::EFI_LOADER_INFO,
2425
parsers::{
@@ -304,7 +305,7 @@ fn get_sorted_type1_boot_entries_helper(
304305
.to_str()
305306
.ok_or(anyhow::anyhow!("Found non UTF-8 characters in filename"))?;
306307

307-
if !file_name.ends_with(".conf") {
308+
if !(file_name.starts_with(BLS_ENTRY_PREFIX) && file_name.ends_with(".conf")) {
308309
continue;
309310
}
310311

@@ -1109,8 +1110,16 @@ mod tests {
11091110
"loader/entries/random_file.txt",
11101111
"Random file that we won't parse",
11111112
)?;
1112-
tempdir.atomic_write("loader/entries/entry1.conf", entry1)?;
1113-
tempdir.atomic_write("loader/entries/entry2.conf", entry2)?;
1113+
tempdir.atomic_write(
1114+
"loader/entries/random_file.conf",
1115+
"Random file that we won't parse",
1116+
)?;
1117+
tempdir.atomic_write(
1118+
"loader/entries/bootc_random_file.txt",
1119+
"Random file that we won't parse",
1120+
)?;
1121+
tempdir.atomic_write("loader/entries/bootc_entry1.conf", entry1)?;
1122+
tempdir.atomic_write("loader/entries/bootc_entry2.conf", entry2)?;
11141123

11151124
let result =
11161125
get_sorted_type1_boot_entries_helper(&tempdir, true, false, Bootloader::Systemd)
@@ -1272,8 +1281,8 @@ mod tests {
12721281

12731282
tempdir.create_dir_all("loader/entries")?;
12741283
tempdir.create_dir_all("loader/entries.staged")?;
1275-
tempdir.atomic_write("loader/entries/active.conf", active_entry)?;
1276-
tempdir.atomic_write("loader/entries.staged/staged.conf", staged_entry)?;
1284+
tempdir.atomic_write("loader/entries/bootc_active.conf", active_entry)?;
1285+
tempdir.atomic_write("loader/entries.staged/bootc_staged.conf", staged_entry)?;
12771286

12781287
let result = list_type1_entries(&tempdir)?;
12791288
assert_eq!(result.len(), 2);
@@ -1310,7 +1319,7 @@ mod tests {
13101319

13111320
let entry2 = format!(
13121321
r#"
1313-
title Fedora Linux (2.0.0)
1322+
title Fedora Linux (2.0.0)
13141323
version 2.0.0
13151324
sort-key {}
13161325
linux /boot/vmlinuz

crates/lib/src/composefs_consts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ pub(crate) const TYPE1_BOOT_DIR_PREFIX: &str = "bootc_composefs-";
4848
/// The prefix for names of UKI and UKI Addons
4949
pub(crate) const UKI_NAME_PREFIX: &str = TYPE1_BOOT_DIR_PREFIX;
5050

51+
/// The prefix for BLS file entries
52+
pub(crate) const BLS_ENTRY_PREFIX: &str = "bootc_";
53+
5154
/// Prefix for OCI tags owned by bootc in the composefs repository.
5255
///
5356
/// Tags are created as `localhost/bootc-<manifest_digest>` to act as GC roots

tmt/tests/booted/test-composefs-corruped-state-resilience.nu

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def first_boot [] {
4141
systemd-run -p MountFlags=slave -qdPG -- /bin/sh -c $"
4242
mount -orw,remount /sysroot
4343
cd ($entries_dir)
44-
cp * new-entry.conf
45-
46-
sed -i 's;($booted_verity);bad-verity;' new-entry.conf
44+
cp * bootc_new-entry.conf
45+
46+
sed -i 's;($booted_verity);bad-verity;' bootc_new-entry.conf
4747
"
4848

4949
# This should work but log a warning in journal
@@ -76,8 +76,8 @@ def first_boot [] {
7676
# Test the same thing but with an existing rollback deployment
7777
def second_boot [] {
7878
assert equal $booted.image.image "localhost/bootc-test-1"
79-
80-
# Create another derived image
79+
80+
# Create another derived image
8181
tap make_uki_containerfile $"
8282
FROM localhost/bootc as base
8383
RUN echo 'second-deployment' > /usr/share/deployment-marker

0 commit comments

Comments
 (0)