# Template file for 'efibootmgr'
pkgname=efibootmgr
version=18
revision=0
short_desc="EFI boot manager entries tool"
maintainer="finwo <finwo@pm.me>"
license="GPL-2.0-only"
homepage="https://github.com/rhboot/efibootmgr"
distfiles="https://github.com/rhboot/efibootmgr/archive/refs/tags/18.tar.gz"
checksum=442867d12f8525034a404fc8af3036dba8e1fc970998af2486c3b940dfad0874
# runtime links (readelf-proven at build): libefivar + libpopt.
depends="efivar popt"
makedepends="efivar popt"

# Notes:
# - No configure step; lowercase make vars (prefix/libdir/sbindir) plus
#   EFIDIR, which configure-time *requires* (build errors without it).
#   EFIDIR=unos matches install.sh --bootloader-id=unos, so the compiled
#   DEFAULT_LOADER lands in the right directory (its `grub.efi` filename
#   vs grub-install's `grubx64.efi` only matters for bare `efibootmgr`
#   invocations; grub-install always passes an explicit loader path).
# - efivar + popt resolve from the sysroot via the driver PKG_CONFIG_PATH.
# - sbindir=/usr/sbin (admin tool, matches our layout). No post-install
#   (no .so shipped). Needs efivarfs at RUNTIME (/sys/firmware/efi/efivars
#   - the installer already binds /sys, which carries it on UEFI hosts);
#   without it the tool errors clearly, it never silently no-ops.

do_build() {
  cd "${WRKSRC}"
  make -j"$(nproc)" prefix=/usr libdir=/usr/lib sbindir=/usr/sbin EFIDIR=unos
  [ -x src/efibootmgr ] || die "efibootmgr: binary missing after build"
}

do_install() {
  cd "${WRKSRC}"
  make install prefix=/usr libdir=/usr/lib sbindir=/usr/sbin EFIDIR=unos DESTDIR="${DESTDIR}"
  [ -x "${DESTDIR}/usr/sbin/efibootmgr" ] || die "efibootmgr: not installed"
}
