@@ -36,8 +36,8 @@ use anyhow::Context;
3636
3737use tempfile:: NamedTempFile ;
3838
39- pub use bootloader_boot_config:: BootConfig ;
4039use crate :: file_data_source:: FileDataSource ;
40+ pub use bootloader_boot_config:: BootConfig ;
4141
4242const KERNEL_FILE_NAME : & str = "kernel-x86_64" ;
4343const RAMDISK_FILE_NAME : & str = "ramdisk" ;
@@ -85,9 +85,13 @@ impl DiskImageBuilder {
8585 let bytes = json. as_bytes ( ) ;
8686 self . add_or_replace_file ( FileDataSource :: Data ( bytes. to_vec ( ) ) , CONFIG_FILE_NAME )
8787 }
88-
88+
8989 /// Add or replace arbitrary files.
90- pub fn add_or_replace_file ( & mut self , file_data_source : FileDataSource , target : & str ) -> & mut Self {
90+ pub fn add_or_replace_file (
91+ & mut self ,
92+ file_data_source : FileDataSource ,
93+ target : & str ,
94+ ) -> & mut Self {
9195 self . files . insert (
9296 0 ,
9397 DiskImageFile {
@@ -107,10 +111,12 @@ impl DiskImageBuilder {
107111 local_map. insert ( f. destination . as_str ( ) , f. source . clone ( ) ) ;
108112 }
109113
110-
111114 for k in internal_files {
112115 if let Some ( _) = local_map. insert ( k. 0 , k. 1 ) {
113- return Err ( anyhow:: Error :: msg ( format ! ( "Attempted to overwrite internal file: {}" , k. 0 ) ) ) ;
116+ return Err ( anyhow:: Error :: msg ( format ! (
117+ "Attempted to overwrite internal file: {}" ,
118+ k. 0
119+ ) ) ) ;
114120 }
115121 }
116122
@@ -130,8 +136,14 @@ impl DiskImageBuilder {
130136 let stage_3_path = Path :: new ( env ! ( "BIOS_STAGE_3_PATH" ) ) ;
131137 let stage_4_path = Path :: new ( env ! ( "BIOS_STAGE_4_PATH" ) ) ;
132138 let mut internal_files = BTreeMap :: new ( ) ;
133- internal_files. insert ( BIOS_STAGE_3 , FileDataSource :: File ( stage_3_path. to_path_buf ( ) ) ) ;
134- internal_files. insert ( BIOS_STAGE_4 , FileDataSource :: File ( stage_4_path. to_path_buf ( ) ) ) ;
139+ internal_files. insert (
140+ BIOS_STAGE_3 ,
141+ FileDataSource :: File ( stage_3_path. to_path_buf ( ) ) ,
142+ ) ;
143+ internal_files. insert (
144+ BIOS_STAGE_4 ,
145+ FileDataSource :: File ( stage_4_path. to_path_buf ( ) ) ,
146+ ) ;
135147
136148 let fat_partition = self
137149 . create_fat_filesystem_image ( internal_files)
@@ -156,7 +168,10 @@ impl DiskImageBuilder {
156168 const UEFI_BOOT_FILENAME : & str = "efi/boot/bootx64.efi" ;
157169 let bootloader_path = Path :: new ( env ! ( "UEFI_BOOTLOADER_PATH" ) ) ;
158170 let mut internal_files = BTreeMap :: new ( ) ;
159- internal_files. insert ( UEFI_BOOT_FILENAME , FileDataSource :: File ( bootloader_path. to_path_buf ( ) ) ) ;
171+ internal_files. insert (
172+ UEFI_BOOT_FILENAME ,
173+ FileDataSource :: File ( bootloader_path. to_path_buf ( ) ) ,
174+ ) ;
160175 let fat_partition = self
161176 . create_fat_filesystem_image ( internal_files)
162177 . context ( "failed to create FAT partition" ) ?;
@@ -195,7 +210,7 @@ impl DiskImageBuilder {
195210 . create ( true )
196211 . truncate ( true )
197212 . open ( to) ?;
198-
213+
199214 f. source . copy_to ( & mut new_file) ?;
200215 }
201216
0 commit comments