#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=efivar
pkgdesc="Tools and libraries to work with EFI variables"
pkgver=38
pkgrel=03
url="https://github.com/rhboot/efivar"
depends=(glibc)
makedepends=(git mandoc)
provides=(libefiboot.so libefisec.so libefivar.so)
# LTO has the linker segfaulting with binutils < 2.38.0: https://github.com/rhboot/efivar/issues/196
options=(!lto)
source=(
  git+$url#tag=${pkgver}?signed
  $pkgname-38-ld_t.patch::https://github.com/rhboot/efivar/pull/201/commits/197a0874ea4010061b98b4b55eff65b33b1cd741.patch
)

prepare() {
  # fix issues with linker scripts: https://github.com/rhboot/efivar/pull/201
  patch -Np1 -d $pkgname -i ../$pkgname-38-ld_t.patch
}

build() {
  # disable -Werror by default by setting ERRORS to empty string
  make ERRORS='' all -C "${pkgname}"
}

check() {
  make GRUB_PREFIX=grub test -k -C "${pkgname}" || echo "grub related tests are flaky"
}

package() {
  make DESTDIR="${pkgdir}/" \
       libdir=/usr/lib/ \
       bindir=/usr/bin/ \
       mandir=/usr/share/man/ \
       includedir=/usr/include/ \
       install -j1 V=1 \
       -C "${pkgname}"
  install -vDm 644 "${pkgname}/"{README.md,TODO} -t "${pkgdir}/usr/share/doc/${pkgname}"
}


#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=('LGPL2.1')

validpgpkeys=('B00B48BC731AA8840FED9FB0EED266B70F4FEF10') # Peter Jones <pjones@redhat.com>

sha256sums=(SKIP
	9450812114f409229bd97211902de8000d2b321c8b4f4e20c31eb4e555625655) # efivar-38-ld_t.patch

##  805719cc1e7fae471494f4ca41d2aa1b6ff24c2ecbc5c5a9d1107f7c149fc26c  efivar-38-03-x86_64.pkg.tar.lz


