| 1 |
# Copyright 1999-2012 Gentoo Foundation |
| 2 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
# $Header: /var/cvsroot/gentoo-x86/app-emulation/libvirt/libvirt-0.9.13.ebuild,v 1.6 2012/08/13 01:13:38 cardoe Exp $ |
| 4 |
|
| 5 |
EAPI=4 |
| 6 |
|
| 7 |
#BACKPORTS=1 |
| 8 |
AUTOTOOLIZE=yes |
| 9 |
|
| 10 |
MY_P="${P/_rc/-rc}" |
| 11 |
|
| 12 |
PYTHON_DEPEND="python? 2:2.5" |
| 13 |
#RESTRICT_PYTHON_ABIS="3.*" |
| 14 |
#SUPPORT_PYTHON_ABIS="1" |
| 15 |
|
| 16 |
inherit eutils python user autotools linux-info |
| 17 |
|
| 18 |
if [[ ${PV} = *9999* ]]; then |
| 19 |
inherit git-2 |
| 20 |
EGIT_REPO_URI="git://libvirt.org/libvirt.git" |
| 21 |
AUTOTOOLIZE=yes |
| 22 |
SRC_URI="" |
| 23 |
KEYWORDS="" |
| 24 |
else |
| 25 |
SRC_URI="http://libvirt.org/sources/${MY_P}.tar.gz |
| 26 |
ftp://libvirt.org/libvirt/${MY_P}.tar.gz |
| 27 |
${BACKPORTS:+ |
| 28 |
http://dev.gentoo.org/~cardoe/distfiles/${MY_P}-bp-${BACKPORTS}.tar.bz2}" |
| 29 |
KEYWORDS="~amd64 ~x86" |
| 30 |
fi |
| 31 |
S="${WORKDIR}/${P%_rc*}" |
| 32 |
|
| 33 |
DESCRIPTION="C toolkit to manipulate virtual machines" |
| 34 |
HOMEPAGE="http://www.libvirt.org/" |
| 35 |
LICENSE="LGPL-2.1" |
| 36 |
SLOT="0" |
| 37 |
IUSE="audit avahi +caps debug iscsi +libvirtd lvm +lxc +macvtap nfs \ |
| 38 |
nls numa openvz parted pcap phyp policykit python qemu rbd sasl \ |
| 39 |
selinux +udev uml +vepa virtualbox virt-network xen elibc_glibc" |
| 40 |
REQUIRED_USE="libvirtd? ( || ( lxc openvz qemu uml virtualbox xen ) ) |
| 41 |
lxc? ( caps libvirtd ) |
| 42 |
openvz? ( libvirtd ) |
| 43 |
qemu? ( libvirtd ) |
| 44 |
uml? ( libvirtd ) |
| 45 |
vepa? ( macvtap ) |
| 46 |
virtualbox? ( libvirtd ) |
| 47 |
xen? ( libvirtd )" |
| 48 |
|
| 49 |
# gettext.sh command is used by the libvirt command wrappers, and it's |
| 50 |
# non-optional, so put it into RDEPEND. |
| 51 |
# We can use both libnl:1.1 and libnl:3, but if you have both installed, the |
| 52 |
# package will use 3 by default. Since we don't have slot pinning in an API, |
| 53 |
# we must go with the most recent |
| 54 |
RDEPEND="sys-libs/readline |
| 55 |
sys-libs/ncurses |
| 56 |
>=net-misc/curl-7.18.0 |
| 57 |
dev-libs/libgcrypt |
| 58 |
>=dev-libs/libxml2-2.7.6 |
| 59 |
dev-libs/libnl:3 |
| 60 |
>=net-libs/gnutls-1.0.25 |
| 61 |
sys-apps/dmidecode |
| 62 |
>=sys-apps/util-linux-2.17 |
| 63 |
sys-devel/gettext |
| 64 |
>=net-analyzer/netcat6-1.0-r2 |
| 65 |
app-misc/scrub |
| 66 |
audit? ( sys-process/audit ) |
| 67 |
avahi? ( >=net-dns/avahi-0.6[dbus] ) |
| 68 |
caps? ( sys-libs/libcap-ng ) |
| 69 |
iscsi? ( sys-block/open-iscsi ) |
| 70 |
lxc? ( sys-power/pm-utils ) |
| 71 |
lvm? ( >=sys-fs/lvm2-2.02.48-r2 ) |
| 72 |
nfs? ( net-fs/nfs-utils ) |
| 73 |
numa? ( |
| 74 |
>sys-process/numactl-2.0.2 |
| 75 |
sys-process/numad |
| 76 |
) |
| 77 |
openvz? ( sys-kernel/openvz-sources ) |
| 78 |
parted? ( |
| 79 |
>=sys-block/parted-1.8[device-mapper] |
| 80 |
sys-fs/lvm2 |
| 81 |
) |
| 82 |
pcap? ( >=net-libs/libpcap-1.0.0 ) |
| 83 |
phyp? ( net-libs/libssh2 ) |
| 84 |
policykit? ( >=sys-auth/polkit-0.9 ) |
| 85 |
qemu? ( |
| 86 |
|| ( app-emulation/qemu-kvm >=app-emulation/qemu-0.10.0 ) |
| 87 |
dev-libs/yajl |
| 88 |
sys-power/pm-utils |
| 89 |
) |
| 90 |
rbd? ( sys-cluster/ceph ) |
| 91 |
sasl? ( dev-libs/cyrus-sasl ) |
| 92 |
selinux? ( >=sys-libs/libselinux-2.0.85 ) |
| 93 |
virtualbox? ( || ( app-emulation/virtualbox >=app-emulation/virtualbox-bin-2.2.0 ) ) |
| 94 |
xen? ( app-emulation/xen-tools app-emulation/xen ) |
| 95 |
udev? ( >=sys-fs/udev-145 >=x11-libs/libpciaccess-0.10.9 ) |
| 96 |
virt-network? ( net-dns/dnsmasq |
| 97 |
>=net-firewall/iptables-1.4.10 |
| 98 |
net-firewall/ebtables |
| 99 |
sys-apps/iproute2[-minimal] ) |
| 100 |
elibc_glibc? ( || ( >=net-libs/libtirpc-0.2.2-r1 <sys-libs/glibc-2.14 ) )" |
| 101 |
# one? ( dev-libs/xmlrpc-c ) |
| 102 |
DEPEND="${RDEPEND} |
| 103 |
virtual/pkgconfig |
| 104 |
app-text/xhtml1 |
| 105 |
=dev-lang/python-2*" |
| 106 |
|
| 107 |
LXC_CONFIG_CHECK=" |
| 108 |
~CGROUPS |
| 109 |
~CGROUP_FREEZER |
| 110 |
~CGROUP_DEVICE |
| 111 |
~CPUSETS |
| 112 |
~CGROUP_CPUACCT |
| 113 |
~RESOURCE_COUNTERS |
| 114 |
~CGROUP_MEM_RES_CTLR |
| 115 |
~CGROUP_SCHED |
| 116 |
~BLK_CGROUP |
| 117 |
~NAMESPACES |
| 118 |
~UTS_NS |
| 119 |
~IPC_NS |
| 120 |
~USER_NS |
| 121 |
~PID_NS |
| 122 |
~NET_NS |
| 123 |
~DEVPTS_MULTIPLE_INSTANCES |
| 124 |
~VETH |
| 125 |
~MACVLAN |
| 126 |
~POSIX_MQUEUE |
| 127 |
~!GRKERNSEC_CHROOT_MOUNT |
| 128 |
~!GRKERNSEC_CHROOT_DOUBLE |
| 129 |
~!GRKERNSEC_CHROOT_PIVOT |
| 130 |
~!GRKERNSEC_CHROOT_CHMOD |
| 131 |
~!GRKERNSEC_CHROOT_CAPS |
| 132 |
" |
| 133 |
|
| 134 |
VIRTNET_CONFIG_CHECK=" |
| 135 |
~BRIDGE_NF_EBTABLES |
| 136 |
~NETFILTER_ADVANCED |
| 137 |
~NETFILTER_XT_TARGET_CHECKSUM |
| 138 |
" |
| 139 |
|
| 140 |
MACVTAP_CONFIG_CHECK="~MACVTAP" |
| 141 |
|
| 142 |
pkg_setup() { |
| 143 |
python_set_active_version 2 |
| 144 |
python_pkg_setup |
| 145 |
|
| 146 |
enewgroup qemu 77 |
| 147 |
enewuser qemu 77 -1 -1 qemu kvm |
| 148 |
|
| 149 |
# Some people used the masked ebuild which was not adding the qemu |
| 150 |
# user to the kvm group originally. This results in VMs failing to |
| 151 |
# start for some users. bug #430808 |
| 152 |
egetent group kvm | grep -q qemu |
| 153 |
if [[ $? -ne 0 ]]; then |
| 154 |
gpasswd -a qemu kvm |
| 155 |
fi |
| 156 |
|
| 157 |
CONFIG_CHECK="" |
| 158 |
use lxc && CONFIG_CHECK+="${LXC_CONFIG_CHECK}" |
| 159 |
use macvtap && CONFIG_CHECK+="${MACVTAP}" |
| 160 |
use virt-network && CONFIG_CHECK+="${VIRTNET_CONFIG_CHECK}" |
| 161 |
if [[ -n ${CONFIG_CHECK} ]]; then |
| 162 |
linux-info_pkg_setup |
| 163 |
fi |
| 164 |
} |
| 165 |
|
| 166 |
src_prepare() { |
| 167 |
[[ -n ${BACKPORTS} ]] && \ |
| 168 |
EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \ |
| 169 |
epatch |
| 170 |
|
| 171 |
epatch \ |
| 172 |
"${FILESDIR}/${P}-qemu-add-rbd-to-whitelist-of-migration-safe-formats.patch" \ |
| 173 |
"${FILESDIR}/${P}-libnl3.patch" |
| 174 |
|
| 175 |
if [[ ${PV} = *9999* ]]; then |
| 176 |
|
| 177 |
# git checkouts require bootstrapping to create the configure script. |
| 178 |
# Additionally the submodules must be cloned to the right locations |
| 179 |
# bug #377279 |
| 180 |
./bootstrap || die "bootstrap failed" |
| 181 |
( |
| 182 |
git submodule status | sed 's/^[ +-]//;s/ .*//' |
| 183 |
git hash-object bootstrap.conf |
| 184 |
) >.git-module-status |
| 185 |
fi |
| 186 |
|
| 187 |
epatch_user |
| 188 |
|
| 189 |
[[ -n ${AUTOTOOLIZE} ]] && eautoreconf |
| 190 |
} |
| 191 |
|
| 192 |
src_configure() { |
| 193 |
local myconf="" |
| 194 |
|
| 195 |
myconf="${myconf} $(use_enable debug)" |
| 196 |
|
| 197 |
## enable/disable daemon, otherwise client only utils |
| 198 |
myconf="${myconf} $(use_with libvirtd)" |
| 199 |
|
| 200 |
## enable/disable the daemon using avahi to find VMs |
| 201 |
myconf="${myconf} $(use_with avahi)" |
| 202 |
|
| 203 |
## hypervisors on the local host |
| 204 |
myconf="${myconf} $(use_with xen) $(use_with xen xen-inotify)" |
| 205 |
# leave it automagic as it depends on the version of xen used. |
| 206 |
use xen || myconf+=" --without-libxl" |
| 207 |
use xen || myconf+=" --without-xenapi" |
| 208 |
myconf="${myconf} $(use_with openvz)" |
| 209 |
myconf="${myconf} $(use_with lxc)" |
| 210 |
if use virtualbox && has_version app-emulation/virtualbox-ose; then |
| 211 |
myconf="${myconf} --with-vbox=/usr/lib/virtualbox-ose/" |
| 212 |
else |
| 213 |
myconf="${myconf} $(use_with virtualbox vbox)" |
| 214 |
fi |
| 215 |
myconf="${myconf} $(use_with uml)" |
| 216 |
myconf="${myconf} $(use_with qemu)" |
| 217 |
myconf="${myconf} $(use_with qemu yajl)" # Use QMP over HMP |
| 218 |
myconf="${myconf} $(use_with phyp)" |
| 219 |
myconf="${myconf} --with-esx" |
| 220 |
myconf="${myconf} --with-vmware" |
| 221 |
|
| 222 |
## additional host drivers |
| 223 |
myconf="${myconf} $(use_with virt-network network)" |
| 224 |
myconf="${myconf} --with-storage-fs" |
| 225 |
myconf="${myconf} $(use_with lvm storage-lvm)" |
| 226 |
myconf="${myconf} $(use_with iscsi storage-iscsi)" |
| 227 |
myconf="${myconf} $(use_with parted storage-disk)" |
| 228 |
myconf="${myconf} $(use_with lvm storage-mpath)" |
| 229 |
myconf="${myconf} $(use_with rbd storage-rbd)" |
| 230 |
myconf="${myconf} $(use_with numa numactl)" |
| 231 |
myconf="${myconf} $(use_with numa numad)" |
| 232 |
myconf="${myconf} $(use_with selinux)" |
| 233 |
|
| 234 |
# udev for device support details |
| 235 |
myconf="${myconf} $(use_with udev)" |
| 236 |
|
| 237 |
# linux capability support so we don't need privileged accounts |
| 238 |
myconf="${myconf} $(use_with caps capng)" |
| 239 |
|
| 240 |
## auth stuff |
| 241 |
myconf="${myconf} $(use_with policykit polkit)" |
| 242 |
myconf="${myconf} $(use_with sasl)" |
| 243 |
|
| 244 |
# network bits |
| 245 |
myconf="${myconf} $(use_with macvtap)" |
| 246 |
myconf="${myconf} $(use_with pcap libpcap)" |
| 247 |
myconf="${myconf} $(use_with vepa virtualport)" |
| 248 |
|
| 249 |
## other |
| 250 |
myconf="${myconf} $(use_enable nls)" |
| 251 |
myconf="${myconf} $(use_with python)" |
| 252 |
|
| 253 |
# user privilege bits fir qemu/kvm |
| 254 |
if use caps; then |
| 255 |
myconf="${myconf} --with-qemu-user=qemu" |
| 256 |
myconf="${myconf} --with-qemu-group=qemu" |
| 257 |
else |
| 258 |
myconf="${myconf} --with-qemu-user=root" |
| 259 |
myconf="${myconf} --with-qemu-group=root" |
| 260 |
fi |
| 261 |
|
| 262 |
# audit support |
| 263 |
myconf="${myconf} $(use_with audit)" |
| 264 |
|
| 265 |
## stuff we don't yet support |
| 266 |
myconf="${myconf} --without-netcf" |
| 267 |
|
| 268 |
# we use udev over hal |
| 269 |
myconf="${myconf} --without-hal" |
| 270 |
|
| 271 |
# locking support |
| 272 |
myconf="${myconf} --without-sanlock" |
| 273 |
|
| 274 |
# this is a nasty trick to work around the problem in bug |
| 275 |
# #275073. The reason why we don't solve this properly is that |
| 276 |
# it'll require us to rebuild autotools (and we don't really want |
| 277 |
# to do that right now). The proper solution has been sent |
| 278 |
# upstream and should hopefully land in 0.7.7, in the mean time, |
| 279 |
# mime the same functionality with this. |
| 280 |
case ${CHOST} in |
| 281 |
*cygwin* | *mingw* ) |
| 282 |
;; |
| 283 |
*) |
| 284 |
ac_cv_prog_WINDRES=no |
| 285 |
;; |
| 286 |
esac |
| 287 |
|
| 288 |
econf \ |
| 289 |
${myconf} \ |
| 290 |
--disable-static \ |
| 291 |
--docdir=/usr/share/doc/${PF} \ |
| 292 |
--with-remote \ |
| 293 |
--localstatedir=/var |
| 294 |
|
| 295 |
if [[ ${PV} = *9999* ]]; then |
| 296 |
# Restore gnulib's config.sub and config.guess |
| 297 |
# bug #377279 |
| 298 |
(cd .gnulib && git reset --hard > /dev/null) |
| 299 |
fi |
| 300 |
} |
| 301 |
|
| 302 |
src_test() { |
| 303 |
# Explicitly allow parallel build of tests |
| 304 |
HOME="${T}" emake check || die "tests failed" |
| 305 |
} |
| 306 |
|
| 307 |
src_install() { |
| 308 |
emake install \ |
| 309 |
DESTDIR="${D}" \ |
| 310 |
HTML_DIR=/usr/share/doc/${PF}/html \ |
| 311 |
DOCS_DIR=/usr/share/doc/${PF}/python \ |
| 312 |
EXAMPLE_DIR=/usr/share/doc/${PF}/python/examples \ |
| 313 |
|| die "emake install failed" |
| 314 |
|
| 315 |
find "${D}" -name '*.la' -delete || die |
| 316 |
|
| 317 |
use libvirtd || return 0 |
| 318 |
# From here, only libvirtd-related instructions, be warned! |
| 319 |
|
| 320 |
newinitd "${FILESDIR}/libvirtd.init-r8" libvirtd || die |
| 321 |
newconfd "${FILESDIR}/libvirtd.confd-r3" libvirtd || die |
| 322 |
|
| 323 |
keepdir /var/lib/libvirt/images |
| 324 |
} |
| 325 |
|
| 326 |
pkg_preinst() { |
| 327 |
# we only ever want to generate this once |
| 328 |
if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then |
| 329 |
rm -rf "${D}"/etc/libvirt/qemu/networks/default.xml |
| 330 |
fi |
| 331 |
|
| 332 |
# We really don't want to use or support old PolicyKit cause it |
| 333 |
# screws with the new polkit integration |
| 334 |
if has_version sys-auth/policykit; then |
| 335 |
rm -rf "${D}"/usr/share/PolicyKit/policy/org.libvirt.unix.policy |
| 336 |
fi |
| 337 |
|
| 338 |
# Only sysctl files ending in .conf work |
| 339 |
mv "${D}"/etc/sysctl.d/libvirtd "${D}"/etc/sysctl.d/libvirtd.conf |
| 340 |
} |
| 341 |
|
| 342 |
pkg_postinst() { |
| 343 |
use python && python_mod_optimize libvirt.py |
| 344 |
|
| 345 |
# support for dropped privileges |
| 346 |
if use qemu; then |
| 347 |
fperms 0750 "${EROOT}/var/lib/libvirt/qemu" |
| 348 |
fperms 0750 "${EROOT}/var/cache/libvirt/qemu" |
| 349 |
fi |
| 350 |
|
| 351 |
if use caps && use qemu; then |
| 352 |
fowners -R qemu:qemu "${EROOT}/var/lib/libvirt/qemu" |
| 353 |
fowners -R qemu:qemu "${EROOT}/var/cache/libvirt/qemu" |
| 354 |
elif use qemu; then |
| 355 |
fowners -R root:root "${EROOT}/var/lib/libvirt/qemu" |
| 356 |
fowners -R root:root "${EROOT}/var/cache/libvirt/qemu" |
| 357 |
fi |
| 358 |
|
| 359 |
if ! use policykit; then |
| 360 |
elog "To allow normal users to connect to libvirtd you must change the" |
| 361 |
elog "unix sock group and/or perms in /etc/libvirt/libvirtd.conf" |
| 362 |
fi |
| 363 |
|
| 364 |
use libvirtd || return 0 |
| 365 |
# From here, only libvirtd-related instructions, be warned! |
| 366 |
|
| 367 |
elog |
| 368 |
elog "For the basic networking support (bridged and routed networks)" |
| 369 |
elog "you don't need any extra software. For more complex network modes" |
| 370 |
elog "including but not limited to NATed network, you can enable the" |
| 371 |
elog "'virt-network' USE flag." |
| 372 |
elog |
| 373 |
if has_version net-dns/dnsmasq; then |
| 374 |
ewarn "If you have a DNS server setup on your machine, you will have" |
| 375 |
ewarn "to configure /etc/dnsmasq.conf to enable the following settings: " |
| 376 |
ewarn " bind-interfaces" |
| 377 |
ewarn " interface or except-interface" |
| 378 |
ewarn |
| 379 |
ewarn "Otherwise you might have issues with your existing DNS server." |
| 380 |
fi |
| 381 |
|
| 382 |
if use caps && use qemu; then |
| 383 |
elog "libvirt will now start qemu/kvm VMs with non-root privileges." |
| 384 |
elog "Ensure any resources your VMs use are accessible by qemu:qemu" |
| 385 |
fi |
| 386 |
} |
| 387 |
|
| 388 |
pkg_postrm() { |
| 389 |
use python && python_mod_cleanup libvirt.py |
| 390 |
} |