maintainer="Bart Ribbers <bribbers@disroot.org>"
pkgname=waydroid
pkgver=1.5.2
pkgrel=0
pkgdesc="A container-based approach to boot a full Android system on a regular Linux system"
url="https://github.com/waydroid/waydroid"
# Only x86, armv7, x86_64 and aarch64 supported upstream
# 32bit: blocked by gbinder-python -> https://github.com/erfanoabdi/gbinder-python/issues/18
arch="noarch !armhf !ppc64le !s390x !armv7 !x86"
license="GPL-3.0-only"
depends="
	dnsmasq
	gbinder-python
	iptables
	kmod
	lxc
	py3-dbus
	py3-gobject3
	py3-pyclip
	python3
	"
triggers="$pkgname.trigger=/usr/share/waydroid-extra/images"
install="$pkgname.post-upgrade"
subpackages="
	$pkgname-openrc
	$pkgname-pyc
	$pkgname-nftables
	"
source="https://github.com/waydroid/waydroid/archive/$pkgver/waydroid-$pkgver.tar.gz
	waydroid-container.initd
	waydroid-container.confd
	51_waydroid.nft
	waydroid-session.desktop
	"
options="!check" # No tests

package() {
	make DESTDIR="$pkgdir" USE_SYSTEMD=0 USE_NFTABLES=1 install

	# Generate __pycache__ packaging time instead of runtime
	python -m compileall "$pkgdir"/usr/lib/waydroid/tools

	install -Dm644 -t "$pkgdir"/etc/xdg/autostart "$srcdir"/waydroid-session.desktop

	install -Dm755 "$srcdir"/waydroid-container.initd "$pkgdir"/etc/init.d/waydroid-container
	install -Dm644 "$srcdir"/waydroid-container.confd "$pkgdir"/etc/conf.d/waydroid-container
}

nftables() {
	pkgdesc="$pkgdesc (nftables rules)"
	install_if="$pkgname=$pkgver-r$pkgrel nftables"
	depends=""

	install -Dm644 -t "$subpkgdir"/etc/nftables.d "$srcdir"/51_waydroid.nft
}

pyc() {
	default_pyc

	cd "$pkgdir"
	local IFS=$'\n'
	amove $(find usr/lib/waydroid -type d -name __pycache__)
}

sha512sums="
80be97409d73c3dc649482ff9b8a9b3c316f7cfa7560c87e26a2b68a0efdcaa34c070825334789b6830e3ee0a88eb0967e9101575e4eadc4a39bda099c0f7651  waydroid-1.5.2.tar.gz
f319dde4f4bb365069dff2c1ddaa0a85d711c9e9d49011b15aec0d10da2ba0da39c464505d28cd7e8b4f803e932fdde04ca69602805d084529bac0ee6b22ba59  waydroid-container.initd
b841282b96110ec59a7aa539db0737327b09549d55c78dc4b2c3b28b4a6ad1facf015b3175cb6d3a38f13e47aa6314ef3dc1514a4e60dd653a97409ec54ba706  waydroid-container.confd
27cec579cfda197ff70d6328043755fc3d1719347bf4987edb86a07341bc4f02b99b65a6ef1fcde58b48a925176e6d770ed7cef304edff6a860bf4d408a62e06  51_waydroid.nft
1848bf6b63ed51c635190c134ec3b0b1345915c13a3b721ea7dde44cb5808e632237bdba2ae12e6a9ba2f8978c07715998c357eb5bd7b7caff9d41142bae27e8  waydroid-session.desktop
"
