# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-samsung-manta
pkgdesc="Google Nexus 10"
pkgver=0.5
pkgrel=1
url="https://postmarketos.org"
license="MIT"
arch="armv7"
options="!check !archcheck"
depends="postmarketos-base linux-samsung-manta mkbootimg watchdog-kick alsa-ucm-conf"
makedepends="devicepkg-dev"
subpackages="$pkgname-nonfree-firmware:nonfree_firmware"
source="
	deviceinfo
	pointercal
	modules-load.conf
	100-manta-charging.rules
	autodetect-charger.sh
	sink-usb-power.sh
	led-charging-manta.sh
	led-discharging-manta.sh
	networkmanager.conf
	ucm/Manta-I2S.conf
	ucm/HiFi.conf
	ucm/Manta-SPDIF.conf
	ucm/SPDIF.conf
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname

	install -D -m644 "$srcdir"/networkmanager.conf \
		"$pkgdir"/etc/NetworkManager/conf.d/10-manta.conf

	install -Dm744 "$srcdir"/autodetect-charger.sh \
		"$pkgdir"/usr/lib/device-samsung-manta/autodetect-charger.sh
	install -Dm744 "$srcdir"/sink-usb-power.sh \
		"$pkgdir"/usr/lib/device-samsung-manta/sink-usb-power.sh
	install -Dm744 "$srcdir"/led-charging-manta.sh \
		"$pkgdir"/usr/lib/device-samsung-manta/led-charging-manta.sh
	install -Dm744 "$srcdir"/led-discharging-manta.sh \
		"$pkgdir"/usr/lib/device-samsung-manta/led-discharging-manta.sh

	install -Dm644 "$srcdir"/100-manta-charging.rules \
		"$pkgdir"/usr/lib/udev/rules.d/100-manta-charging.rules

	install -D -m644 "$srcdir"/pointercal \
		"$pkgdir"/etc/pointercal

	install -Dm644 -t "$pkgdir"/usr/share/alsa/ucm2/conf.d/Manta-I2S \
		"$srcdir"/Manta-I2S.conf \
		"$srcdir"/HiFi.conf

	install -Dm644 -t "$pkgdir"/usr/share/alsa/ucm2/conf.d/Manta-SPDIF \
		"$srcdir"/Manta-SPDIF.conf \
		"$srcdir"/SPDIF.conf
}

nonfree_firmware() {
	pkgdesc="Firmware for Samsung Manta (Nexus 10)"
	depends="firmware-samsung-manta"
	mkdir "$subpkgdir"
}

sha512sums="
58a40f3ea8942e868d384f185e3bfadb3b1b1d1d3b785425ccc2fd851189595b6c645edda9aad1e158abcd2ead0e169470e43392d2263742e36d7f4fac5cb0e9  deviceinfo
4a4a1e478131175d628669c45c780db6eace39653d7c331e13042d315a1d04a1feebbf3ab1caea959f84d3203dcf0402da0a51dfd90728bc0a2a52a069069c52  pointercal
aa65eddbf733af7a8c143f810aa21319ea267bfe473080faba634419146ff14f57e9e07cecdf64aefe0d060bf03564637d606be7b436ccb7de512697097460d5  modules-load.conf
e479dd64f2c27aeeafcc57ea1ae650b382e07a7ea2addf994406b2f64e9b3eff7df451637ceeef85e484be39a8d5a19e35d35c2643b9538b29abf55c67bcecc3  100-manta-charging.rules
edb46f0de37835c7c5a55f47f57acd40012817e0a734153d49033d7aa82404192abdd8f100c93df80702a09698e0d13eb3e26f4bcc86dc427322a2b68498bbb4  autodetect-charger.sh
71a4bf6d25b55acb94fd624625c94cc9c74fe57c4328cddb488f57274443f8c9354c0a5a6f52df40f0ca54ed0713db73f1f90b5fcfd0f8e25ed9cc755b30dea3  sink-usb-power.sh
797f5dce8e27bb5e1fb77a6fa9a917847067f533f14b7b6339703f0aa2969cd8bee686fcdd83e91d21c2fefb6d44365f6b5b0c7726950febfee8a99f9faf8be7  led-charging-manta.sh
a6c9ac55b8d343bcef8765498b450d3e17993b7ad72b274c2fe3e9d3b1a94f917f3790a3595394c0a4de5f1debffbcfbfccd1e4eb637604d6a3da54741cf6091  led-discharging-manta.sh
a6d59c86fc7c47ba25fe125fe57cfbc0b82cb41e3729c3b0387e611386c2e449fa14360b999bc7593527f30a01f3f85bacf2d81762f167a547b37271456343bd  networkmanager.conf
20bd1a5ced8f816c931353abb939936f3c71c5ae1e7a6736dc7c596e721fd59dff70866dc056ef8732fa3cd68f50f08875698696f75ca15e8d618d7778342da4  Manta-I2S.conf
684f1dacb031dcbfd17d55c43db08a1da89d1e7c8197e4c9b8200096e74895469cffabeef3233a4ff380eb92e5fd5618819770ade4f86d1aad9e12e9da7ef122  HiFi.conf
d9e1847f74e46091e2c0bf6cf088cd85ad866fde3e0b8aff8fb02b2dc8869c44977303e40f2be86751ad083838c5a659dd70e434746b92bafd2d0a618f135bcb  Manta-SPDIF.conf
5e1bae638cbd88a38b10b45f675bc4e5fdb84155923a945168207e49db2053a31ae9e7b5233936b832ed60b3a367e31dee7b2d85b52b2922dcfa5df1a813aaa7  SPDIF.conf
"
