From 66f4368afc5696585724b21372305b07bdcc9009 Mon Sep 17 00:00:00 2001
From: Keshav P R <the.ridikulus.rat@gmail.com>
Date: Sat, 15 Sep 2012 20:36:38 +0530
Subject: [PATCH] Use gummiboot-efi-x86_64 instead of UEFI Shell for booting

---
 configs/releng/build.sh                            | 55 +++++++++++++++-------
 .../efiboot/loader/entries/archiso-x86_64-cd.conf  |  4 ++
 .../efiboot/loader/entries/archiso-x86_64-usb.conf |  4 ++
 .../loader/entries/uefi-shell-v1-x86_64.conf       |  2 +
 .../loader/entries/uefi-shell-v2-x86_64.conf       |  2 +
 configs/releng/efiboot/loader/loader.conf          |  2 +
 configs/releng/packages.x86_64                     |  1 +
 7 files changed, 53 insertions(+), 17 deletions(-)
 create mode 100644 configs/releng/efiboot/loader/entries/archiso-x86_64-cd.conf
 create mode 100644 configs/releng/efiboot/loader/entries/archiso-x86_64-usb.conf
 create mode 100644 configs/releng/efiboot/loader/entries/uefi-shell-v1-x86_64.conf
 create mode 100644 configs/releng/efiboot/loader/entries/uefi-shell-v2-x86_64.conf
 create mode 100644 configs/releng/efiboot/loader/loader.conf

diff --git a/configs/releng/build.sh b/configs/releng/build.sh
index 63cbad0..df089d4 100755
--- a/configs/releng/build.sh
+++ b/configs/releng/build.sh
@@ -69,6 +69,28 @@ make_boot() {
 make_boot_efi() {
     if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
         if [[ ${arch} == "x86_64" ]]; then
+            ## Start - UEFI USB
+
+            mkdir -p ${work_dir}/iso/EFI/boot
+            cp ${work_dir}/root-image/boot/efi/EFI/gummiboot/gummibootx64.efi ${work_dir}/iso/EFI/boot/bootx64.efi
+
+            mkdir -p ${work_dir}/iso/loader/entries
+            cp ${script_path}/efiboot/loader/loader.conf ${work_dir}/iso/loader/loader.conf
+            cp ${script_path}/efiboot/loader/entries/uefi-shell-v2-x86_64.conf ${work_dir}/iso/loader/entries/uefi-shell-v2-x86_64.conf
+            cp ${script_path}/efiboot/loader/entries/uefi-shell-v1-x86_64.conf ${work_dir}/iso/loader/entries/uefi-shell-v1-x86_64.conf
+
+            sed "s|%ARCHISO_LABEL%|${iso_label}|g;
+                 s|%INSTALL_DIR%|${install_dir}|g" ${script_path}/efiboot/loader/entries/archiso-x86_64-usb.conf > ${work_dir}/iso/loader/entries/archiso-x86_64.conf
+
+            # EFI Shell 2.0 for UEFI 2.3+ ( http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=UEFI_Shell )
+            wget -O ${work_dir}/iso/EFI/shellx64_v2.efi https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/ShellBinPkg/UefiShell/X64/Shell.efi
+            # EFI Shell 1.0 for non UEFI 2.3+ ( http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Efi-shell )
+            wget -O ${work_dir}/iso/EFI/shellx64_v1.efi https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/X64/Shell_Full.efi
+
+            ## End - UEFI USB
+
+            ## Start - UEFI CD
+
             mkdir -p ${work_dir}/iso/EFI/archiso
             dd of=${work_dir}/iso/EFI/archiso/efiboot.img bs=1 seek=20M count=0
             mkfs.vfat ${work_dir}/iso/EFI/archiso/efiboot.img
@@ -80,29 +102,28 @@ make_boot_efi() {
             cp ${work_dir}/iso/${install_dir}/boot/x86_64/vmlinuz ${work_dir}/efiboot/EFI/archiso/vmlinuz.efi
             cp ${work_dir}/iso/${install_dir}/boot/x86_64/archiso.img ${work_dir}/efiboot/EFI/archiso/archiso.img
 
-            # There are plans to support command line options via a config file (not yet in linux-3.3)
-            #cp ${work_dir}/iso/${install_dir}/boot/x86_64/vmlinuz ${work_dir}/efiboot/EFI/boot/bootx64.efi
-            #cp ${work_dir}/iso/${install_dir}/boot/x86_64/archiso.img ${work_dir}/efiboot/EFI/boot/linux.img
-            #echo "archisolabel=${iso_label} initrd=\EFI\boot\linux.img" | iconv -f ascii -t ucs2 > ${work_dir}/iso/EFI/boot/linux.conf
-
-            # For now, provide an EFI-shell until 'linux.conf' hits mainline.
             mkdir -p ${work_dir}/efiboot/EFI/boot
-            # EFI Shell 2.0 for UEFI 2.3+ ( http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=UEFI_Shell )
-            #wget -O ${work_dir}/efiboot/EFI/boot/bootx64.efi https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/ShellBinPkg/UefiShell/X64/Shell.efi
-            # EFI Shell 1.0 for non UEFI 2.3+ ( http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Efi-shell )
-            wget -O ${work_dir}/efiboot/EFI/boot/bootx64.efi https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/X64/Shell_Full.efi
+            cp ${work_dir}/root-image/boot/efi/EFI/gummiboot/gummibootx64.efi ${work_dir}/efiboot/EFI/boot/bootx64.efi
 
-            # Add an EFI shell script for automatic boot if ESC-key is not pressed within 5 seconds timeout.
-            sed "s|%ARCHISO_LABEL%|${iso_label}|g;
-                 s|%INSTALL_DIR%|${install_dir}|g" ${script_path}/efiboot/EFI/boot/startup_iso.nsh > ${work_dir}/efiboot/EFI/boot/startup.nsh
-
-            mkdir -p ${work_dir}/iso/EFI/boot
-            cp ${work_dir}/efiboot/EFI/boot/bootx64.efi ${work_dir}/iso/EFI/boot/bootx64.efi
+            mkdir -p ${work_dir}/efiboot/loader/entries
+            cp ${script_path}/efiboot/loader/loader.conf ${work_dir}/efiboot/loader/loader.conf
+            cp ${script_path}/efiboot/loader/entries/uefi-shell-v2-x86_64.conf ${work_dir}/efiboot/loader/entries/uefi-shell-v2-x86_64.conf
+            cp ${script_path}/efiboot/loader/entries/uefi-shell-v1-x86_64.conf ${work_dir}/efiboot/loader/entries/uefi-shell-v1-x86_64.conf
 
             sed "s|%ARCHISO_LABEL%|${iso_label}|g;
-                 s|%INSTALL_DIR%|${install_dir}|g" ${script_path}/efiboot/EFI/boot/startup_usb.nsh > ${work_dir}/iso/EFI/boot/startup.nsh
+                 s|%INSTALL_DIR%|${install_dir}|g" ${script_path}/efiboot/loader/entries/archiso-x86_64-cd.conf > ${work_dir}/efiboot/loader/entries/archiso-x86_64.conf
 
+            cp ${work_dir}/iso/EFI/shellx64_v2.efi ${work_dir}/efiboot/EFI/shellx64_v2.efi
+            cp ${work_dir}/iso/EFI/shellx64_v1.efi ${work_dir}/efiboot/EFI/shellx64_v1.efi
+            
+            # There are plans to support command line options via a config file (not yet in linux-3.3)
+            #cp ${work_dir}/iso/${install_dir}/boot/x86_64/vmlinuz ${work_dir}/efiboot/EFI/boot/bootx64.efi
+            #cp ${work_dir}/iso/${install_dir}/boot/x86_64/archiso.img ${work_dir}/efiboot/EFI/boot/archiso.img
+            #echo "archisobasedir=${install_dir} archisolabel=${iso_label} initrd=\\EFI\\boot\\archiso.img" > ${work_dir}/efiboot/EFI/boot/linux.conf
+            
             umount ${work_dir}/efiboot
+
+            ## End - UEFI CD
         fi
         : > ${work_dir}/build.${FUNCNAME}
     fi
diff --git a/configs/releng/efiboot/loader/entries/archiso-x86_64-cd.conf b/configs/releng/efiboot/loader/entries/archiso-x86_64-cd.conf
new file mode 100644
index 0000000..9892c59
--- /dev/null
+++ b/configs/releng/efiboot/loader/entries/archiso-x86_64-cd.conf
@@ -0,0 +1,4 @@
+title   Arch Linux archiso x86_64 UEFI CD
+linux   /EFI/archiso/vmlinuz.efi
+initrd  /EFI/archiso/archiso.img
+options archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL%
diff --git a/configs/releng/efiboot/loader/entries/archiso-x86_64-usb.conf b/configs/releng/efiboot/loader/entries/archiso-x86_64-usb.conf
new file mode 100644
index 0000000..f61c532
--- /dev/null
+++ b/configs/releng/efiboot/loader/entries/archiso-x86_64-usb.conf
@@ -0,0 +1,4 @@
+title   Arch Linux archiso x86_64 UEFI USB
+linux   /%INSTALL_DIR%/boot/x86_64/vmlinuz
+initrd  /%INSTALL_DIR%/boot/x86_64/archiso.img
+options archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL%
diff --git a/configs/releng/efiboot/loader/entries/uefi-shell-v1-x86_64.conf b/configs/releng/efiboot/loader/entries/uefi-shell-v1-x86_64.conf
new file mode 100644
index 0000000..9597ff2
--- /dev/null
+++ b/configs/releng/efiboot/loader/entries/uefi-shell-v1-x86_64.conf
@@ -0,0 +1,2 @@
+title  UEFI Shell x86_64 v1
+efi    /EFI/shellx64_v1.efi
diff --git a/configs/releng/efiboot/loader/entries/uefi-shell-v2-x86_64.conf b/configs/releng/efiboot/loader/entries/uefi-shell-v2-x86_64.conf
new file mode 100644
index 0000000..0dde77a
--- /dev/null
+++ b/configs/releng/efiboot/loader/entries/uefi-shell-v2-x86_64.conf
@@ -0,0 +1,2 @@
+title  UEFI Shell x86_64 v2
+efi    /EFI/shellx64_v2.efi
diff --git a/configs/releng/efiboot/loader/loader.conf b/configs/releng/efiboot/loader/loader.conf
new file mode 100644
index 0000000..62c4a83
--- /dev/null
+++ b/configs/releng/efiboot/loader/loader.conf
@@ -0,0 +1,2 @@
+timeout 3
+default archiso-x86_64
diff --git a/configs/releng/packages.x86_64 b/configs/releng/packages.x86_64
index a5be3c4..4c1851f 100644
--- a/configs/releng/packages.x86_64
+++ b/configs/releng/packages.x86_64
@@ -17,6 +17,7 @@ gptfdisk
 grml-zsh-config
 grub-bios
 grub-efi-x86_64
+gummiboot-efi-x86_64
 haveged
 hdparm
 ipw2100-fw
-- 
1.7.12

