@@ -7,6 +7,8 @@ use bootc_utils::CommandRunExt;
77use fn_error_context:: context;
88use openat_ext:: OpenatDirExt ;
99
10+ use crate :: freezethaw:: fsfreeze_thaw_cycle;
11+
1012/// The subdirectory of /boot we use
1113const GRUB2DIR : & str = "grub2" ;
1214const CONFIGDIR : & str = "/usr/lib/bootupd/grub2-static" ;
@@ -60,8 +62,9 @@ pub(crate) fn install(
6062 println ! ( "Added {name}" ) ;
6163 }
6264
63- bootdir
64- . write_file_contents ( format ! ( "{GRUB2DIR}/grub.cfg" ) , 0o644 , config. as_bytes ( ) )
65+ let grub2dir = bootdir. sub_dir ( GRUB2DIR ) ?;
66+ grub2dir
67+ . write_file_contents ( "grub.cfg" , 0o644 , config. as_bytes ( ) )
6568 . context ( "Copying grub-static.cfg" ) ?;
6669 println ! ( "Installed: grub.cfg" ) ;
6770
@@ -74,15 +77,18 @@ pub(crate) fn install(
7477 . uuid
7578 . ok_or_else ( || anyhow:: anyhow!( "Failed to find UUID for boot" ) ) ?;
7679 let grub2_uuid_contents = format ! ( "set BOOT_UUID=\" {bootfs_uuid}\" \n " ) ;
77- let uuid_path = format ! ( "{GRUB2DIR}/ bootuuid.cfg") ;
78- bootdir
79- . write_file_contents ( & uuid_path, 0o644 , grub2_uuid_contents)
80+ let uuid_path = " bootuuid.cfg";
81+ grub2dir
82+ . write_file_contents ( uuid_path, 0o644 , grub2_uuid_contents)
8083 . context ( "Writing bootuuid.cfg" ) ?;
84+ println ! ( "Installed: bootuuid.cfg" ) ;
8185 Some ( uuid_path)
8286 } else {
8387 None
8488 } ;
8589
90+ fsfreeze_thaw_cycle ( grub2dir. open_file ( "." ) ?) ?;
91+
8692 if let Some ( vendordir) = installed_efi_vendor {
8793 log:: debug!( "vendordir={:?}" , & vendordir) ;
8894 let vendor = PathBuf :: from ( vendordir) ;
@@ -96,13 +102,13 @@ pub(crate) fn install(
96102 . context ( "Copying static EFI" ) ?;
97103 println ! ( "Installed: {target:?}" ) ;
98104 if let Some ( uuid_path) = uuid_path {
99- // SAFETY: we always have a filename
100- let filename = Path :: new ( & uuid_path) . file_name ( ) . unwrap ( ) ;
101- let target = & vendor. join ( filename) ;
102- bootdir
105+ let target = & vendor. join ( uuid_path) ;
106+ grub2dir
103107 . copy_file_at ( uuid_path, & efidir, target)
104108 . context ( "Writing bootuuid.cfg to efi dir" ) ?;
109+ println ! ( "Installed: {target:?}" ) ;
105110 }
111+ fsfreeze_thaw_cycle ( efidir. open_file ( "." ) ?) ?;
106112 }
107113 }
108114
0 commit comments