patches and low-level development discussion
 help / color / mirror / code / Atom feed
* [PATCH] installer: operate on FAT image directly
@ 2022-02-01 17:51 Alyssa Ross
  0 siblings, 0 replies; only message in thread
From: Alyssa Ross @ 2022-02-01 17:51 UTC (permalink / raw)
  To: devel; +Cc: Yureka

---
It feels cleaner to me to operate directly on the FAT image, rather
than constructing the directory on the build filesystem and then
copying it into the FAT image at the end.  But, I'm wondering if maybe
there's a reason it's better to do it the other way that I've missed?

 installer/default.nix | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/installer/default.nix b/installer/default.nix
index f7e84ac..0818091 100644
--- a/installer/default.nix
+++ b/installer/default.nix
@@ -24,6 +24,7 @@ let
 
   esp = runCommand "esp.img" {
     nativeBuildInputs = [ grub libfaketime dosfstools mtools ];
+    grubTargetDir = "${grub}/lib/grub/${grub.grubTarget}";
     # Definition copied from util/grub-install-common.c.
     # Last checked: GRUB 2.06
     pkglib_DATA = [
@@ -31,23 +32,23 @@ let
       "parttool.lst" "video.lst" "crypto.lst" "terminal.lst" "modinfo.sh"
     ];
   } ''
-    mkdir -p files/grub/${grub.grubTarget}
-    cp ${grubCfg} files/grub/grub.cfg
-    cp ${grub}/lib/grub/${grub.grubTarget}/*.mod files/grub/${grub.grubTarget}
+    truncate -s 15M $out
+    faketime "1970-01-01 00:00:00" mkfs.vfat -i 0x2178694e -n EFI $out
+    mmd -i $out ::/EFI ::/EFI/BOOT \
+        ::/grub ::/grub/${grub.grubTarget} ::/grub/fonts
+
+    mcopy -i $out ${grubCfg} ::/grub/grub.cfg
+    mcopy -i $out $grubTargetDir/*.mod ::/grub/${grub.grubTarget}
     for file in $pkglib_DATA; do
-        path="${grub}/lib/grub/${grub.grubTarget}/$file"
-        ! [ -e "$path" ] || cp "$path" files/grub/${grub.grubTarget}
+        path="$grubTargetDir/$file"
+        ! [ -e "$path" ] || mcopy -i $out "$path" ::/grub/${grub.grubTarget}
     done
+    mcopy -i $out ${grub}/share/grub/unicode.pf2 ::/grub/fonts
 
-    install -D ${grub}/share/grub/unicode.pf2 files/grub/fonts/unicode.pf2
     grub-mkimage -o grubx64.efi -p "(hd0,gpt1)/grub" -O ${grub.grubTarget} part_gpt fat
-    install -D grubx64.efi files/EFI/BOOT/BOOTX64.EFI
+    mcopy -i $out grubx64.efi ::/EFI/BOOT/BOOTX64.EFI
 
-    img=$out
-    truncate -s 15M $img
-    faketime "1970-01-01 00:00:00" mkfs.vfat -i 0x2178694e -n EFI $img
-    (cd files; mcopy -psvm -i $img ./* ::)
-    fsck.vfat -vn $img
+    fsck.vfat -n $out
   '';
 
   installer = runCommand "installer.img" {
-- 
2.33.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-02-01 17:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-01 17:51 [PATCH] installer: operate on FAT image directly Alyssa Ross

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).