# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-samsung-klte
pkgdesc="Samsung Galaxy S5 (G900F)"
pkgver=3
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="armv7"
options="!check !archcheck"
depends="
	linux-postmarketos-qcom-msm8974
	mesa-dri-gallium
	mkbootimg
	postmarketos-base
	swclock-offset
"
makedepends="devicepkg-dev"
subpackages="
	$pkgname-nonfree-firmware:nonfree_firmware
"
source="
	20-tm2-touchkey-input.rules
	bt-module-deps.conf
	deviceinfo
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
	install -Dm644 "$srcdir"/20-tm2-touchkey-input.rules \
		"$pkgdir"/lib/udev/rules.d/20-tm2-touchkey-input.rules
}

nonfree_firmware() {
	pkgdesc="GPU, Wi-Fi, Bluetooth firmware"
	depends="
		firmware-qcom-adreno-a330
		firmware-samsung-klte-bt
		firmware-samsung-klte-wifi
		msm-firmware-loader
		msm-modem
	"

	mkdir "$subpkgdir"
	# This config makes sense only if non-free firmware is installed
	install -Dm644 "$srcdir"/bt-module-deps.conf \
		"$subpkgdir"/etc/modprobe.d/bt-module-deps.conf
}

sha512sums="
5a91ca375652bc9d2af90db4f446176a4fd43b5c924362219f6bf35e76de818cb4ecce105ee56b4511c3c0882bd055615f409516fade6dfcd30642cc147c1c5a  20-tm2-touchkey-input.rules
6cef5f8ae1785ac16e6fe84bfc861ac50cdfb94db35d764f44a25c960e123cb82f6e56f45362a5340c62a3d5ac225f2689afd4f6964cb88305a0892ba44214f0  bt-module-deps.conf
ddbf2140fdc4b3c50a78a5c946d2bec75debec68a89bfac6e1ad7b112af7c38e916ac056dbe69e266c229e3543427471375d3f5f362dcf35765e86a6bc0f4024  deviceinfo
"