From 62e6db1a0d4a1708867131473c9f48e2d8c9d523 Mon Sep 17 00:00:00 2001
From: davidovski <david@davidovski.xyz>
Date: Tue, 18 Jan 2022 16:41:30 +0000
Subject: added efi tools

---
 repo/system/efibootmgr.xibuild | 20 ++++++++++++++++++++
 repo/system/efivar.xibuild     | 20 ++++++++++++++++++++
 repo/system/grub.xibuild       | 12 ++++++++++--
 repo/util/dosfstools.xibuild   | 27 +++++++++++++++++++++++++++
 4 files changed, 77 insertions(+), 2 deletions(-)
 create mode 100644 repo/system/efibootmgr.xibuild
 create mode 100644 repo/system/efivar.xibuild
 create mode 100644 repo/util/dosfstools.xibuild

diff --git a/repo/system/efibootmgr.xibuild b/repo/system/efibootmgr.xibuild
new file mode 100644
index 0000000..82020cf
--- /dev/null
+++ b/repo/system/efibootmgr.xibuild
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+DEPS=(efivar popt)
+
+PKG_VER=17
+SOURCE=https://github.com/rhboot/efibootmgr/archive/$PKG_VER/efibootmgr-$PKG_VER.tar.gz
+DESC="Tools and libraries to manipulate EFI variables"
+
+prepare () {
+    # fix an outdated hotfix declaration causing compilation failure
+    sed -e '/extern int efi_set_verbose/d' -i src/efibootmgr.c
+}
+
+build () {
+    make EFIDIR=XI EFI_LOADER=grubx64.efi
+}
+
+package () {
+    make EFIDIR=XI DESTDIR=$PKG_DEST install 
+}
diff --git a/repo/system/efivar.xibuild b/repo/system/efivar.xibuild
new file mode 100644
index 0000000..0d52229
--- /dev/null
+++ b/repo/system/efivar.xibuild
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+DEPS=()
+
+PKG_VER=37
+SOURCE=https://github.com/rhboot/efivar/releases/download/$PKG_VER/efivar-$PKG_VER.tar.bz2
+DESC="Tools and libraries to manupulate EFI variables"
+
+prepare () {
+    curl -SsL https://www.linuxfromscratch.org/patches/blfs/svn/efivar-$PKG_VER-gcc_9-1.patch > efivar-$PKG_VER.patch
+    patch -Np1 -i efivar-$PKG_VER.patch
+}
+
+build () {
+    make CFLAGS="-O2 -Wno-stringop-truncation"
+}
+
+package () {
+    make LIBDIR=/usr/lib DESTDIR=$PKG_DEST install 
+}
diff --git a/repo/system/grub.xibuild b/repo/system/grub.xibuild
index ff2b85e..3e8c1c2 100644
--- a/repo/system/grub.xibuild
+++ b/repo/system/grub.xibuild
@@ -1,13 +1,21 @@
 #!/bin/bash
 
-DEPS=(sh xz gettext device-mapper)
+DEPS=(sh xz gettext device-mapper efibootmgr)
 
 PKG_VER=2.06
 SOURCE=https://ftp.gnu.org/gnu/grub/grub-$PKG_VER.tar.xz
 DESC="GNU GRand Unified Bootloader v2"
 
+prepare () {
+    curl -SsL https://unifoundry.com/pub/unifont/unifont-13.0.06/font-builds/unifont-13.0.06.pcf.gz > unifont-13.0.06.pcf.gz
+    gunzip -c unifont-13.0.06.pcf.gz > /usr/share/fonts/unifont/unifont.pcf
+
+    unset {C,CPP,CXX,LD}FLAGS
+}
+
 build () {
-    ./configure --prefix=/usr --sysconfdir=/etc --disable-werror
+    ./configure --prefix=/usr --sysconfdir=/etc --disable-werror \
+        --disable-efiemu --enable-grub-mkfont --with-platform=efi
     make 
 }
 
diff --git a/repo/util/dosfstools.xibuild b/repo/util/dosfstools.xibuild
new file mode 100644
index 0000000..c84fc30
--- /dev/null
+++ b/repo/util/dosfstools.xibuild
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+DEPS=()
+
+PKG_VER=4.2
+SOURCE=https://github.com/dosfstools/dosfstools/releases/download/v$PKG_VER/dosfstools-$PKG_VER.tar.gz
+DESC="Utilities for use with the FAT familiy of file systems"
+
+prepare () {
+    curl -SsL https://unifoundry.com/pub/unifont/unifont-13.0.06/font-builds/unifont-13.0.06.pcf.gz > unifont-13.0.06.pcf.gz
+    gunzip -c unifont-13.0.06.pcf.gz > /usr/share/fonts/unifont/unifont.pcf
+
+    unset {C,CPP,CXX,LD}FLAGS
+}
+
+build () {
+    ./configure --prefix=/usr        \
+            --enable-compat-symlinks \
+            --mandir=/usr/share/man  \
+            --docdir=/usr/share/doc/dosfstools-$PKG_VER &&
+    make
+
+}
+
+package () {
+    make DESTDIR=$PKG_DEST install 
+}
-- 
cgit v1.2.1