# Template file for 'vboot-utils'
pkgname=vboot-utils
version=45.7262
revision=13
archs="x86_64* i686* aarch64* arm*"
_githash=0e8c964915fffb58032bb59bdb31949de718ca90
hostmakedepends="pkg-config git"
makedepends="libressl-devel libuuid-devel liblzma-devel libyaml-devel"
short_desc="Verified boot kernel utilities"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="BSD-3-Clause"
homepage="https://chromium.googlesource.com/chromiumos/platform/vboot_reference.git"
CFLAGS='-D_GNU_SOURCE -Wno-error -fcommon'

case "$XBPS_TARGET_MACHINE" in
	aarch64*) broken="https://build.voidlinux.org/builders/aarch64-musl_builder/builds/8508/steps/shell_3/logs/stdio" ;;
esac

do_fetch() {
	git clone https://chromium.googlesource.com/chromiumos/platform/vboot_reference.git $pkgname-$version || true
	cd $pkgname-$version
	git checkout $_githash
}

do_build() {
	local _arch=
	sed -i "s/MTD_CHAR_MAJOR/90/" cgpt/cgpt_wrapper.c
	case $XBPS_TARGET_MACHINE in
		x86_64*) _arch=x86_64 ;;
		i686*) _arch=x86 ;;
		arm*) _arch=arm ;;
	esac
	make CC="$CC" LD="$CC" AR="$AR" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
		MINIMAL=1 ARCH=$_arch ${makejobs} \
		cgpt utils futil
}

do_install() {
	make STRIP=true DESTDIR=${DESTDIR} MINIMAL=1 install
	vmkdir usr/share/vboot
	vcopy tests/devkeys usr/share/vboot/devkeys
	vlicense LICENSE
}
