@@ -9,10 +9,32 @@ pub mod write_boot;
99
1010use  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
1418use  crate :: bootloader:: { get_boot_resources,  BootEntry } ; 
1519
20+ /// These directories are required to exist in images. 
21+ /// They may have content in the container, but we don't 
22+ /// want to expose them in the final merged root. 
23+ /// 
24+ /// # /boot 
25+ /// 
26+ /// This is how sealed UKIs are handled; the UKI in /boot has the composefs 
27+ /// digest, so we can't include it in the rendered image. 
28+ /// 
29+ /// # /sysroot 
30+ /// 
31+ /// See https://github.com/containers/composefs-rs/issues/164 
32+ /// Basically there is only content here in ostree-container cases, 
33+ /// and us traversing there for SELinux labeling will cause problems. 
34+ /// The ostree-container code special cases it in a different way, but 
35+ /// here we can just ignore it. 
36+ const  REQUIRED_TOPLEVEL_TO_EMPTY_DIRS :  & [ & str ]  = & [ "boot" ,  "sysroot" ] ; 
37+ 
1638pub  trait  BootOps < ObjectID :  FsVerityHashValue >  { 
1739    fn  transform_for_boot ( 
1840        & mut  self , 
@@ -26,9 +48,11 @@ impl<ObjectID: FsVerityHashValue> BootOps<ObjectID> for FileSystem<ObjectID> {
2648        repo :  & Repository < ObjectID > , 
2749    )  -> Result < Vec < BootEntry < ObjectID > > >  { 
2850        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 ( ) ; 
51+         for  d in  REQUIRED_TOPLEVEL_TO_EMPTY_DIRS  { 
52+             let  d = self . root . get_directory_mut ( d. as_ref ( ) ) ?; 
53+             d. stat . st_mtim_sec  = 0 ; 
54+             d. clear ( ) ; 
55+         } 
3256
3357        selabel:: selabel ( self ,  repo) ?; 
3458
0 commit comments