# Maintainer: Alexander Martinz <amartinz@shiftphones.com>

pkgname=firmware-shift-sdm845
pkgver=0.3
pkgrel=1
pkgdesc="Firmware for SHIFT sdm845 devices"
url="https://gitlab.com/sdm845-mainline/firmware-shift-sdm845"
arch="aarch64"
depends="
	linux-firmware-ath10k
	linux-firmware-qcom
"
license="proprietary"
options="!check !strip !archcheck !tracedeps pmb:cross-native"

_version="ce9d27bf03624cceeaa8e7466f2e6dc731f2ba5e"

source="$pkgname.tar.gz::$url/-/archive/$_version/$pkgname-$_version.tar.gz
	firmware.files
	30-gpu-firmware.files"
subpackages="
	$pkgname-initramfs:firmware_initramfs"

package() {
	cd "$srcdir/$pkgname-$_version/"
	while IFS="" read -r _i || [ -n "$_i" ]; do
		[ ! -d $(dirname $_i) ] && mkdir -p $(dirname $_i)
		echo $_i
		install -Dm644 $_i "$pkgdir/$_i"
	done < "$srcdir/firmware.files"
}

firmware_initramfs() {
	pkgdesc="Files to be included in the initramfs to support osk-sdl"
	depends="$pkgname"
	install_if="$pkgname-nonfree-firmware"
	mkdir "$subpkgdir"

	install -Dm644 "$srcdir/30-gpu-firmware.files" \
		"$subpkgdir/usr/share/mkinitfs/files/30-gpu-firmware.files"
}

sha512sums="
86c3813a9f43e8f5f5e0df1215e37090011d6c468aad1a23f944a202e9fa740240869ed7b0b11ad032d35afaee72e903e24ca8d0e1de2f992902692f8c5983f8  firmware-shift-sdm845.tar.gz
0b547cd027a9760cf16d80e63ebfb89282cff260bd07cc0bfea364513be7a5a32202a5f0aedbeb52dc5ca8087595a2842442a59f77dc7c9bcf5f154e905ceb15  firmware.files
8695a37da5578fdae506f373131ce9481be3db1a86f329c19893e7360b9cb0fadd47b0b1318b2e74702c5e76a9be022f58610940ad17becab49788689f6ca3f8  30-gpu-firmware.files
"
