# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>

pkgname=xochitl-bin
pkgver=2.15.1.1189
_pkgprefix=Xdvv3lBmE4
pkgrel=1
pkgdesc="Image extractor for reMarkable firmware files"
arch="armv7"
url="https://archive.org/download/rm110/RM110/"
license="MIT"
makedepends="rm-extractor p7zip"
options="!check !strip !tracedeps" # No testsuite
subpackages="$pkgname-rm1 $pkgname-rm2"
builddir="$srcdir"
source="
	$pkgname-rm1-$pkgver.signed::https://archive.org/download/rm110/RM110/2.15.1.1189_reMarkable-Xdvv3lBmE4-.signed
	$pkgname-rm2-$pkgver.signed::https://archive.org/download/rm110/RM110/2.15.1.1189_reMarkable2-wVbHkgKisg-.signed
	xochitl.sh
"
package() {
	install -vdm755 "$pkgdir"/var/lib/$pkgname
	install -vDm755 "$srcdir"/xochitl.sh "$pkgdir"/usr/bin/xochitl
}

rm1() {
	depends="$pkgname"

	mkdir -p "$subpkgdir"/usr/lib/$pkgname
	cd "$subpkgdir"/usr/lib/$pkgname
	rm-extractor "$builddir"/$pkgname-rm1-$pkgver.signed
	7z x out || true
	rm out
}

rm2() {
	depends="$pkgname"

	mkdir -p "$subpkgdir"/usr/lib/$pkgname
	cd "$subpkgdir"/usr/lib/$pkgname
	rm-extractor "$builddir"/$pkgname-rm1-$pkgver.signed
	7z x out || true
	rm out
}

sha512sums="
294a5dccebb11366ad4e9a39d15829f310f575044f6e4db2747364ae61ef984cf3e0a8f09f3a33f157365b637d0217f34a01000eff3f92dd177afd011c7b2c9f  xochitl-bin-rm1-2.15.1.1189.signed
6b2baac5c970ddfbf84f376fbfd22dab0a72979160b6889352bb2464f46f9d85d0fdc9f5754dbcb431b3629df833e64913c81aa7838f636cce11b00413d8506e  xochitl-bin-rm2-2.15.1.1189.signed
e0f7ce6a5a29f98929339f55a2073b251ce76802c244473677be35eeef82e0e840edddfdfe56f8dc16fe80865d22e8dd35f3815f716903966768c3d9300831f2  xochitl.sh
"
