/[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.4 - (hide annotations) (download)
Thu Nov 29 02:13:06 2012 UTC (21 months, 2 weeks ago) by ssuominen
Branch: MAIN
Changes since 1.3: +2 -2 lines
Use virtual/udev instead of sys-fs/udev

(Portage version: 2.2.0_alpha142/cvs/Linux x86_64, signed Manifest commit with key 4868F14D)

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

  ViewVC Help
Powered by ViewVC 1.1.20