pkgname=lxc-android
pkgver=1.0_git20190315
pkgrel=2
arch="noarch"
url="https://github.com/Halium/lxc-android"
license="Apache"
makedepends=""
depends="lxc shadow"
_commit="9551443e5ab11d0d21cb544f681bcb7603b870de"
install="$pkgname.post-install"
source="$pkgname-$_commit.tar.gz::https://github.com/Halium/$pkgname/archive/$_commit.tar.gz
    add_android_groups.sh
    logcat
    pre-start.sh
    0001-lxcconfig.patch
    0002-fix-android-rules.patch
    lxc-android.init"
pkgdesc="Configuration for starting Halium build of Android inside LXC container"
options="!check"

builddir="$srcdir/$pkgname-$_commit"

package() {
	cd "$builddir"
	mkdir -p "$pkgdir"
	cp -r "$builddir"/* "$pkgdir"

	# Remove unneeded udev rule override
	rm -f "$pkgdir/etc/udev/rules.d/50-firmware.rules"
	rm -f "$pkgdir/etc/udev/rules.d/60-persistent-v4l.rules"

	# Remove systemd units
	rm -rf "$pkgdir/etc/systemd"
	rm -rf "$pkgdir/lib/systemd"

	# Install wrapper so pre-start.sh could be provided by device package
	mv "$pkgdir/var/lib/lxc/android/pre-start.sh" "$pkgdir/var/lib/lxc/android/pre-start.default.sh"
	install -m755 "$srcdir/pre-start.sh" "$pkgdir/var/lib/lxc/android/pre-start.sh"

	# OpenRC services
	install -Dm755 "${srcdir}/lxc-android.init" \
		"${pkgdir}/etc/init.d/lxc-android"

	install -Dm755 "${srcdir}/logcat" \
		"${pkgdir}/usr/bin/logcat"

	install -Dm755 "${srcdir}/add_android_groups.sh" \
		"${pkgdir}/usr/sbin/add_android_groups.sh"
}
sha512sums="348650f24464abb7a5d2b3e86e762efbdf770bf5f91d4fb12eb62290e3e29b94bcb91fac36cb0b550f4cb1ad9941b97ea7b7c44cccdf9af51d6b35233b6fe46d  lxc-android-9551443e5ab11d0d21cb544f681bcb7603b870de.tar.gz
5917947c88e47e7ce982822b8d286073da6b8104a0c3df335b1358908cff0e3d819573a341392958aafb533503847ed2b188cb0e88086a8be16244383a577862  add_android_groups.sh
7c5931671a78ab8222f1c99b9720be328883c8961b7966daf71fd8a7093365d1a2b8785196399534c323585b1c70d723df7c1b52a94d533c62c4942e0eb267f0  logcat
ef7081ea55a1acd5a6c5a973b4a7fc79bad4d5fdc721bc481e4ed92962a8ba9b70634e2a0a8f0afd28c14bd1fd4e1956914f68239c3dc34e41e167254252b1df  pre-start.sh
7e8981ba9c779bf893dfddbe495dcaacfa43154748e21dd14fed2696d50b55807585d7168b79d73769d1381bb9974d7661479a303bacef883da0e0cf07dd0ad7  0001-lxcconfig.patch
d5772e4776464acc016854cec8a7348e4226696c343eae3bf5e08fb5ad23155d883c23ed5d00e7ff3876907f516e66dd4438c7894c8441dd9b00d1f8f9f22620  0002-fix-android-rules.patch
ad373e26fb4850f887ca0be76a4c5f19115e214dcbdc315cf24e41eabfd03eebf8f19085a49c97661861b16e8005355c7fd10e86acdb4593d43250e3fed998fb  lxc-android.init"
