pkgname=linux-postmarketos-grate
pkgver=6.1.0
pkgrel=0
arch="armv7"
pkgdesc="Linux kernel with experimental patches for Tegra"
url="https://postmarketos.org"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev
	     devicepkg-dev bison flex openssl-dev xz findutils"
options="!strip !check !tracedeps pmb:cross-native pmb:kconfigcheck-community"
license="GPL-2.0-only"

# Source
_flavor=postmarketos-grate
_commit="ba4fe02fc7658a300985fd36adee3f630c309d09"
_carch="arm"
_config="config-$_flavor.$arch"
source="$pkgname-$pkgver-$_commit.tar.gz::https://github.com/grate-driver/linux/archive/$_commit.tar.gz
	$_config"
builddir="$srcdir/linux-$_commit"
_outdir="out"

prepare() {
	default_prepare
	REPLACE_GCCH=0 \
		. downstreamkernel_prepare
}

build() {
	unset LDFLAGS
	make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-$_flavor"
}

package() {
	downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor" "$_outdir"

	make modules_install dtbs_install \
		O="$_outdir" ARCH="$_carch" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_DTBS_PATH="$pkgdir/boot/dtbs"
}

sha512sums="
2649932e50c1cacb211c10995d7b6e44ecf567670a7117106bfd2aa467af164b0ad26891d4babd53f2cabb5cc41a806f0a1e2a94067283b67cc4c3218a2f78b8  linux-postmarketos-grate-6.1.0-ba4fe02fc7658a300985fd36adee3f630c309d09.tar.gz
4f918fd996f9f0c6c9418fa9d7c360db196c00b54ca4c8991fd5769efd95102c43150086c0e81a0de7f103548136026d434a65604462188fac7b1bbef8098951  config-postmarketos-grate.armv7
"
