@@ -5,6 +5,7 @@ use camino::Utf8Path;
5
5
use cap_std:: fs:: Dir ;
6
6
use cap_std:: fs:: Permissions ;
7
7
use cap_std_ext:: cap_std;
8
+ use cap_std_ext:: cap_std:: fs:: DirBuilder ;
8
9
use cap_std_ext:: prelude:: * ;
9
10
use fn_error_context:: context;
10
11
@@ -58,21 +59,30 @@ pub(crate) fn install_via_bootupd(
58
59
Task :: new_and_run (
59
60
"Running bootupctl to install bootloader" ,
60
61
"bootupctl" ,
61
- [ "backend" , "install" , "--src-root" , "/" , rootfs. as_str ( ) ] ,
62
+ [
63
+ "backend" ,
64
+ "install" ,
65
+ "--src-root" ,
66
+ "/" ,
67
+ "--device" ,
68
+ device. as_str ( ) ,
69
+ rootfs. as_str ( ) ,
70
+ ] ,
62
71
) ?;
63
72
64
73
let grub2_uuid_contents = format ! ( "set BOOT_UUID=\" {boot_uuid}\" \n " ) ;
65
74
66
75
let bootfs = & rootfs. join ( "boot" ) ;
76
+ let bootfs = Dir :: open_ambient_dir ( bootfs, cap_std:: ambient_authority ( ) ) ?;
67
77
68
78
{
69
- let efidir = Dir :: open_ambient_dir ( bootfs. join ( "efi" ) , cap_std :: ambient_authority ( ) ) ?;
79
+ let efidir = bootfs. open_dir ( "efi" ) ?;
70
80
install_grub2_efi ( & efidir, & grub2_uuid_contents) ?;
71
81
}
72
82
73
- let grub2 = & bootfs. join ( "grub2" ) ;
74
- std :: fs :: create_dir ( grub2) . context ( "creating boot/ grub2") ?;
75
- let grub2 = Dir :: open_ambient_dir ( grub2 , cap_std :: ambient_authority ( ) ) ? ;
83
+ bootfs. ensure_dir_with ( "grub2" , & DirBuilder :: new ( ) ) ? ;
84
+ let grub2 = bootfs . open_dir ( " grub2") ?;
85
+
76
86
// Mode 0700 to support passwords etc.
77
87
grub2. set_permissions ( "." , Permissions :: from_mode ( 0o700 ) ) ?;
78
88
grub2
@@ -91,17 +101,5 @@ pub(crate) fn install_via_bootupd(
91
101
)
92
102
. with_context ( || format ! ( "Writing {GRUB_BOOT_UUID_FILE}" ) ) ?;
93
103
94
- Task :: new ( "Installing BIOS grub2" , "grub2-install" )
95
- . args ( [
96
- "--target" ,
97
- "i386-pc" ,
98
- "--boot-directory" ,
99
- bootfs. as_str ( ) ,
100
- "--modules" ,
101
- "mdraid1x" ,
102
- device. as_str ( ) ,
103
- ] )
104
- . run ( ) ?;
105
-
106
104
Ok ( ( ) )
107
105
}
0 commit comments