# Maintainer (aur): Nico Huber <nico.h@gmx.de>
# Maintainer: Wael Karram <wael AT waelk.tech>


# Parabola Changes and Rationale
# 1) Clarified license version (GPLv2 only).
# 2) Dropped unsupported architectures.
# 3) removed support for incompatible 'libgpiod'


pkgname="flashprog"
pkgdesc="utility which can be used to detect, read, erase, or write BIOS chips (DIP, PLCC, SPI)"
pkgver=1.0.1
pkgrel=1
url="https://flashprog.org/"
license=('GPL2')
source=(http://flashprog.org/releases/flashprog-v1.0.1.tar.bz2{,.asc})
validpgpkeys=('2853079C9C66AB7E82C64966A5C163B7E557CAEB')
sha256sums=('888863dfc254a9dd7c00dfdac8a31a74879c31db5c16375fb3f216347c03cc71'
            'SKIP')
depends=('pciutils' 'libusb' 'libftdi' 'libjaylink' 'libgpiod')
depends=( ${depends[*]/libgpiod/} ) # libgpiod >=2.0 is incompatible
optdepends=("dmidecode: for SMBIOS/DMI table decoder support")
arch=('riscv64' 'aarch64' 'armv6h' 'armv7h' 'i686' 'x86_64')
arch=( ${arch[*]/armv6h/} )


build() {
	cd "${srcdir}/${pkgname}-v${pkgver}"
	make CONFIG_LINUX_GPIO_SPI=no
}

package() {
	cd "${srcdir}/${pkgname}-v${pkgver}"
	install -d "${pkgdir}/usr/bin"
	install -d "${pkgdir}/usr/man/man8"
	install -m 0755 flashprog "${pkgdir}/usr/bin/"
	install -m 0644 flashprog.8 "${pkgdir}/usr/man/man8/"

	# armv7h fails to build 'ich_descriptors_tool'
	[[ "${CARCH}" == armv7h ]] ||
	install -m 0755 util/ich_descriptors_tool/ich_descriptors_tool "${pkgdir}/usr/bin/"
}
