# Archived: Downstream port, only for testing. Use mainline port (xiaomi-lavender)!
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm64/configs/lavender-perf_defconfig
# Original defconfig was: arch/arm64/configs/sdm660-perf_defconfig

pkgname=linux-xiaomi-lavender-downstream
pkgver=4.4.156
pkgrel=0
pkgdesc="Xiaomi Redmi Note 7 kernel fork"
arch="aarch64"
_carch="arm64"
_flavor="xiaomi-lavender"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev devicepkg-dev gcc6 openssl-dev"

# Compile with gcc6, kernel does not boot when built with newer versions
if [ "${CC:0:5}" != "gcc6-" ]; then
	CC="gcc6-$CC"
	HOSTCC="gcc6-gcc"
	CROSS_COMPILE="gcc6-$CROSS_COMPILE"
fi

_repourl="https://github.com/minlexx"
_repository="android_kernel_xiaomi_lavender"
_commit="f0ae55603106e1fa3e55c1ab197df79178755eb2"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::$_repourl/$_repository/archive/$_commit.tar.gz
	$_config
	0001-Use-relative-includes.patch
	0002-Fix-TRACE_INCLUDE_PATH-paths.patch
	0003-Add-config-option-to-fix-bootloader-cmdline-args.patch
	0004-Reduce-battery-spam-in-dmesg.patch
	0005-Adds-and-sets-BGRA-as-default.patch
	0006-mdss-panel-to-fb-var.patch
	0007-nvt-touch-f7a-unbreak-libinput.patch
	linux4.2-gcc10-extern_YYLOC_global_declaration.patch
"

builddir="$srcdir/$_repository-$_commit"

prepare() {
	default_prepare
	. downstreamkernel_prepare
}

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

package() {
	downstreamkernel_package "$builddir" "$pkgdir" $_carch $_flavor
	# External modules install
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS" \
		INSTALL_MOD_PATH="$pkgdir" modules_install
}

sha512sums="
797586ac2757c9b27a5f8fc1c1ff460d959b32de322ff00509d1b3b060dbcc909a150582992e8b5a25b185724d622115fd89a99d07ed10366e1a616a862eb79e  linux-xiaomi-lavender-downstream-f0ae55603106e1fa3e55c1ab197df79178755eb2.tar.gz
ff44ea67bda5f48625acc7385a8d1ba8a6cb7070c4be8505e8448d03ebe1f47bbe45fbadcd8c6e0dde940dfd4160067af56a13886f36d57e1734d7af72b6481b  config-xiaomi-lavender.aarch64
9f1b27e523675ecaafd0ffd884e3e8d0fe9b0bf78b09b5fe044a5d5c9888a86fb0007aa9d90118f0b022a4ace62c5be236097df3bb67a3207a24a766d0907c33  0001-Use-relative-includes.patch
a8713d22404a5e2c0d2add3deb4cb033e972bd1983e10f1557d4de640c1329af50be2bfd92dc3cf76df711a6b4a422b920da76c2d6c4435e3624c85f7d07ae52  0002-Fix-TRACE_INCLUDE_PATH-paths.patch
9ce867c4254b537ef5d2485780c26b72da8a3a8767ba71557f3b48d6c550e0e14c8c3e575b31bf65d2878f08a8a4926e48a1c2f1be534bf80a7a57f58313b0fd  0003-Add-config-option-to-fix-bootloader-cmdline-args.patch
066ac4b77388fd2001df227db216da9f435e06d29ce1be59d8a8923613f3390e154cb5b6cb7785614a3a4b12c01d9f1b84dfd09b884dede3fa6d0e5b1ddb9045  0004-Reduce-battery-spam-in-dmesg.patch
f2a97a9500b6155a11f2341a8fd4b083ceb25a17d656c7975e34b9f3d8bacb495ae687f823db5fd07ddee27b2d95021f193bfadb5274185334255cda12bc85ce  0005-Adds-and-sets-BGRA-as-default.patch
d5b868c64b8ebddcf74cb3aa478f30f0897af1e14e4fc42d977921104a6c568cc0bf36fc8a3b0f538cd3ca2ebf59244fdf23186a903259e5acc14d1c4ef4ccc3  0006-mdss-panel-to-fb-var.patch
e13adff827073edfaded0a34a1f913b7341069d062552f1444c3de390c3b3b08bf3cd4ad8cdf0f76c6be084ccc14469492a535a96022a0729ce56b3b09cfdfec  0007-nvt-touch-f7a-unbreak-libinput.patch
eaf2e61fcb508cdd239b8fed209d2a09ecac77287f6b46d003918fdf1c6fa2ee63f7390f3ff7c49029b8ed6cbcdd81c7e9a4b1ece9f5060b6fc84e322bd47f41  linux4.2-gcc10-extern_YYLOC_global_declaration.patch
"
