@@ -6,7 +6,6 @@ use camino::Utf8Path;
6
6
use cap_std:: fs:: Dir ;
7
7
use cap_std:: fs:: Permissions ;
8
8
use cap_std_ext:: cap_std;
9
- use cap_std_ext:: cap_std:: fs:: DirBuilder ;
10
9
use cap_std_ext:: prelude:: * ;
11
10
use fn_error_context:: context;
12
11
@@ -15,43 +14,9 @@ use crate::task::Task;
15
14
/// This variable is referenced by our GRUB fragment
16
15
pub ( crate ) const IGNITION_VARIABLE : & str = "$ignition_firstboot" ;
17
16
const GRUB_BOOT_UUID_FILE : & str = "bootuuid.cfg" ;
18
- const STATIC_GRUB_CFG : & str = include_str ! ( "grub.cfg" ) ;
19
- const STATIC_GRUB_CFG_EFI : & str = include_str ! ( "grub-efi.cfg" ) ;
20
17
/// The name of the mountpoint for efi (as a subdirectory of /boot, or at the toplevel)
21
18
pub ( crate ) const EFI_DIR : & str = "efi" ;
22
19
23
- #[ context( "Installing grub2 EFI" ) ]
24
- fn install_grub2_efi ( efidir : & Dir , uuid : & str ) -> Result < ( ) > {
25
- let mut vendordir = None ;
26
- let efidir = efidir. open_dir ( "EFI" ) . context ( "Opening EFI/" ) ?;
27
- for child in efidir. entries ( ) ? {
28
- let child = child?;
29
- let name = child. file_name ( ) ;
30
- let name = if let Some ( name) = name. to_str ( ) {
31
- name
32
- } else {
33
- continue ;
34
- } ;
35
- if name == "BOOT" {
36
- continue ;
37
- }
38
- if !child. file_type ( ) ?. is_dir ( ) {
39
- continue ;
40
- }
41
- vendordir = Some ( child. open_dir ( ) ?) ;
42
- break ;
43
- }
44
- let vendordir = vendordir. ok_or_else ( || anyhow:: anyhow!( "Failed to find EFI vendor dir" ) ) ?;
45
- vendordir
46
- . atomic_write ( "grub.cfg" , STATIC_GRUB_CFG_EFI )
47
- . context ( "Writing static EFI grub.cfg" ) ?;
48
- vendordir
49
- . atomic_write ( GRUB_BOOT_UUID_FILE , uuid)
50
- . with_context ( || format ! ( "Writing {GRUB_BOOT_UUID_FILE}" ) ) ?;
51
-
52
- Ok ( ( ) )
53
- }
54
-
55
20
/// Return `true` if the system is booted via EFI
56
21
pub ( crate ) fn is_efi_booted ( ) -> Result < bool > {
57
22
if !super :: install:: ARCH_USES_EFI {
@@ -74,19 +39,19 @@ pub(crate) fn install_via_bootupd(
74
39
// to only doing that. This is only on x86_64 because that's the only arch that has multiple
75
40
// components right now.
76
41
// TODO: Add --component=auto which moves this logic into bootupd
77
- let ( install_efi , component_args) = if cfg ! ( target_arch = "x86_64" ) && is_alongside {
42
+ let component_args = if cfg ! ( target_arch = "x86_64" ) && is_alongside {
78
43
assert ! ( super :: install:: ARCH_USES_EFI ) ;
79
44
let install_efi = is_efi_booted ( ) ?;
80
45
let component_arg = if install_efi {
81
46
"--component=EFI"
82
47
} else {
83
48
"--component=BIOS"
84
49
} ;
85
- ( install_efi , Some ( component_arg) )
50
+ Some ( component_arg)
86
51
} else {
87
- ( super :: install :: ARCH_USES_EFI , None )
52
+ None
88
53
} ;
89
- let args = [ "backend" , "install" ]
54
+ let args = [ "backend" , "install" , "--with-static-configs" ]
90
55
. into_iter ( )
91
56
. chain ( verbose)
92
57
. chain ( component_args)
@@ -104,26 +69,7 @@ pub(crate) fn install_via_bootupd(
104
69
let bootfs = & rootfs. join ( "boot" ) ;
105
70
let bootfs =
106
71
Dir :: open_ambient_dir ( bootfs, cap_std:: ambient_authority ( ) ) . context ( "Opening boot" ) ?;
107
-
108
- if super :: install:: ARCH_USES_EFI && install_efi {
109
- let efidir = bootfs. open_dir ( "efi" ) . context ( "Opening efi" ) ?;
110
- install_grub2_efi ( & efidir, & grub2_uuid_contents) ?;
111
- }
112
-
113
- bootfs
114
- . ensure_dir_with ( "grub2" , & DirBuilder :: new ( ) )
115
- . context ( "Creating boot/grub2" ) ?;
116
- let grub2 = bootfs. open_dir ( "grub2" ) ?;
117
-
118
- // Mode 0700 to support passwords etc.
119
- grub2. set_permissions ( "." , Permissions :: from_mode ( 0o700 ) ) ?;
120
- grub2
121
- . atomic_write_with_perms (
122
- "grub.cfg" ,
123
- STATIC_GRUB_CFG ,
124
- cap_std:: fs:: Permissions :: from_mode ( 0o600 ) ,
125
- )
126
- . context ( "Writing grub.cfg" ) ?;
72
+ let grub2 = bootfs. open_dir ( "grub2" ) . context ( "Opening boot/grub2" ) ?;
127
73
128
74
grub2
129
75
. atomic_write_with_perms (
0 commit comments