/[gentoo-x86]/app-emulation/libvirt/libvirt-1.0.0.ebuild
Gentoo

Contents of /app-emulation/libvirt/libvirt-1.0.0.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download)
Wed May 22 15:56:22 2013 UTC (17 months ago) by cardoe
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +1 -1 lines
FILE REMOVED
More fixes to LXC's kernel requirements. Remove older versions.

(Portage version: 2.1.11.62/cvs/Linux x86_64, signed Manifest commit with key D7DFA8D318FA9AEF!)

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

  ViewVC Help
Powered by ViewVC 1.1.20