summaryrefslogtreecommitdiff
blob: 641eac99dae5d6ff565839ec93d234b5c2073bc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit linux-mod eutils

SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"

DESCRIPTION="KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V)"
HOMEPAGE="http://kvm.qumranet.com/kvmwiki"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

RESTRICT="mirror"

MODULE_NAMES="kernel/kvm(extra:)
	      kernel/kvm-intel(extra:)
	      kernel/kvm-amd(extra:)"
BUILD_TARGETS="kernel"

src_unpack() {
	unpack ${A}
	cd "${S}"

	epatch ${FILESDIR}/kvm_use_bios_files_in_usr_share_kvm.patch
	epatch ${FILESDIR}/kvm_add-scripts-qemu-ifup.patch
	epatch ${FILESDIR}/kvm_use_etc_kvm_kvm-ifup.patch
}

src_compile() {

	if [ "$(gcc-major-version)" == "4" ]; then
		eerror "kvm requires gcc-3 in order to build and work correctly"
		eerror "please compile it switching to gcc-3."
		die "gcc 4 cannot build qemu"
	fi

	#fix make install to not install modules
	sed -i '/$(kcmd)/d' ${WORKDIR}/${P}/Makefile

	linux-mod_pkg_setup
	conf_opts="--prefix=/usr"

	./configure ${conf_opts} || die "configure failed"
	#Check if kvm is NOT part of the kernel and compile the module
	if ! linux_chkconfig_present KVM; then
		linux-mod_src_compile
		./configure ${conf_opts}
	#If it is we need to disable the build of the module
	else
		./configure ${conf_opts} --with-patched-kernel || die "Configure failed"
	fi
	make user qemu || die "make failed"
}

pkg_preinst() {
	enewgroup kvm
}

src_install() {
	make install DESTDIR="${D}" || die
	if ! linux_chkconfig_present KVM; then
		linux-mod_src_install
	fi

	if use amd64; then
		mv ${D}/usr/bin/qemu-system-x86_64 ${D}/usr/bin/kvm-system-x86_64
	else
		mv ${D}/usr/bin/qemu ${D}/usr/bin/kvm	
	fi

	mv ${D}/usr/share/doc/qemu ${D}/usr/share/doc/kvm
	mv ${D}/usr/share/man/man1/qemu.1 ${D}/usr/share/man/man1/kvm.1
#	rm -f ${D}/usr/bin/qemu-img
#	rm -f ${D}/usr/share/man/man1/qemu-img.1
	insinto /etc/udev/rules.d/
	doins ${WORKDIR}/${P}/scripts/65-kvm.rules
	insinto /etc/kvm/
	doins ${WORKDIR}/${P}/scripts/qemu-ifup
}