Skip to content

Commit 84a048f

Browse files
committed
boot: Skip /sysroot too
This aids our compatibility with existing ostree-containers. Closes: #164
1 parent 126751d commit 84a048f

File tree

1 file changed

+31
-4
lines changed
  • crates/composefs-boot/src

1 file changed

+31
-4
lines changed

crates/composefs-boot/src/lib.rs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,31 @@ pub mod write_boot;
99

1010
use anyhow::Result;
1111

12-
use composefs::{fsverity::FsVerityHashValue, repository::Repository, tree::FileSystem};
12+
use composefs::{
13+
fsverity::FsVerityHashValue,
14+
repository::Repository,
15+
tree::{FileSystem, ImageError},
16+
};
1317

1418
use crate::bootloader::{get_boot_resources, BootEntry};
1519

20+
/// These directories may have content in the container, but we don't
21+
/// want to expose them in the final merged root.
22+
///
23+
/// # /boot
24+
///
25+
/// This is how sealed UKIs are handled; the UKI in /boot has the composefs
26+
/// digest, so we can't include it in the rendered image.
27+
///
28+
/// # /sysroot
29+
///
30+
/// See https://github.com/containers/composefs-rs/issues/164
31+
/// Basically there is only content here in ostree-container cases,
32+
/// and us traversing there for SELinux labeling will cause problems.
33+
/// The ostree-container code special cases it in a different way, but
34+
/// here we can just ignore it.
35+
const SKIPPED_DIRS: &[&str] = &["boot", "sysroot"];
36+
1637
pub trait BootOps<ObjectID: FsVerityHashValue> {
1738
fn transform_for_boot(
1839
&mut self,
@@ -26,9 +47,15 @@ impl<ObjectID: FsVerityHashValue> BootOps<ObjectID> for FileSystem<ObjectID> {
2647
repo: &Repository<ObjectID>,
2748
) -> Result<Vec<BootEntry<ObjectID>>> {
2849
let boot_entries = get_boot_resources(self, repo)?;
29-
let boot = self.root.get_directory_mut("boot".as_ref())?;
30-
boot.stat.st_mtim_sec = 0;
31-
boot.clear();
50+
for d in SKIPPED_DIRS {
51+
let d = match self.root.get_directory_mut(d.as_ref()) {
52+
Ok(e) => e,
53+
Err(ImageError::NotFound(_)) => continue,
54+
Err(e) => return Err(e.into()),
55+
};
56+
d.stat.st_mtim_sec = 0;
57+
d.clear();
58+
}
3259

3360
selabel::selabel(self, repo)?;
3461

0 commit comments

Comments
 (0)