@@ -70,9 +70,6 @@ impl BiosBoot {
70
70
fn create_fat_partition ( & self ) -> anyhow:: Result < NamedTempFile > {
71
71
let stage_3_path = Path :: new ( env ! ( "BIOS_STAGE_3_PATH" ) ) ;
72
72
let stage_4_path = Path :: new ( env ! ( "BIOS_STAGE_4_PATH" ) ) ;
73
- let has_rd_path = self . ramdisk . is_some ( ) ;
74
- let binding = self . ramdisk . as_deref ( ) ;
75
- let ramdisk_path = binding. unwrap_or ( Path :: new ( "no-such-file" ) ) ;
76
73
let kernel_path = self . kernel . as_path ( ) ;
77
74
78
75
let mut files = BTreeMap :: new ( ) ;
@@ -106,11 +103,9 @@ impl UefiBoot {
106
103
}
107
104
108
105
/// Add a ramdisk file to the disk image
109
- pub fn with_ramdisk ( & self , ramdisk_path : & Path ) -> Self {
110
- Self {
111
- kernel : self . kernel . clone ( ) ,
112
- ramdisk : Some ( ramdisk_path. to_owned ( ) ) ,
113
- }
106
+ pub fn with_ramdisk ( & mut self , ramdisk_path : & Path ) -> & mut Self {
107
+ self . ramdisk = Some ( ramdisk_path. to_owned ( ) ) ;
108
+ self
114
109
}
115
110
116
111
/// Create a bootable BIOS disk image at the given path.
@@ -146,15 +141,12 @@ impl UefiBoot {
146
141
/// Creates an UEFI-bootable FAT partition with the kernel.
147
142
fn create_fat_partition ( & self ) -> anyhow:: Result < NamedTempFile > {
148
143
let bootloader_path = Path :: new ( env ! ( "UEFI_BOOTLOADER_PATH" ) ) ;
149
- let has_rd_path = self . ramdisk . is_some ( ) ;
150
- let binding = self . ramdisk . as_deref ( ) ;
151
- let ramdisk_path = binding. unwrap_or ( Path :: new ( "no-such-file" ) ) ;
152
144
let kernel_path = self . kernel . as_path ( ) ;
153
145
let mut files = BTreeMap :: new ( ) ;
154
146
files. insert ( "efi/boot/bootx64.efi" , bootloader_path) ;
155
147
files. insert ( KERNEL_FILE_NAME , kernel_path) ;
156
148
157
- if has_rd_path {
149
+ if let Some ( ramdisk_path ) = & self . ramdisk {
158
150
files. insert ( RAMDISK_FILE_NAME , ramdisk_path) ;
159
151
}
160
152
0 commit comments