# Copyright Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=8

if [[ ${PV} == 9999* ]]; then
	EGIT_REPO_URI="https://dev.unitas-network.de/r/VA/${PN}.git"
	inherit git-r3
else
	SRC_URI="https://git.unitas-network.de/VA/${PN}/archive/${PR/r/}.tar.gz -> ${P}-${PR}.tar.gz"
	KEYWORDS="amd64 x86"
fi


inherit linux-info toolchain-funcs

DESCRIPTION="Programatically (re)create Gentoo Virtual Appliances"
HOMEPAGE="https://git.unitas-network.de/VA/virtual-appliance"

LICENSE="unknown"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

DEPEND="app-emulation/qemu
        app-emulation/open-vmdk
        dev-python/python-gnupg
        sys-block/parted"
RDEPEND="${DEPEND}"

S=${WORKDIR}/${PN}

pkg_setup() {
	CONFIG_CHECK="BLK_DEV_NBD"
	linux-info_pkg_setup
}

src_compile() {
	einfo "Nothing to compile"
}

src_install() {
	dodir /opt/${PN}
	cp -r appliances ${D}/opt/${PN}/appliances
	cp -r configs ${D}/opt/${PN}/configs
	cp -r scripts ${D}/opt/${PN}/scripts
	cp -r Makefile ${D}/opt/${PN}/Makefile

	echo "CONFIG_PROTECT=\"/opt/${PN}/configs\"" > "${T}"/99${PN}
	doenvd "${T}"/99${PN}
}
