/[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.5 - (show annotations) (download)
Thu Jan 24 04:18:47 2013 UTC (18 months ago) by cardoe
Branch: MAIN
Changes since 1.4: +4 -5 lines
Tweak Xen depends to make bug #446572 not bite people.

(Portage version: 2.2.0_alpha159/cvs/Linux x86_64, unsigned Manifest commit)

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.4 2012/11/29 02:13:06 ssuominen 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 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 5 && LXC_CONFIG_CHECK+=" ~USER_NS"
163 kernel_is lt 3 6 && LXC_CONFIG_CHECK+=" ~CGROUP_MEM_RES_CTLR" || \
164 LXC_CONFIG_CHECK+=" ~MEMCG"
165
166 CONFIG_CHECK=""
167 use lxc && CONFIG_CHECK+="${LXC_CONFIG_CHECK}"
168 use macvtap && CONFIG_CHECK+="${MACVTAP}"
169 use virt-network && CONFIG_CHECK+="${VIRTNET_CONFIG_CHECK}"
170 if [[ -n ${CONFIG_CHECK} ]]; then
171 linux-info_pkg_setup
172 fi
173 }
174
175 src_prepare() {
176 touch "${S}/.mailmap"
177 [[ -n ${BACKPORTS} ]] && \
178 EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \
179 epatch
180
181 if [[ ${PV} = *9999* ]]; then
182
183 # git checkouts require bootstrapping to create the configure script.
184 # Additionally the submodules must be cloned to the right locations
185 # bug #377279
186 ./bootstrap || die "bootstrap failed"
187 (
188 git submodule status | sed 's/^[ +-]//;s/ .*//'
189 git hash-object bootstrap.conf
190 ) >.git-module-status
191 fi
192
193 epatch_user
194
195 [[ -n ${AUTOTOOLIZE} ]] && eautoreconf
196
197 # Tweak the init script
198 local avahi_init=
199 local iscsi_init=
200 local rbd_init=
201 local firewalld_init=
202 cp "${FILESDIR}/libvirtd.init-r11" "${S}/libvirtd.init"
203 use avahi && avahi_init='avahi-daemon'
204 use iscsi && iscsi_init='iscsid'
205 use rbd && rbd_init='ceph'
206 use firewalld && firewalld_init='need firewalld'
207
208 sed -e "s/USE_FLAG_FIREWALLD/${firewalld_init}/" -i "${S}/libvirtd.init"
209 sed -e "s/USE_FLAG_AVAHI/${avahi_init}/" -i "${S}/libvirtd.init"
210 sed -e "s/USE_FLAG_ISCSI/${iscsi_init}/" -i "${S}/libvirtd.init"
211 sed -e "s/USE_FLAG_RBD/${rbd_init}/" -i "${S}/libvirtd.init"
212 }
213
214 src_configure() {
215 local myconf=""
216
217 myconf="${myconf} $(use_enable debug)"
218
219 ## enable/disable daemon, otherwise client only utils
220 myconf="${myconf} $(use_with libvirtd)"
221
222 ## enable/disable the daemon using avahi to find VMs
223 myconf="${myconf} $(use_with avahi)"
224
225 ## hypervisors on the local host
226 myconf="${myconf} $(use_with xen) $(use_with xen xen-inotify)"
227 myconf="${myconf} $(use_with xen xenapi)"
228 myconf+=" --without-libxl"
229 myconf="${myconf} $(use_with openvz)"
230 myconf="${myconf} $(use_with lxc)"
231 if use virtualbox && has_version app-emulation/virtualbox-ose; then
232 myconf="${myconf} --with-vbox=/usr/lib/virtualbox-ose/"
233 else
234 myconf="${myconf} $(use_with virtualbox vbox)"
235 fi
236 myconf="${myconf} $(use_with uml)"
237 myconf="${myconf} $(use_with qemu)"
238 myconf="${myconf} $(use_with qemu yajl)" # Use QMP over HMP
239 myconf="${myconf} $(use_with phyp)"
240 myconf="${myconf} --with-esx"
241 myconf="${myconf} --with-vmware"
242
243 ## additional host drivers
244 myconf="${myconf} $(use_with virt-network network)"
245 myconf="${myconf} --with-storage-fs"
246 myconf="${myconf} $(use_with lvm storage-lvm)"
247 myconf="${myconf} $(use_with iscsi storage-iscsi)"
248 myconf="${myconf} $(use_with parted storage-disk)"
249 myconf="${myconf} $(use_with lvm storage-mpath)"
250 myconf="${myconf} $(use_with rbd storage-rbd)"
251 myconf="${myconf} $(use_with numa numactl)"
252 myconf="${myconf} $(use_with numa numad)"
253 myconf="${myconf} $(use_with selinux)"
254
255 # udev for device support details
256 myconf="${myconf} $(use_with udev)"
257
258 # linux capability support so we don't need privileged accounts
259 myconf="${myconf} $(use_with caps capng)"
260
261 ## auth stuff
262 myconf="${myconf} $(use_with policykit polkit)"
263 myconf="${myconf} $(use_with sasl)"
264
265 # network bits
266 myconf="${myconf} $(use_with macvtap)"
267 myconf="${myconf} $(use_with pcap libpcap)"
268 myconf="${myconf} $(use_with vepa virtualport)"
269 myconf="${myconf} $(use_with firewalld)"
270
271 ## other
272 myconf="${myconf} $(use_enable nls)"
273 myconf="${myconf} $(use_with python)"
274
275 # user privilege bits fir qemu/kvm
276 if use caps; then
277 myconf="${myconf} --with-qemu-user=qemu"
278 myconf="${myconf} --with-qemu-group=qemu"
279 else
280 myconf="${myconf} --with-qemu-user=root"
281 myconf="${myconf} --with-qemu-group=root"
282 fi
283
284 # audit support
285 myconf="${myconf} $(use_with audit)"
286
287 ## stuff we don't yet support
288 myconf="${myconf} --without-netcf"
289
290 # we use udev over hal
291 myconf="${myconf} --without-hal"
292
293 # locking support
294 myconf="${myconf} --without-sanlock"
295
296 # this is a nasty trick to work around the problem in bug
297 # #275073. The reason why we don't solve this properly is that
298 # it'll require us to rebuild autotools (and we don't really want
299 # to do that right now). The proper solution has been sent
300 # upstream and should hopefully land in 0.7.7, in the mean time,
301 # mime the same functionality with this.
302 case ${CHOST} in
303 *cygwin* | *mingw* )
304 ;;
305 *)
306 ac_cv_prog_WINDRES=no
307 ;;
308 esac
309
310 econf \
311 ${myconf} \
312 --disable-static \
313 --docdir=/usr/share/doc/${PF} \
314 --with-remote \
315 --localstatedir=/var
316
317 if [[ ${PV} = *9999* ]]; then
318 # Restore gnulib's config.sub and config.guess
319 # bug #377279
320 (cd .gnulib && git reset --hard > /dev/null)
321 fi
322 }
323
324 src_test() {
325 # Explicitly allow parallel build of tests
326 export VIR_TEST_DEBUG=1
327 HOME="${T}" emake check || die "tests failed"
328 }
329
330 src_install() {
331 emake install \
332 DESTDIR="${D}" \
333 HTML_DIR=/usr/share/doc/${PF}/html \
334 DOCS_DIR=/usr/share/doc/${PF}/python \
335 EXAMPLE_DIR=/usr/share/doc/${PF}/python/examples \
336 || die "emake install failed"
337
338 find "${D}" -name '*.la' -delete || die
339
340 use libvirtd || return 0
341 # From here, only libvirtd-related instructions, be warned!
342
343 newinitd "${S}/libvirtd.init" libvirtd || die
344 newconfd "${FILESDIR}/libvirtd.confd-r4" libvirtd || die
345
346 keepdir /var/lib/libvirt/images
347 }
348
349 pkg_preinst() {
350 # we only ever want to generate this once
351 if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then
352 rm -rf "${D}"/etc/libvirt/qemu/networks/default.xml
353 fi
354
355 # We really don't want to use or support old PolicyKit cause it
356 # screws with the new polkit integration
357 if has_version sys-auth/policykit; then
358 rm -rf "${D}"/usr/share/PolicyKit/policy/org.libvirt.unix.policy
359 fi
360
361 # Only sysctl files ending in .conf work
362 mv "${D}"/etc/sysctl.d/libvirtd "${D}"/etc/sysctl.d/libvirtd.conf
363 }
364
365 pkg_postinst() {
366 use python && python_mod_optimize libvirt.py
367
368 # support for dropped privileges
369 if use qemu; then
370 fperms 0750 "${EROOT}/var/lib/libvirt/qemu"
371 fperms 0750 "${EROOT}/var/cache/libvirt/qemu"
372 fi
373
374 if use caps && use qemu; then
375 fowners -R qemu:qemu "${EROOT}/var/lib/libvirt/qemu"
376 fowners -R qemu:qemu "${EROOT}/var/cache/libvirt/qemu"
377 elif use qemu; then
378 fowners -R root:root "${EROOT}/var/lib/libvirt/qemu"
379 fowners -R root:root "${EROOT}/var/cache/libvirt/qemu"
380 fi
381
382 if ! use policykit; then
383 elog "To allow normal users to connect to libvirtd you must change the"
384 elog "unix sock group and/or perms in /etc/libvirt/libvirtd.conf"
385 fi
386
387 use libvirtd || return 0
388 # From here, only libvirtd-related instructions, be warned!
389
390 elog
391 elog "For the basic networking support (bridged and routed networks)"
392 elog "you don't need any extra software. For more complex network modes"
393 elog "including but not limited to NATed network, you can enable the"
394 elog "'virt-network' USE flag."
395 elog
396 if has_version net-dns/dnsmasq; then
397 ewarn "If you have a DNS server setup on your machine, you will have"
398 ewarn "to configure /etc/dnsmasq.conf to enable the following settings: "
399 ewarn " bind-interfaces"
400 ewarn " interface or except-interface"
401 ewarn
402 ewarn "Otherwise you might have issues with your existing DNS server."
403 fi
404
405 if use caps && use qemu; then
406 elog "libvirt will now start qemu/kvm VMs with non-root privileges."
407 elog "Ensure any resources your VMs use are accessible by qemu:qemu"
408 fi
409 }
410
411 pkg_postrm() {
412 use python && python_mod_cleanup libvirt.py
413 }

  ViewVC Help
Powered by ViewVC 1.1.20