# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm64/configs/merge_hi6250_defconfig

pkgname=linux-huawei-warsaw
pkgver=4.4.174
pkgrel=2
pkgdesc="Huawei P10 Lite kernel fork"
arch="aarch64"
_carch="arm64"
_flavor="huawei-warsaw"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="bash bc bison devicepkg-dev dtc flex openssl-dev perl xz"

# Source
_repository="labyrinth_kernel_prague"
_commit="f148d781c3d6bad4bae8d1c4073e233abeca9c96"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/Dil3mm4/$_repository/archive/$_commit.tar.gz
	$_config
	linux4.2-gcc10-extern_YYLOC_global_declaration.patch
	01_remove_wireguard.patch
	02_fix_undeclared_AID_INET.patch
	03_fix_dtc.patch
	04_make_rdr_hisi_adapter_compileable.patch
	05-disable-huawei-bfmr.patch
	06-change-bfgx-and-wifi-cfg-paths.patch
	07-fix-p2p.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="
457975f60727cb0d6e0a62a2706fc37431480f47635b8deed178843d71a8ae9f0893f33e84b0b41dbfe33e47c7b4b05aa99efbc57fa4411bdbf48395b3340f3e  linux-huawei-warsaw-f148d781c3d6bad4bae8d1c4073e233abeca9c96.tar.gz
512b7ed7bfc40198317a84f233d77f41420e7a467349c280994cf5e8a29e9b3cd5a08540da1793f3a060139442fef36038409aa94955ee83a8332a0e70b6cc1e  config-huawei-warsaw.aarch64
eaf2e61fcb508cdd239b8fed209d2a09ecac77287f6b46d003918fdf1c6fa2ee63f7390f3ff7c49029b8ed6cbcdd81c7e9a4b1ece9f5060b6fc84e322bd47f41  linux4.2-gcc10-extern_YYLOC_global_declaration.patch
e72fdbde8746f29af60065b765a75e5475ba859bf545e2074609a075aebb6700024fe289ed56ab49bd8f55cb3597ea8e01b465b85d51675b1f45db88a8ebd9ae  01_remove_wireguard.patch
03df93e697a1a63bb6003af569850f7bb54749127b8cef8d9c0aa9be1487b9e33e5454d258454d01d8e70ad776e8b4730569549390d327f0cf0d50a5334b8f7e  02_fix_undeclared_AID_INET.patch
3c7120bf70cdf508f2d5c919d1e0fa9e716882e3774e146ab953e9708f353d0e71af5325e0e9c881601aa90d6f131892b2f7e8b9bd774b4f993d17da189e5141  03_fix_dtc.patch
cdc60b6c829df3b014226b9cb506ed71cf005cf5fec8d4339b54a23f052465501aaa4983ec00f33ef301db2e6a70b24a30439b3f6ce8f7c00348c05d3132ec3f  04_make_rdr_hisi_adapter_compileable.patch
6e420722576111a7ba49f265a66de632631c13d1bdb67553916d2156149226526daedc8298d83a38115c0a7189497cdb92b0daa0a263a92e6093f575e855a6e5  05-disable-huawei-bfmr.patch
ebba6534c200dd174e0ea8915c88e7fe4cf5a5ffb59b21ab4dcf25a64bfd3ba8b9be027e1c29f7c39aa86f659431e1819371fe7d3bd78ccbd8aab82ff164671f  06-change-bfgx-and-wifi-cfg-paths.patch
71b3783d21eff6b43aec7b97d16e64696bd39ac191984254fb77d28db17f5f940beb3e3f0516468d698f6e10e936b8d38aa97f7e39004a3a17491de454ecdccb  07-fix-p2p.patch
"
