| 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.11.5.ebuild,v 1.1 2012/08/13 23:19:11 cardoe Exp $ |
| 4 |
|
| 5 |
EAPI=4 |
| 6 |
|
| 7 |
#BACKPORTS=1 |
| 8 |
#AUTOTOOLIZE=yes |
| 9 |
|
| 10 |
MY_P="${P/_rc/-rc}" |
| 11 |
|
| 12 |
if [[ ${PV} = *9999* ]]; then |
| 13 |
EGIT_REPO_URI="git://libvirt.org/libvirt.git" |
| 14 |
AUTOTOOLIZE=yes |
| 15 |
fi |
| 16 |
|
| 17 |
PYTHON_DEPEND="python? 2:2.5" |
| 18 |
#RESTRICT_PYTHON_ABIS="3.*" |
| 19 |
#SUPPORT_PYTHON_ABIS="1" |
| 20 |
|
| 21 |
inherit eutils python |
| 22 |
|
| 23 |
if [[ ${PV} = *9999* ]]; then |
| 24 |
inherit autotools git-2 |
| 25 |
SRC_URI="" |
| 26 |
KEYWORDS="" |
| 27 |
else |
| 28 |
SRC_URI="http://libvirt.org/sources/stable_updates/${MY_P}.tar.gz |
| 29 |
ftp://libvirt.org/libvirt/stable_updates/${MY_P}.tar.gz |
| 30 |
${BACKPORTS:+ |
| 31 |
http://dev.gentoo.org/~cardoe/distfiles/${MY_P}-bp-${BACKPORTS}.tar.bz2}" |
| 32 |
KEYWORDS="~amd64 ~x86" |
| 33 |
fi |
| 34 |
S="${WORKDIR}/${P%_rc*}" |
| 35 |
|
| 36 |
DESCRIPTION="C toolkit to manipulate virtual machines" |
| 37 |
HOMEPAGE="http://www.libvirt.org/" |
| 38 |
LICENSE="LGPL-2.1" |
| 39 |
SLOT="0" |
| 40 |
IUSE="avahi caps debug iscsi +libvirtd lvm +lxc macvtap nfs \ |
| 41 |
nls numa openvz parted pcap phyp policykit python qemu sasl selinux +udev \ |
| 42 |
uml virtualbox virt-network xen elibc_glibc" |
| 43 |
# IUSE=one : bug #293416 & bug #299011 |
| 44 |
REQUIRED_USE="libvirtd? ( || ( lxc openvz qemu uml virtualbox xen ) ) |
| 45 |
lxc? ( libvirtd ) openvz? ( libvirtd ) qemu? ( libvirtd ) uml? ( libvirtd ) |
| 46 |
virtualbox? ( libvirtd ) xen? ( libvirtd )" |
| 47 |
|
| 48 |
# gettext.sh command is used by the libvirt command wrappers, and it's |
| 49 |
# non-optional, so put it into RDEPEND. |
| 50 |
RDEPEND="sys-libs/readline |
| 51 |
sys-libs/ncurses |
| 52 |
>=net-misc/curl-7.18.0 |
| 53 |
dev-libs/libgcrypt |
| 54 |
>=dev-libs/libxml2-2.7.6 |
| 55 |
>=dev-libs/libnl-1.1:1.1 |
| 56 |
>=net-libs/gnutls-1.0.25 |
| 57 |
sys-apps/dmidecode |
| 58 |
>=sys-apps/util-linux-2.17 |
| 59 |
sys-devel/gettext |
| 60 |
>=net-analyzer/netcat6-1.0-r2 |
| 61 |
app-misc/scrub |
| 62 |
avahi? ( >=net-dns/avahi-0.6[dbus] ) |
| 63 |
caps? ( sys-libs/libcap-ng ) |
| 64 |
iscsi? ( sys-block/open-iscsi ) |
| 65 |
lxc? ( sys-power/pm-utils ) |
| 66 |
lvm? ( >=sys-fs/lvm2-2.02.48-r2 ) |
| 67 |
nfs? ( net-fs/nfs-utils ) |
| 68 |
numa? ( >sys-process/numactl-2.0.2 ) |
| 69 |
openvz? ( sys-kernel/openvz-sources ) |
| 70 |
parted? ( |
| 71 |
>=sys-block/parted-1.8[device-mapper] |
| 72 |
sys-fs/lvm2 |
| 73 |
) |
| 74 |
pcap? ( >=net-libs/libpcap-1.0.0 ) |
| 75 |
phyp? ( net-libs/libssh2 ) |
| 76 |
policykit? ( >=sys-auth/polkit-0.9 ) |
| 77 |
qemu? ( |
| 78 |
|| ( app-emulation/qemu-kvm >=app-emulation/qemu-0.10.0 ) |
| 79 |
dev-libs/yajl |
| 80 |
sys-power/pm-utils |
| 81 |
) |
| 82 |
sasl? ( dev-libs/cyrus-sasl ) |
| 83 |
selinux? ( >=sys-libs/libselinux-2.0.85 ) |
| 84 |
virtualbox? ( || ( app-emulation/virtualbox >=app-emulation/virtualbox-bin-2.2.0 ) ) |
| 85 |
xen? ( app-emulation/xen-tools app-emulation/xen ) |
| 86 |
udev? ( >=sys-fs/udev-145 >=x11-libs/libpciaccess-0.10.9 ) |
| 87 |
virt-network? ( net-dns/dnsmasq |
| 88 |
>=net-firewall/iptables-1.4.10 |
| 89 |
net-firewall/ebtables |
| 90 |
sys-apps/iproute2[-minimal] ) |
| 91 |
elibc_glibc? ( || ( >=net-libs/libtirpc-0.2.2-r1 <sys-libs/glibc-2.14 ) )" |
| 92 |
# one? ( dev-libs/xmlrpc-c ) |
| 93 |
DEPEND="${RDEPEND} |
| 94 |
virtual/pkgconfig |
| 95 |
app-text/xhtml1" |
| 96 |
|
| 97 |
pkg_setup() { |
| 98 |
use python && python_set_active_version 2 |
| 99 |
python_pkg_setup |
| 100 |
} |
| 101 |
|
| 102 |
src_prepare() { |
| 103 |
[[ -n ${BACKPORTS} ]] && \ |
| 104 |
EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \ |
| 105 |
epatch |
| 106 |
|
| 107 |
if [[ ${PV} = *9999* ]]; then |
| 108 |
# git checkouts require bootstrapping to create the configure script. |
| 109 |
# Additionally the submodules must be cloned to the right locations |
| 110 |
# bug #377279 |
| 111 |
./bootstrap || die "bootstrap failed" |
| 112 |
( |
| 113 |
git submodule status | sed 's/^[ +-]//;s/ .*//' |
| 114 |
git hash-object bootstrap.conf |
| 115 |
) >.git-module-status |
| 116 |
fi |
| 117 |
|
| 118 |
[[ -n ${AUTOTOOLIZE} ]] && eautoreconf |
| 119 |
} |
| 120 |
|
| 121 |
src_configure() { |
| 122 |
local myconf="" |
| 123 |
|
| 124 |
myconf="${myconf} $(use_enable debug)" |
| 125 |
|
| 126 |
## enable/disable daemon, otherwise client only utils |
| 127 |
myconf="${myconf} $(use_with libvirtd)" |
| 128 |
|
| 129 |
## enable/disable the daemon using avahi to find VMs |
| 130 |
myconf="${myconf} $(use_with avahi)" |
| 131 |
|
| 132 |
## hypervisors on the local host |
| 133 |
myconf="${myconf} $(use_with xen) $(use_with xen xen-inotify)" |
| 134 |
# leave it automagic as it depends on the version of xen used. |
| 135 |
use xen || myconf+=" --without-libxl" |
| 136 |
|
| 137 |
myconf="${myconf} $(use_with openvz)" |
| 138 |
myconf="${myconf} $(use_with lxc)" |
| 139 |
if use virtualbox && has_version app-emulation/virtualbox-ose; then |
| 140 |
myconf="${myconf} --with-vbox=/usr/lib/virtualbox-ose/" |
| 141 |
else |
| 142 |
myconf="${myconf} $(use_with virtualbox vbox)" |
| 143 |
fi |
| 144 |
myconf="${myconf} $(use_with uml)" |
| 145 |
myconf="${myconf} $(use_with qemu)" |
| 146 |
myconf="${myconf} $(use_with qemu yajl)" # Use QMP over HMP |
| 147 |
# doesn't belong with hypervisors but links to libvirtd for some reason |
| 148 |
#myconf="${myconf} $(use_with one)" |
| 149 |
|
| 150 |
## hypervisor protocols |
| 151 |
myconf="${myconf} $(use_with phyp)" |
| 152 |
myconf="${myconf} --with-esx" |
| 153 |
|
| 154 |
## additional host drivers |
| 155 |
myconf="${myconf} $(use_with virt-network network)" |
| 156 |
myconf="${myconf} --with-storage-fs" |
| 157 |
myconf="${myconf} $(use_with lvm storage-lvm)" |
| 158 |
myconf="${myconf} $(use_with iscsi storage-iscsi)" |
| 159 |
myconf="${myconf} $(use_with parted storage-disk)" |
| 160 |
myconf="${myconf} $(use_with lvm storage-mpath)" |
| 161 |
myconf="${myconf} $(use_with numa numactl)" |
| 162 |
myconf="${myconf} $(use_with selinux)" |
| 163 |
|
| 164 |
# udev for device support details |
| 165 |
myconf="${myconf} $(use_with udev)" |
| 166 |
|
| 167 |
# linux capability support so we don't need privileged accounts |
| 168 |
myconf="${myconf} $(use_with caps capng)" |
| 169 |
|
| 170 |
## auth stuff |
| 171 |
myconf="${myconf} $(use_with policykit polkit)" |
| 172 |
myconf="${myconf} $(use_with sasl)" |
| 173 |
|
| 174 |
# network bits |
| 175 |
myconf="${myconf} $(use_with macvtap)" |
| 176 |
myconf="${myconf} $(use_with pcap libpcap)" |
| 177 |
|
| 178 |
## other |
| 179 |
myconf="${myconf} $(use_enable nls)" |
| 180 |
myconf="${myconf} $(use_with python)" |
| 181 |
|
| 182 |
## stuff we don't yet support |
| 183 |
myconf="${myconf} --without-netcf --without-audit" |
| 184 |
|
| 185 |
# we use udev over hal |
| 186 |
myconf="${myconf} --without-hal" |
| 187 |
|
| 188 |
# locking support |
| 189 |
myconf="${myconf} --without-sanlock" |
| 190 |
|
| 191 |
# this is a nasty trick to work around the problem in bug |
| 192 |
# #275073. The reason why we don't solve this properly is that |
| 193 |
# it'll require us to rebuild autotools (and we don't really want |
| 194 |
# to do that right now). The proper solution has been sent |
| 195 |
# upstream and should hopefully land in 0.7.7, in the mean time, |
| 196 |
# mime the same functionality with this. |
| 197 |
case ${CHOST} in |
| 198 |
*cygwin* | *mingw* ) |
| 199 |
;; |
| 200 |
*) |
| 201 |
ac_cv_prog_WINDRES=no |
| 202 |
;; |
| 203 |
esac |
| 204 |
|
| 205 |
econf \ |
| 206 |
${myconf} \ |
| 207 |
--disable-static \ |
| 208 |
--docdir=/usr/share/doc/${PF} \ |
| 209 |
--with-remote \ |
| 210 |
--localstatedir=/var |
| 211 |
|
| 212 |
if [[ ${PV} = *9999* ]]; then |
| 213 |
# Restore gnulib's config.sub and config.guess |
| 214 |
# bug #377279 |
| 215 |
(cd .gnulib && git reset --hard > /dev/null) |
| 216 |
fi |
| 217 |
} |
| 218 |
|
| 219 |
src_test() { |
| 220 |
# Explicitly allow parallel build of tests |
| 221 |
HOME="${T}" emake check || die "tests failed" |
| 222 |
} |
| 223 |
|
| 224 |
src_install() { |
| 225 |
emake install \ |
| 226 |
DESTDIR="${D}" \ |
| 227 |
HTML_DIR=/usr/share/doc/${PF}/html \ |
| 228 |
DOCS_DIR=/usr/share/doc/${PF}/python \ |
| 229 |
EXAMPLE_DIR=/usr/share/doc/${PF}/python/examples \ |
| 230 |
|| die "emake install failed" |
| 231 |
|
| 232 |
find "${D}" -name '*.la' -delete || die |
| 233 |
|
| 234 |
use libvirtd || return 0 |
| 235 |
# From here, only libvirtd-related instructions, be warned! |
| 236 |
|
| 237 |
newinitd "${FILESDIR}/libvirtd.init-r8" libvirtd || die |
| 238 |
newconfd "${FILESDIR}/libvirtd.confd-r3" libvirtd || die |
| 239 |
|
| 240 |
keepdir /var/lib/libvirt/images |
| 241 |
} |
| 242 |
|
| 243 |
pkg_preinst() { |
| 244 |
# we only ever want to generate this once |
| 245 |
if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then |
| 246 |
rm -rf "${D}"/etc/libvirt/qemu/networks/default.xml |
| 247 |
fi |
| 248 |
|
| 249 |
# We really don't want to use or support old PolicyKit cause it |
| 250 |
# screws with the new polkit integration |
| 251 |
if has_version sys-auth/policykit; then |
| 252 |
rm -rf "${D}"/usr/share/PolicyKit/policy/org.libvirt.unix.policy |
| 253 |
fi |
| 254 |
|
| 255 |
# Only sysctl files ending in .conf work |
| 256 |
mv "${D}"/etc/sysctl.d/libvirtd "${D}"/etc/sysctl.d/libvirtd.conf |
| 257 |
} |
| 258 |
|
| 259 |
pkg_postinst() { |
| 260 |
use python && python_mod_optimize libvirt.py |
| 261 |
|
| 262 |
elog |
| 263 |
if use policykit && has_version sys-auth/policykit; then |
| 264 |
elog "You must have run the following at least once:" |
| 265 |
elog |
| 266 |
elog "$ polkit-auth --grant org.libvirt.unix.manage --user \"USERNAME\"" |
| 267 |
elog |
| 268 |
elog "to grant USERNAME access to libvirt when using USE=policykit" |
| 269 |
else |
| 270 |
elog "To allow normal users to connect to libvirtd you must change the" |
| 271 |
elog " unix sock group and/or perms in /etc/libvirt/libvirtd.conf" |
| 272 |
fi |
| 273 |
|
| 274 |
use libvirtd || return 0 |
| 275 |
# From here, only libvirtd-related instructions, be warned! |
| 276 |
|
| 277 |
elog |
| 278 |
elog "For the basic networking support (bridged and routed networks)" |
| 279 |
elog "you don't need any extra software. For more complex network modes" |
| 280 |
elog "including but not limited to NATed network, you can enable the" |
| 281 |
elog "'virt-network' USE flag." |
| 282 |
elog |
| 283 |
if has_version net-dns/dnsmasq; then |
| 284 |
ewarn "If you have a DNS server setup on your machine, you will have" |
| 285 |
ewarn "to configure /etc/dnsmasq.conf to enable the following settings: " |
| 286 |
ewarn " bind-interfaces" |
| 287 |
ewarn " interface or except-interface" |
| 288 |
ewarn |
| 289 |
ewarn "Otherwise you might have issues with your existing DNS server." |
| 290 |
fi |
| 291 |
} |
| 292 |
|
| 293 |
pkg_postrm() { |
| 294 |
use python && python_mod_cleanup libvirt.py |
| 295 |
} |