# Contributor: Denis Burkov <hitechshell@mail.ru>
maintainer="Denis Burkov <hitechshell@mail.ru>"
pkgname=u-boot-pocketbook-614-plus
pkgver=2024.01
pkgrel=0
pkgdesc="U-Boot bootloader for Pocketbook 614 Plus"
url="https://source.denx.de/u-boot"
arch="armv7"
license="GPL-2.0-or-later OFL-1.1 BSD-2-Clause BSD-3-Clause eCos-2.0 IBM-pibs
	ISC LGPL-2.0-only LGPL-2.1-only X11"
makedepends="$depends_dev
	bc
	bison
	dtc
	flex
	openssl-dev
	py3-setuptools
	python3-dev
	swig
	"
options="!check"
source="
	https://source.denx.de/u-boot/u-boot/-/archive/v$pkgver/u-boot-v$pkgver.tar.gz
	0001-ARM-dts-allwinner-sun5i-a13-pocketbook-614-plus-Add-.patch
	0002-ARM-add-defconfig-for-PocketBook-614-Plus.patch
"
builddir="$srcdir/u-boot-v$pkgver"

build() {
	touch include/config.h
	LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > include/timestamp_autogenerated.h
	LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> include/timestamp_autogenerated.h
	export BUILD_DIR="$builddir"/build

	make O="$BUILD_DIR" A13-pocketbook614plus_defconfig
	make O="$BUILD_DIR" all
	sha512sum -b "$BUILD_DIR/u-boot-sunxi-with-spl.bin" > "$BUILD_DIR/u-boot-sunxi-with-spl.bin.sha512"
}

package() {
	install -Dm644 "build/u-boot-sunxi-with-spl.bin" \
		-t "$pkgdir/usr/share/u-boot/pocketbook-614-plus"
	install -Dm644 "build/u-boot-sunxi-with-spl.bin.sha512" \
		-t "$pkgdir/usr/share/u-boot/pocketbook-614-plus"
}
sha512sums="
82c78fc35ec1462c2f1d6193c8b8dfbf3cbabca905d043916d7ba55f5570fada87c32a4906b46b9af89ec1706308b21bb23281e7126f40e1ec57e0b431675fd8  u-boot-v2024.01.tar.gz
b1271dbb462c9cb6ea02baf3f954d0c09e7de1610086e7b95862538911465d0754b96a2e1be7048b5d3f6aeb314da5ef9eb290622cd6099266a8e3ba7e7609ca  0001-ARM-dts-allwinner-sun5i-a13-pocketbook-614-plus-Add-.patch
3447a3614499a7ffcfdabb70b1c2d33945c1ace258d87ad2ab013ad2c5501fcd030c6f9902246bfc2c91892437fc7e230a663887954c877fe9d404bba943582a  0002-ARM-add-defconfig-for-PocketBook-614-Plus.patch
"
