# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=virt-manager
pkgver=1.4.3
pkgrel=2
pkgdesc="GUI for managing virtual machines"
url="http://virt-manager.org/"
arch="noarch"
license="GPL-2.0-or-later"
_py=py2
depends="python2 gtk+3.0 vte3 $_py-libxml2 $pkgname-common
	spice-gtk gtk-vnc>=0.5.2-r2 libosinfo
	ttf-dejavu gnome-icon-theme dconf"
depends_dev="intltool"
_common_deps="libvirt-glib $_py-libxml2 py-urlgrabber py-ipaddr
	$_py-libvirt $_py-requests $_py-urllib3 $_py-chardet
	$_py-certifi $_py-idna $_py-gobject3"
makedepends="$depends_dev grep $_common_deps perl-dev file"
install=
subpackages="$pkgname-doc $pkgname-lang
	$pkgname-common
	virt-install:virt_install"
source="http://virt-manager.org/download/sources/virt-manager/virt-manager-$pkgver.tar.gz
	dont-double-create-spice-display.patch"

_builddir="$srcdir"/$pkgname-$pkgver
prepare() {
	cd "$_builddir"
}

build() {
	cd "$_builddir"
	python2 setup.py build || return 1
}

package() {
	cd "$_builddir"
	python2 setup.py --no-update-icon-cache --no-compile-schemas \
		install --prefix=/usr --root="$pkgdir" \
		|| return 1
}

common() {
	pkgdesc="Common files used by virt-manager and virt-install"
	depends="$_common_deps"
	mkdir -p "$subpkgdir"/usr/share/virt-manager "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/share/virt-manager/virtcli \
		"$pkgdir"/usr/share/virt-manager/virtconv \
		"$pkgdir"/usr/share/virt-manager/virtinst \
		"$subpkgdir"/usr/share/virt-manager || return 1
}

virt_install() {
	pkgdesc="Utilities for installing virtual machines"
	depends="$pkgname-common=$pkgver-r$pkgrel libosinfo"
	mkdir -p "$subpkgdir"/usr/share/virt-manager "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/share/virt-manager/virt-install \
		"$pkgdir"/usr/share/virt-manager/virt-clone \
		"$pkgdir"/usr/share/virt-manager/virt-convert \
		"$subpkgdir"/usr/share/virt-manager/ || return 1
	mv "$pkgdir"/usr/bin/virt-install \
		"$pkgdir"/usr/bin/virt-clone \
		"$pkgdir"/usr/bin/virt-convert \
		"$subpkgdir"/usr/bin/ || return 1
}

sha512sums="007f125503fc2c774beefc8047ca2c36aa7177af40d9bc78fa3448fd50d4d35abd4a1dbbf761a8cd538fdf6541eba46c2cd019ba3ff0c7e29b1944d873b74274  virt-manager-1.4.3.tar.gz
a0ff9479328ac4845f00454d4fc78c5ffe825de1186c4d09d7d6a06ccbbc98d965a9b281395cc8a285bf16755a1a5519466d3a0c07c25cb726d093de46496864  dont-double-create-spice-display.patch"
