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

Contents of /app-emulation/libvirt/libvirt-0.10.2-r3.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Tue Oct 30 12:01:54 2012 UTC (20 months, 3 weeks ago) by ago
Branch: MAIN
Changes since 1.3: +2 -2 lines
Stable for amd64, wrt bug #439298

(Portage version: 2.1.11.9/cvs/Linux x86_64)

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.10.2-r3.ebuild,v 1.3 2012/10/30 05:12:33 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 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 net-libs/libssh2
62 sys-apps/dmidecode
63 >=sys-apps/util-linux-2.17
64 sys-devel/gettext
65 >=net-analyzer/netcat6-1.0-r2
66 app-misc/scrub
67 audit? ( sys-process/audit )
68 avahi? ( >=net-dns/avahi-0.6[dbus] )
69 caps? ( sys-libs/libcap-ng )
70 iscsi? ( sys-block/open-iscsi )
71 lxc? ( sys-power/pm-utils )
72 lvm? ( >=sys-fs/lvm2-2.02.48-r2 )
73 nfs? ( net-fs/nfs-utils )
74 numa? (
75 >sys-process/numactl-2.0.2
76 sys-process/numad
77 )
78 openvz? ( sys-kernel/openvz-sources )
79 parted? (
80 >=sys-block/parted-1.8[device-mapper]
81 sys-fs/lvm2
82 )
83 pcap? ( >=net-libs/libpcap-1.0.0 )
84 policykit? ( >=sys-auth/polkit-0.9 )
85 qemu? (
86 >=app-emulation/qemu-0.13.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-misc/radvd
99 net-firewall/ebtables
100 sys-apps/iproute2[-minimal] )
101 elibc_glibc? ( || ( >=net-libs/libtirpc-0.2.2-r1 <sys-libs/glibc-2.14 ) )"
102 # one? ( dev-libs/xmlrpc-c )
103 DEPEND="${RDEPEND}
104 virtual/pkgconfig
105 app-text/xhtml1
106 dev-libs/libxslt
107 =dev-lang/python-2*"
108
109 LXC_CONFIG_CHECK="
110 ~CGROUPS
111 ~CGROUP_FREEZER
112 ~CGROUP_DEVICE
113 ~CPUSETS
114 ~CGROUP_CPUACCT
115 ~RESOURCE_COUNTERS
116 ~CGROUP_SCHED
117 ~BLK_CGROUP
118 ~NAMESPACES
119 ~UTS_NS
120 ~IPC_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 # Handle specific kernel versions for different features
158 kernel_is lt 3 5 && LXC_CONFIG_CHECK+=" ~USER_NS"
159 kernel_is lt 3 6 && LXC_CONFIG_CHECK+=" ~CGROUP_MEM_RES_CTLR" || \
160 LXC_CONFIG_CHECK+=" ~MEMCG"
161
162 CONFIG_CHECK=""
163 use lxc && CONFIG_CHECK+="${LXC_CONFIG_CHECK}"
164 use macvtap && CONFIG_CHECK+="${MACVTAP}"
165 use virt-network && CONFIG_CHECK+="${VIRTNET_CONFIG_CHECK}"
166 if [[ -n ${CONFIG_CHECK} ]]; then
167 linux-info_pkg_setup
168 fi
169 }
170
171 src_prepare() {
172 touch "${S}/.mailmap"
173 [[ -n ${BACKPORTS} ]] && \
174 EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \
175 epatch
176
177 if [[ ${PV} = *9999* ]]; then
178
179 # git checkouts require bootstrapping to create the configure script.
180 # Additionally the submodules must be cloned to the right locations
181 # bug #377279
182 ./bootstrap || die "bootstrap failed"
183 (
184 git submodule status | sed 's/^[ +-]//;s/ .*//'
185 git hash-object bootstrap.conf
186 ) >.git-module-status
187 fi
188
189 epatch_user
190
191 [[ -n ${AUTOTOOLIZE} ]] && eautoreconf
192 }
193
194 src_configure() {
195 local myconf=""
196
197 myconf="${myconf} $(use_enable debug)"
198
199 ## enable/disable daemon, otherwise client only utils
200 myconf="${myconf} $(use_with libvirtd)"
201
202 ## enable/disable the daemon using avahi to find VMs
203 myconf="${myconf} $(use_with avahi)"
204
205 ## hypervisors on the local host
206 myconf="${myconf} $(use_with xen) $(use_with xen xen-inotify)"
207 # leave it automagic as it depends on the version of xen used.
208 use xen || myconf+=" --without-libxl"
209 use xen || myconf+=" --without-xenapi"
210 myconf="${myconf} $(use_with openvz)"
211 myconf="${myconf} $(use_with lxc)"
212 if use virtualbox && has_version app-emulation/virtualbox-ose; then
213 myconf="${myconf} --with-vbox=/usr/lib/virtualbox-ose/"
214 else
215 myconf="${myconf} $(use_with virtualbox vbox)"
216 fi
217 myconf="${myconf} $(use_with uml)"
218 myconf="${myconf} $(use_with qemu)"
219 myconf="${myconf} $(use_with qemu yajl)" # Use QMP over HMP
220 myconf="${myconf} $(use_with phyp)"
221 myconf="${myconf} --with-esx"
222 myconf="${myconf} --with-vmware"
223
224 ## additional host drivers
225 myconf="${myconf} $(use_with virt-network network)"
226 myconf="${myconf} --with-storage-fs"
227 myconf="${myconf} $(use_with lvm storage-lvm)"
228 myconf="${myconf} $(use_with iscsi storage-iscsi)"
229 myconf="${myconf} $(use_with parted storage-disk)"
230 myconf="${myconf} $(use_with lvm storage-mpath)"
231 myconf="${myconf} $(use_with rbd storage-rbd)"
232 myconf="${myconf} $(use_with numa numactl)"
233 myconf="${myconf} $(use_with numa numad)"
234 myconf="${myconf} $(use_with selinux)"
235
236 # udev for device support details
237 myconf="${myconf} $(use_with udev)"
238
239 # linux capability support so we don't need privileged accounts
240 myconf="${myconf} $(use_with caps capng)"
241
242 ## auth stuff
243 myconf="${myconf} $(use_with policykit polkit)"
244 myconf="${myconf} $(use_with sasl)"
245
246 # network bits
247 myconf="${myconf} $(use_with macvtap)"
248 myconf="${myconf} $(use_with pcap libpcap)"
249 myconf="${myconf} $(use_with vepa virtualport)"
250
251 ## other
252 myconf="${myconf} $(use_enable nls)"
253 myconf="${myconf} $(use_with python)"
254
255 # user privilege bits fir qemu/kvm
256 if use caps; then
257 myconf="${myconf} --with-qemu-user=qemu"
258 myconf="${myconf} --with-qemu-group=qemu"
259 else
260 myconf="${myconf} --with-qemu-user=root"
261 myconf="${myconf} --with-qemu-group=root"
262 fi
263
264 # audit support
265 myconf="${myconf} $(use_with audit)"
266
267 ## stuff we don't yet support
268 myconf="${myconf} --without-netcf"
269
270 # we use udev over hal
271 myconf="${myconf} --without-hal"
272
273 # locking support
274 myconf="${myconf} --without-sanlock"
275
276 # DBus access to iptables/ebtables and friends
277 myconf="${myconf} --without-firewalld"
278
279 # this is a nasty trick to work around the problem in bug
280 # #275073. The reason why we don't solve this properly is that
281 # it'll require us to rebuild autotools (and we don't really want
282 # to do that right now). The proper solution has been sent
283 # upstream and should hopefully land in 0.7.7, in the mean time,
284 # mime the same functionality with this.
285 case ${CHOST} in
286 *cygwin* | *mingw* )
287 ;;
288 *)
289 ac_cv_prog_WINDRES=no
290 ;;
291 esac
292
293 econf \
294 ${myconf} \
295 --disable-static \
296 --docdir=/usr/share/doc/${PF} \
297 --with-remote \
298 --localstatedir=/var
299
300 if [[ ${PV} = *9999* ]]; then
301 # Restore gnulib's config.sub and config.guess
302 # bug #377279
303 (cd .gnulib && git reset --hard > /dev/null)
304 fi
305 }
306
307 src_test() {
308 # Explicitly allow parallel build of tests
309 HOME="${T}" emake check || die "tests failed"
310 }
311
312 src_install() {
313 emake install \
314 DESTDIR="${D}" \
315 HTML_DIR=/usr/share/doc/${PF}/html \
316 DOCS_DIR=/usr/share/doc/${PF}/python \
317 EXAMPLE_DIR=/usr/share/doc/${PF}/python/examples \
318 || die "emake install failed"
319
320 find "${D}" -name '*.la' -delete || die
321
322 use libvirtd || return 0
323 # From here, only libvirtd-related instructions, be warned!
324
325 newinitd "${FILESDIR}/libvirtd.init-r9" libvirtd || die
326 newconfd "${FILESDIR}/libvirtd.confd-r3" libvirtd || die
327
328 keepdir /var/lib/libvirt/images
329 }
330
331 pkg_preinst() {
332 # we only ever want to generate this once
333 if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then
334 rm -rf "${D}"/etc/libvirt/qemu/networks/default.xml
335 fi
336
337 # We really don't want to use or support old PolicyKit cause it
338 # screws with the new polkit integration
339 if has_version sys-auth/policykit; then
340 rm -rf "${D}"/usr/share/PolicyKit/policy/org.libvirt.unix.policy
341 fi
342
343 # Only sysctl files ending in .conf work
344 mv "${D}"/etc/sysctl.d/libvirtd "${D}"/etc/sysctl.d/libvirtd.conf
345 }
346
347 pkg_postinst() {
348 use python && python_mod_optimize libvirt.py
349
350 # support for dropped privileges
351 if use qemu; then
352 fperms 0750 "${EROOT}/var/lib/libvirt/qemu"
353 fperms 0750 "${EROOT}/var/cache/libvirt/qemu"
354 fi
355
356 if use caps && use qemu; then
357 fowners -R qemu:qemu "${EROOT}/var/lib/libvirt/qemu"
358 fowners -R qemu:qemu "${EROOT}/var/cache/libvirt/qemu"
359 elif use qemu; then
360 fowners -R root:root "${EROOT}/var/lib/libvirt/qemu"
361 fowners -R root:root "${EROOT}/var/cache/libvirt/qemu"
362 fi
363
364 if ! use policykit; then
365 elog "To allow normal users to connect to libvirtd you must change the"
366 elog "unix sock group and/or perms in /etc/libvirt/libvirtd.conf"
367 fi
368
369 use libvirtd || return 0
370 # From here, only libvirtd-related instructions, be warned!
371
372 elog
373 elog "For the basic networking support (bridged and routed networks)"
374 elog "you don't need any extra software. For more complex network modes"
375 elog "including but not limited to NATed network, you can enable the"
376 elog "'virt-network' USE flag."
377 elog
378 if has_version net-dns/dnsmasq; then
379 ewarn "If you have a DNS server setup on your machine, you will have"
380 ewarn "to configure /etc/dnsmasq.conf to enable the following settings: "
381 ewarn " bind-interfaces"
382 ewarn " interface or except-interface"
383 ewarn
384 ewarn "Otherwise you might have issues with your existing DNS server."
385 fi
386
387 if use caps && use qemu; then
388 elog "libvirt will now start qemu/kvm VMs with non-root privileges."
389 elog "Ensure any resources your VMs use are accessible by qemu:qemu"
390 fi
391 }
392
393 pkg_postrm() {
394 use python && python_mod_cleanup libvirt.py
395 }

  ViewVC Help
Powered by ViewVC 1.1.20