Skip to content

Commit cf8799b

Browse files
committed
Add apply fixes from bios builder to uefi
1 parent 6703441 commit cf8799b

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/lib.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ impl BiosBoot {
7070
fn create_fat_partition(&self) -> anyhow::Result<NamedTempFile> {
7171
let stage_3_path = Path::new(env!("BIOS_STAGE_3_PATH"));
7272
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"));
7673
let kernel_path = self.kernel.as_path();
7774

7875
let mut files = BTreeMap::new();
@@ -106,11 +103,9 @@ impl UefiBoot {
106103
}
107104

108105
/// 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
114109
}
115110

116111
/// Create a bootable BIOS disk image at the given path.
@@ -146,15 +141,12 @@ impl UefiBoot {
146141
/// Creates an UEFI-bootable FAT partition with the kernel.
147142
fn create_fat_partition(&self) -> anyhow::Result<NamedTempFile> {
148143
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"));
152144
let kernel_path = self.kernel.as_path();
153145
let mut files = BTreeMap::new();
154146
files.insert("efi/boot/bootx64.efi", bootloader_path);
155147
files.insert(KERNEL_FILE_NAME, kernel_path);
156148

157-
if has_rd_path {
149+
if let Some(ramdisk_path) = &self.ramdisk {
158150
files.insert(RAMDISK_FILE_NAME, ramdisk_path);
159151
}
160152

0 commit comments

Comments
 (0)