# Maintainer: Barnabas Czeman <trabarni@gmail.com>
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm64/configs/riva_defconfig

pkgname=linux-xiaomi-riva
pkgver=4.9.337
pkgrel=0
pkgdesc="Xiaomi Redmi 5A kernel fork"
arch="aarch64"
_carch="arm64"
_flavor="xiaomi-riva"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="bash bc bison devicepkg-dev flex openssl-dev perl"

# Source
_repository="android_kernel_xiaomi_msm8937"
_commit="1c2aef5588be23134801cfa304b1b30168367811"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz
	$_config
	fix-xorg-mdss-update-fb-info.patch
	99_framebuffer.patch
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"

prepare() {
	default_prepare
	. downstreamkernel_prepare
}

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

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

sha512sums="
723376e9ce54f1d7745e45658690ea503d716792638716275e0d47bb8bfdf83ce635555c28b1be80a660e1e391f0124ad264aa135ed9b4e08a2d63cb5f9beb78  linux-xiaomi-riva-1c2aef5588be23134801cfa304b1b30168367811.tar.gz
e271cddb8401e8aa1f0d729d83064ad0c6ca3cd46e9105a7b281aedfb39eab867aa72c69c7322b716b897d27b6598ea19b7e2d2fedf1f3a8f7e00a29107e8148  config-xiaomi-riva.aarch64
e11a1ca524a05a5fe8b845937dbc57ee38c52e0a1a979d8e7be0ac53df22f84dfb424205ee7f541acfca3daba3e9f5d49bb4b9e9bb482eb354de14eb28bd0094  fix-xorg-mdss-update-fb-info.patch
741a46c6679172639568df96614b12a543563895ddee79051d88d28742b26d9c725f1d03dc208152c46e87b8b58240a3e206877da9a6a72035095e0f43458a72  99_framebuffer.patch
"
