maintainer="Raymond Hackley <wonderfulShrineMaidenOfParadise@postmarketos.org>"
pkgname=firmware-samsung-fortuna
pkgver=3
pkgrel=0
_name="Samsung Galaxy Grand Prime"
pkgdesc="Firmware for $_name"
url="https://postmarketos.org"
arch="aarch64 armv7"
license="proprietary"
subpackages="
	firmware-samsung-fortuna3g-wcnss-nv:wcnss_nv_fortuna3g
	firmware-samsung-fortunaltezt-wcnss-nv:wcnss_nv_fortunaltezt
	firmware-samsung-gprimeltecan-wcnss-nv:wcnss_nv_gprimeltecan
	firmware-samsung-grandprimelte-wcnss-nv:wcnss_nv_grandprimelte
"
source="
	firmware-samsung-fortuna3g-WCNSS_qcom_wlan_nv.bin.base64::https://pastebin.com/raw/Y8DvfvRf
	firmware-samsung-fortunaltezt-WCNSS_qcom_wlan_nv.bin.base64::https://pastebin.com/raw/s25mBaen
	firmware-samsung-gprimeltecan-WCNSS_qcom_wlan_nv.bin.base64::https://pastebin.com/raw/BxjvzZhd
	firmware-samsung-grandprimelte-WCNSS_qcom_wlan_nv.bin.base64::https://pastebin.com/raw/6rPpqqEE
"
options="!check !strip !archcheck !tracedeps pmb:cross-native"
builddir="$srcdir"
_fwdir="/usr/lib/firmware/postmarketos"

build() {
	base64 -d firmware-samsung-fortuna3g-WCNSS_qcom_wlan_nv.bin.base64 \
		> fortuna3g-WCNSS_qcom_wlan_nv.bin
	base64 -d firmware-samsung-fortunaltezt-WCNSS_qcom_wlan_nv.bin.base64 \
		> fortunaltezt-WCNSS_qcom_wlan_nv.bin
	base64 -d firmware-samsung-gprimeltecan-WCNSS_qcom_wlan_nv.bin.base64 \
		> gprimeltecan-WCNSS_qcom_wlan_nv.bin
	base64 -d firmware-samsung-grandprimelte-WCNSS_qcom_wlan_nv.bin.base64 \
		> grandprimelte-WCNSS_qcom_wlan_nv.bin
}

package() {
	# parent package is empty
	mkdir -p "$pkgdir"
}

wcnss_nv_fortuna3g() {
	pkgdesc="$_name (SM-G530H) WiFi/BT firmware configuration"
	install -Dm644 "$srcdir"/fortuna3g-WCNSS_qcom_wlan_nv.bin \
		"$subpkgdir/$_fwdir"/wlan/prima/WCNSS_qcom_wlan_nv.bin
}

wcnss_nv_fortunaltezt() {
	pkgdesc="$_name (SM-G530Y) WiFi/BT firmware configuration"
	install -Dm644 "$srcdir"/fortunaltezt-WCNSS_qcom_wlan_nv.bin \
		"$subpkgdir/$_fwdir"/wlan/prima/WCNSS_qcom_wlan_nv.bin
}

wcnss_nv_gprimeltecan() {
	pkgdesc="$_name (SM-G530W) WiFi/BT firmware configuration"
	install -Dm644 "$srcdir"/gprimeltecan-WCNSS_qcom_wlan_nv.bin \
		"$subpkgdir/$_fwdir"/wlan/prima/WCNSS_qcom_wlan_nv.bin
}

wcnss_nv_grandprimelte() {
	pkgdesc="$_name (SM-G530FZ) WiFi/BT firmware configuration"
	install -Dm644 "$srcdir"/grandprimelte-WCNSS_qcom_wlan_nv.bin \
		"$subpkgdir/$_fwdir"/wlan/prima/WCNSS_qcom_wlan_nv.bin
}

sha512sums="
8f46dae0009391871764e3e5cfcb39f565116444ae0882ef3b93cf43418a997a8fb260948d2bb1315ffb33faa82565ec352b1bbee573421363e86325b2bf5a9e  firmware-samsung-fortuna3g-WCNSS_qcom_wlan_nv.bin.base64
0a34532a0c5bbf69bb6a81ec850951b47c9e059a3ea2ab269dac1dfe19de49a51f98d018d899db2517e95f0ac737f82ff0c46df9bfd3e990b44b7b03062cba2e  firmware-samsung-fortunaltezt-WCNSS_qcom_wlan_nv.bin.base64
7129e4a5ed999d203d5b097abebd434c4293cb65e4eb387e517e52e91ff6e5939a0d8f25eb45efcee986d856689ba0a3e0887087425ce8d0883688891b25fa55  firmware-samsung-gprimeltecan-WCNSS_qcom_wlan_nv.bin.base64
2c012fdf0abe58c4864f79d6f084ce3857f8f09a9c5d85dd36b1dd3377dcc4745646047a5929e2e70ab755aca3f1506018b7f389fef4ff00d7f396eecd4f908f  firmware-samsung-grandprimelte-WCNSS_qcom_wlan_nv.bin.base64
"
