From ac0c59c3c8a18a7e4815edda6fb37e4e71e5f455 Mon Sep 17 00:00:00 2001
From: jane400 <alpine@j4ne.de>
Date: Fri, 3 May 2024 19:40:59 +0200
Subject: [PATCH] community/edk2: add -shell subpackage

---
 community/edk2/APKBUILD | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/community/edk2/APKBUILD b/community/edk2/APKBUILD
index d8aba6ac44bd..9f8d924c215a 100644
--- a/community/edk2/APKBUILD
+++ b/community/edk2/APKBUILD
@@ -6,14 +6,14 @@ pkgver=0.0.202308
 _realver=edk2-stable${pkgver##*.}
 _sslver=3.0.9
 _sfver=3e
-pkgrel=0
+pkgrel=1
 pkgdesc="EFI Development Kit II"
 url="https://github.com/tianocore/tianocore.github.io/wiki/EDK-II/"
 arch="x86_64 aarch64"
 license="BSD-2-Clause-Patent"
 makedepends="bash python3 iasl nasm util-linux-dev util-linux-misc"
 options="!archcheck !check" # has no checks
-subpackages="$pkgname-pyc"
+subpackages="$pkgname-pyc $pkgname-shell:_shell"
 _mipisyst_commit=370b5944c046bab043dd8b133727b2135af7747a
 source="$pkgname-$pkgver.tar.gz::https://github.com/tianocore/edk2/archive/$_realver.tar.gz
 	mipisyst-$_mipisyst_commit.tar.gz::https://github.com/MIPI-Alliance/public-mipi-sys-t/archive/$_mipisyst_commit.tar.gz
@@ -25,19 +25,20 @@ source="$pkgname-$pkgver.tar.gz::https://github.com/tianocore/edk2/archive/$_rea
 	"
 builddir="$srcdir/$pkgname-$_realver"
 
+PLATFORM="ShellPkg/ShellPkg.dsc"
 case "$CARCH" in
 	x86)
 		TARGET_ARCH=IA32
-		PLATFORM=OvmfPkg/OvmfPkgIa32X64.dsc
+		PLATFORM="$PLATFORM OvmfPkg/OvmfPkgIa32X64.dsc"
 		;;
 	x86_64)
 		TARGET_ARCH=X64
-		PLATFORM="OvmfPkg/OvmfPkgX64.dsc OvmfPkg/OvmfXen.dsc"
+		PLATFORM="$PLATFORM OvmfPkg/OvmfPkgX64.dsc OvmfPkg/OvmfXen.dsc"
 		subpackages="$subpackages ovmf:_ovmf:noarch ovmf-xen:_xen:noarch"
 		;;
 	aarch64)
 		TARGET_ARCH=AARCH64
-		PLATFORM=ArmVirtPkg/ArmVirtQemu.dsc
+		PLATFORM="$PLATFORM ArmVirtPkg/ArmVirtQemu.dsc"
 		subpackages="$subpackages aavmf::noarch"
 		;;
 esac
@@ -110,6 +111,22 @@ package() {
 	done
 }
 
+_shell() {
+	pkgdesc="EDK2 UEFI Shell"
+
+	# taken from arch
+	# minimal UEFI shell, as defined in ShellPkg/Application/Shell/Shell.inf
+	local _min='7C04A583-9E3E-4f1c-AD65-E05268D0B4D1'
+	# full UEFI shell, as defined in ShellPkg/ShellPkg.dsc
+	local _full='EA4BB293-2D7F-4456-A681-1F22F42CD0BC'
+
+	install -D "$builddir"/Build/Shell/"$RELEASE"_"$TOOLCHAIN"/$TARGET_ARCH/Shell_$_min.efi \
+		"$subpkgdir"/usr/share/edk2-shell/Shell.efi
+
+	install -D "$builddir"/Build/Shell/"$RELEASE"_"$TOOLCHAIN"/$TARGET_ARCH/Shell_$_full.efi \
+		"$subpkgdir"/usr/share/edk2-shell/ShellFull.efi
+}
+
 _ovmf() {
 	pkgdesc="Open Virtual Machine Firmware (OVMF) BIOS"
 	license="BSD MIT"
-- 
GitLab