patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Yureka <yuka@yuka.dev>
To: devel@spectrum-os.org
Cc: Yureka <yuka@yuka.dev>
Subject: [PATCH 2/2] speed up installer image build
Date: Sun, 12 Dec 2021 16:50:36 +0100	[thread overview]
Message-ID: <20211212155036.3624860-2-yuka@yuka.dev> (raw)
In-Reply-To: <20211212155036.3624860-1-yuka@yuka.dev>

---
 installer/default.nix | 33 ++++++++++++++++++++-------------
 installer/grub.cfg.in | 10 ++++++++++
 2 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/installer/default.nix b/installer/default.nix
index 39933d9..8c2a3d0 100644
--- a/installer/default.nix
+++ b/installer/default.nix
@@ -21,6 +21,22 @@ let
     ] ++ config.boot.kernelParams);
   };
 
+  efi = runCommand "efi.img" {
+    nativeBuildInputs = [ grub libfaketime dosfstools mtools ];
+  } ''
+    install -D ${grubCfg} files/grub/grub.cfg
+    cp -r ${grub}/lib/grub/${grub.grubTarget} files/grub/
+    cp ${grub}/share/grub/unicode.pf2 files/grub/
+    grub-mkimage -o grubx64.efi -p "(hd0,gpt1)/grub" -O ${grub.grubTarget} part_gpt fat
+    install -D grubx64.efi files/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
+  '';
+
   installer = runCommand "installer.img" {
     nativeBuildInputs = [ squashfs-tools-ng ];
   } ''
@@ -47,7 +63,7 @@ let
   '');
 in
 
-vmTools.runInLinuxVM (runCommand "spectrum-installer" {
+runCommand "spectrum-installer" {
   nativeBuildInputs = [ dosfstools grub jq kmod util-linux systemdMinimal ];
 } ''
   blockSize() {
@@ -60,7 +76,7 @@ vmTools.runInLinuxVM (runCommand "spectrum-installer" {
       dd if="$3" of="$1" seek="$start" count="$size" conv=notrunc
   }
 
-  efiSize=40000
+  efiSize="$(blockSize ${efi})"
   installerSize="$(blockSize ${installer})"
   eosimagesSize="$(blockSize ${eosimages})"
 
@@ -72,16 +88,7 @@ vmTools.runInLinuxVM (runCommand "spectrum-installer" {
   size=$eosimagesSize, type=56a3bbc3-aefa-43d9-a64d-7b3fd59bbc4e
   EOF
 
+  fillPartition $out 0 ${efi}
   fillPartition $out 1 ${installer}
   fillPartition $out 2 ${eosimages}
-
-  modprobe loop
-  loop="$(losetup -P --show -f $out)"
-  mkfs.vfat "$loop"p1
-  mkdir /mnt
-  mount "$loop"p1 /mnt
-  grub-install --target ${grub.grubTarget} --removable \
-      --boot-directory /mnt --efi-directory /mnt "$loop"
-  cp ${grubCfg} /mnt/grub/grub.cfg
-  umount /mnt
-'')
+''
diff --git a/installer/grub.cfg.in b/installer/grub.cfg.in
index 46171ec..e4370f1 100644
--- a/installer/grub.cfg.in
+++ b/installer/grub.cfg.in
@@ -1,6 +1,16 @@
 # SPDX-License-Identifier: EUPL-1.2
 # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
 
+insmod efi_gop
+insmod efi_uga
+insmod font
+loadfont /grub/unicode.pf2
+insmod gfxterm
+set gfxmode=auto
+set gfxpayload=keep
+terminal_output gfxterm
+set timeout=5
+
 menuentry "Try Spectrum" {
   loopback live (hd0,gpt3)/Spectrum-0.0-x86_64-generic.0.Live.img
   chainloader (live,gpt1)/efi/boot/bootx64.efi
-- 
2.34.0


  reply	other threads:[~2021-12-12 15:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-12 15:50 [PATCH 1/2] increase partition sizes Yureka
2021-12-12 15:50 ` Yureka [this message]
2021-12-16  2:38   ` [PATCH 2/2] speed up installer image build Alyssa Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211212155036.3624860-2-yuka@yuka.dev \
    --to=yuka@yuka.dev \
    --cc=devel@spectrum-os.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).