# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-lg-hammerhead
pkgver=7
pkgrel=1
pkgdesc="Google Nexus 5"
url="https://postmarketos.org"
arch="armv7"
license="MIT"
depends="
	linux-postmarketos-qcom-msm8974
	lk2nd-msm8974
	mkbootimg
	postmarketos-base
	swclock-offset
"
makedepends="devicepkg-dev"
subpackages="
	$pkgname-phosh
	$pkgname-unl0kr
	$pkgname-x11
	$pkgname-nonfree-firmware:nonfree_firmware"
source="
	10-unl0kr.conf
	20-gsk-gpu-workaround.sh
	bt-module-deps.conf
	deviceinfo
	modules-initfs
	phoc.ini
	xorg.conf
"
options="!check !archcheck"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
	install -Dm755 "$srcdir"/20-gsk-gpu-workaround.sh \
		"$pkgdir"/etc/profile.d/20-gsk-gpu-workaround.sh
}

unl0kr() {
	install_if="$pkgname unl0kr"
	depends=""
	install -Dm644 "$srcdir"/10-unl0kr.conf \
		-t "$subpkgdir"/etc/unl0kr.conf.d
}

x11() {
	install_if="$pkgname xorg-server"
	depends="
		libinput
		xf86-input-libinput
		xf86-video-fbdev
		msm-fb-refresher"
	install -Dm644 "$srcdir"/xorg.conf \
		"$subpkgdir"/etc/X11/xorg.conf.d/10-hammerhead.conf
}

phosh() {
	install_if="$pkgname postmarketos-ui-phosh"
	install -Dm644 "$srcdir"/phoc.ini \
		"$subpkgdir"/etc/phosh/phoc.ini
}

nonfree_firmware() {
	pkgdesc="WiFi, GPU, Modem and ADSP firmware"
	depends="
		firmware-qcom-adreno-a330
		firmware-lg-hammerhead
		firmware-lg-hammerhead-adsp
		firmware-lg-hammerhead-modem
		firmware-lg-hammerhead-bluetooth
		linux-firmware-brcm
		linux-firmware-cypress
		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="
f700af3145b79d1ef9edfb22982899b25cabfb212f9620dcbd3a2e6f44b5ad591e0a66056c6fcd66c3fde89a2b5f551e8a8fe2e65cf0e2a48adec57c027d7825  10-unl0kr.conf
b0ff3cf868380481638cce975688eb622e50d4a45a877892e087789ad7f292f8723de1fbf3da2af445adad31df99d7976c31dcf4f685a046b644b38aa109067d  20-gsk-gpu-workaround.sh
6cef5f8ae1785ac16e6fe84bfc861ac50cdfb94db35d764f44a25c960e123cb82f6e56f45362a5340c62a3d5ac225f2689afd4f6964cb88305a0892ba44214f0  bt-module-deps.conf
9d4839f940ff55dc3213e4fae3f119a5cd9c5242f06fb835fb7cf38d8455ba2278c41fef41e2dcd9f6aa06857ec772c2ca9ba018e482f7e8b32409a42542774f  deviceinfo
fd639faebbee2c0c2c227710678376e0d039b7d96a62103f7ba7e6304d7060023f09064918e93a125465d20d125c0334225680521a7aeae5a43d77d7360c180c  modules-initfs
ee1deae3c21de4dfcf9842abc7ba984229fd37bff058cb630a9bd44e787484ddfa3e5d4d85dbd30850d3ac34822aa91c82c3a5d7c107a990f202fb7da2f4db98  phoc.ini
0a9da551fa9d48d8a663f6bc74e8a7d6e2d2a6e009bd163fa46cd302e75656ad7ae57402a0bd70614ec253e0f2445b4c6999df07104f4c657ed630305c7f40d4  xorg.conf
"
