/[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.1 - (show annotations) (download)
Sun Nov 4 01:29:38 2012 UTC (22 months, 1 week ago) by cardoe
Branch: MAIN
Version bump. Add support for firewalld as well.

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

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

  ViewVC Help
Powered by ViewVC 1.1.20