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

Contents of /app-emulation/libvirt/libvirt-0.9.13-r1.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Tue Oct 9 20:35:26 2012 UTC (22 months, 2 weeks ago) by cardoe
Branch: MAIN
Changes since 1.4: +2 -2 lines
Reflect the app-emulation/qemu-kvm -> app-emulation/qemu move

(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.9.13-r1.ebuild,v 1.4 2012/08/22 13:11:25 nativemad 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.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 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-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-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 ~PID_NS
121 ~NET_NS
122 ~DEVPTS_MULTIPLE_INSTANCES
123 ~VETH
124 ~MACVLAN
125 ~POSIX_MQUEUE
126 ~!GRKERNSEC_CHROOT_MOUNT
127 ~!GRKERNSEC_CHROOT_DOUBLE
128 ~!GRKERNSEC_CHROOT_PIVOT
129 ~!GRKERNSEC_CHROOT_CHMOD
130 ~!GRKERNSEC_CHROOT_CAPS
131 "
132
133 VIRTNET_CONFIG_CHECK="
134 ~BRIDGE_NF_EBTABLES
135 ~NETFILTER_ADVANCED
136 ~NETFILTER_XT_TARGET_CHECKSUM
137 "
138
139 MACVTAP_CONFIG_CHECK="~MACVTAP"
140
141 pkg_setup() {
142 python_set_active_version 2
143 python_pkg_setup
144
145 enewgroup qemu 77
146 enewuser qemu 77 -1 -1 qemu kvm
147
148 # Some people used the masked ebuild which was not adding the qemu
149 # user to the kvm group originally. This results in VMs failing to
150 # start for some users. bug #430808
151 egetent group kvm | grep -q qemu
152 if [[ $? -ne 0 ]]; then
153 gpasswd -a qemu kvm
154 fi
155
156 CONFIG_CHECK=""
157 use lxc && CONFIG_CHECK+="${LXC_CONFIG_CHECK}"
158 kernel_is lt 3 5 && use lxc && CONFIG_CHECK+=" ~USER_NS"
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 if [[ ${PV} = *9999* ]]; then
172
173 # git checkouts require bootstrapping to create the configure script.
174 # Additionally the submodules must be cloned to the right locations
175 # bug #377279
176 ./bootstrap || die "bootstrap failed"
177 (
178 git submodule status | sed 's/^[ +-]//;s/ .*//'
179 git hash-object bootstrap.conf
180 ) >.git-module-status
181 fi
182
183 epatch_user
184
185 [[ -n ${AUTOTOOLIZE} ]] && eautoreconf
186 }
187
188 src_configure() {
189 local myconf=""
190
191 myconf="${myconf} $(use_enable debug)"
192
193 ## enable/disable daemon, otherwise client only utils
194 myconf="${myconf} $(use_with libvirtd)"
195
196 ## enable/disable the daemon using avahi to find VMs
197 myconf="${myconf} $(use_with avahi)"
198
199 ## hypervisors on the local host
200 myconf="${myconf} $(use_with xen) $(use_with xen xen-inotify)"
201 # leave it automagic as it depends on the version of xen used.
202 use xen || myconf+=" --without-libxl"
203 use xen || myconf+=" --without-xenapi"
204 myconf="${myconf} $(use_with openvz)"
205 myconf="${myconf} $(use_with lxc)"
206 if use virtualbox && has_version app-emulation/virtualbox-ose; then
207 myconf="${myconf} --with-vbox=/usr/lib/virtualbox-ose/"
208 else
209 myconf="${myconf} $(use_with virtualbox vbox)"
210 fi
211 myconf="${myconf} $(use_with uml)"
212 myconf="${myconf} $(use_with qemu)"
213 myconf="${myconf} $(use_with qemu yajl)" # Use QMP over HMP
214 myconf="${myconf} $(use_with phyp)"
215 myconf="${myconf} --with-esx"
216 myconf="${myconf} --with-vmware"
217
218 ## additional host drivers
219 myconf="${myconf} $(use_with virt-network network)"
220 myconf="${myconf} --with-storage-fs"
221 myconf="${myconf} $(use_with lvm storage-lvm)"
222 myconf="${myconf} $(use_with iscsi storage-iscsi)"
223 myconf="${myconf} $(use_with parted storage-disk)"
224 myconf="${myconf} $(use_with lvm storage-mpath)"
225 myconf="${myconf} $(use_with rbd storage-rbd)"
226 myconf="${myconf} $(use_with numa numactl)"
227 myconf="${myconf} $(use_with numa numad)"
228 myconf="${myconf} $(use_with selinux)"
229
230 # udev for device support details
231 myconf="${myconf} $(use_with udev)"
232
233 # linux capability support so we don't need privileged accounts
234 myconf="${myconf} $(use_with caps capng)"
235
236 ## auth stuff
237 myconf="${myconf} $(use_with policykit polkit)"
238 myconf="${myconf} $(use_with sasl)"
239
240 # network bits
241 myconf="${myconf} $(use_with macvtap)"
242 myconf="${myconf} $(use_with pcap libpcap)"
243 myconf="${myconf} $(use_with vepa virtualport)"
244
245 ## other
246 myconf="${myconf} $(use_enable nls)"
247 myconf="${myconf} $(use_with python)"
248
249 # user privilege bits fir qemu/kvm
250 if use caps; then
251 myconf="${myconf} --with-qemu-user=qemu"
252 myconf="${myconf} --with-qemu-group=qemu"
253 else
254 myconf="${myconf} --with-qemu-user=root"
255 myconf="${myconf} --with-qemu-group=root"
256 fi
257
258 # audit support
259 myconf="${myconf} $(use_with audit)"
260
261 ## stuff we don't yet support
262 myconf="${myconf} --without-netcf"
263
264 # we use udev over hal
265 myconf="${myconf} --without-hal"
266
267 # locking support
268 myconf="${myconf} --without-sanlock"
269
270 # this is a nasty trick to work around the problem in bug
271 # #275073. The reason why we don't solve this properly is that
272 # it'll require us to rebuild autotools (and we don't really want
273 # to do that right now). The proper solution has been sent
274 # upstream and should hopefully land in 0.7.7, in the mean time,
275 # mime the same functionality with this.
276 case ${CHOST} in
277 *cygwin* | *mingw* )
278 ;;
279 *)
280 ac_cv_prog_WINDRES=no
281 ;;
282 esac
283
284 econf \
285 ${myconf} \
286 --disable-static \
287 --docdir=/usr/share/doc/${PF} \
288 --with-remote \
289 --localstatedir=/var
290
291 if [[ ${PV} = *9999* ]]; then
292 # Restore gnulib's config.sub and config.guess
293 # bug #377279
294 (cd .gnulib && git reset --hard > /dev/null)
295 fi
296 }
297
298 src_test() {
299 # Explicitly allow parallel build of tests
300 HOME="${T}" emake check || die "tests failed"
301 }
302
303 src_install() {
304 emake install \
305 DESTDIR="${D}" \
306 HTML_DIR=/usr/share/doc/${PF}/html \
307 DOCS_DIR=/usr/share/doc/${PF}/python \
308 EXAMPLE_DIR=/usr/share/doc/${PF}/python/examples \
309 || die "emake install failed"
310
311 find "${D}" -name '*.la' -delete || die
312
313 use libvirtd || return 0
314 # From here, only libvirtd-related instructions, be warned!
315
316 newinitd "${FILESDIR}/libvirtd.init-r8" libvirtd || die
317 newconfd "${FILESDIR}/libvirtd.confd-r3" libvirtd || die
318
319 keepdir /var/lib/libvirt/images
320 }
321
322 pkg_preinst() {
323 # we only ever want to generate this once
324 if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then
325 rm -rf "${D}"/etc/libvirt/qemu/networks/default.xml
326 fi
327
328 # We really don't want to use or support old PolicyKit cause it
329 # screws with the new polkit integration
330 if has_version sys-auth/policykit; then
331 rm -rf "${D}"/usr/share/PolicyKit/policy/org.libvirt.unix.policy
332 fi
333
334 # Only sysctl files ending in .conf work
335 mv "${D}"/etc/sysctl.d/libvirtd "${D}"/etc/sysctl.d/libvirtd.conf
336 }
337
338 pkg_postinst() {
339 use python && python_mod_optimize libvirt.py
340
341 # support for dropped privileges
342 if use qemu; then
343 fperms 0750 "${EROOT}/var/lib/libvirt/qemu"
344 fperms 0750 "${EROOT}/var/cache/libvirt/qemu"
345 fi
346
347 if use caps && use qemu; then
348 fowners -R qemu:qemu "${EROOT}/var/lib/libvirt/qemu"
349 fowners -R qemu:qemu "${EROOT}/var/cache/libvirt/qemu"
350 elif use qemu; then
351 fowners -R root:root "${EROOT}/var/lib/libvirt/qemu"
352 fowners -R root:root "${EROOT}/var/cache/libvirt/qemu"
353 fi
354
355 if ! use policykit; then
356 elog "To allow normal users to connect to libvirtd you must change the"
357 elog "unix sock group and/or perms in /etc/libvirt/libvirtd.conf"
358 fi
359
360 use libvirtd || return 0
361 # From here, only libvirtd-related instructions, be warned!
362
363 elog
364 elog "For the basic networking support (bridged and routed networks)"
365 elog "you don't need any extra software. For more complex network modes"
366 elog "including but not limited to NATed network, you can enable the"
367 elog "'virt-network' USE flag."
368 elog
369 if has_version net-dns/dnsmasq; then
370 ewarn "If you have a DNS server setup on your machine, you will have"
371 ewarn "to configure /etc/dnsmasq.conf to enable the following settings: "
372 ewarn " bind-interfaces"
373 ewarn " interface or except-interface"
374 ewarn
375 ewarn "Otherwise you might have issues with your existing DNS server."
376 fi
377
378 if use caps && use qemu; then
379 elog "libvirt will now start qemu/kvm VMs with non-root privileges."
380 elog "Ensure any resources your VMs use are accessible by qemu:qemu"
381 fi
382 }
383
384 pkg_postrm() {
385 use python && python_mod_cleanup libvirt.py
386 }

  ViewVC Help
Powered by ViewVC 1.1.20