1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_{5,6,7} )
8 inherit autotools bash-completion-r1 eutils linux-info python-any-r1 readme.gentoo-r1 systemd
10 if [[ ${PV} = *9999* ]]; then
12 EGIT_REPO_URI="https://libvirt.org/git/libvirt.git"
17 SRC_URI="https://libvirt.org/sources/${P}.tar.xz"
18 KEYWORDS="amd64 ~arm64 x86"
22 DESCRIPTION="C toolkit to manipulate virtual machines"
23 HOMEPAGE="http://www.libvirt.org/"
26 apparmor audit +caps +dbus dtrace firewalld fuse glusterfs iscsi
27 iscsi-direct +libvirtd lvm libssh lxc +macvtap nfs nls numa openvz
28 parted pcap phyp policykit +qemu rbd sasl selinux +udev +vepa
29 virtualbox virt-network wireshark-plugins xen zfs
33 firewalld? ( virt-network )
34 libvirtd? ( || ( lxc openvz qemu virtualbox xen ) )
35 lxc? ( caps libvirtd )
40 virt-network? ( libvirtd )
41 virtualbox? ( libvirtd )
44 # gettext.sh command is used by the libvirt command wrappers, and it's
45 # non-optional, so put it into RDEPEND.
46 # We can use both libnl:1.1 and libnl:3, but if you have both installed, the
47 # package will use 3 by default. Since we don't have slot pinning in an API,
48 # we must go with the most recent
51 policykit? ( acct-group/libvirt )
55 >=dev-libs/libxml2-2.7.6
56 >=net-analyzer/openbsd-netcat-1.105-r1
57 >=net-libs/gnutls-1.0.25:0=
61 >=net-misc/curl-7.18.0
63 !sys-apps/systemd[-cgroup-hybrid(+)]
64 >=sys-apps/util-linux-2.17
68 apparmor? ( sys-libs/libapparmor )
69 audit? ( sys-process/audit )
70 caps? ( sys-libs/libcap-ng )
71 dbus? ( sys-apps/dbus )
72 dtrace? ( dev-util/systemtap )
73 firewalld? ( >=net-firewall/firewalld-0.6.3 )
74 fuse? ( >=sys-fs/fuse-2.8.6:= )
75 glusterfs? ( >=sys-cluster/glusterfs-3.4.1 )
76 iscsi? ( sys-block/open-iscsi )
77 iscsi-direct? ( >=net-libs/libiscsi-1.18.0 )
78 libssh? ( net-libs/libssh )
79 lvm? ( >=sys-fs/lvm2-2.02.48-r2[-device-mapper-only(-)] )
80 nfs? ( net-fs/nfs-utils )
82 >sys-process/numactl-2.0.2
86 >=sys-block/parted-1.8[device-mapper]
87 sys-fs/lvm2[-device-mapper-only(-)]
89 pcap? ( >=net-libs/libpcap-1.0.0 )
90 policykit? ( >=sys-auth/polkit-0.9 )
92 >=app-emulation/qemu-1.5.0
95 rbd? ( sys-cluster/ceph )
96 sasl? ( dev-libs/cyrus-sasl )
97 selinux? ( >=sys-libs/libselinux-2.0.85 )
99 net-dns/dnsmasq[script]
100 net-firewall/ebtables
101 >=net-firewall/iptables-1.4.10[ipv6]
103 sys-apps/iproute2[-minimal]
105 virtualbox? ( || ( app-emulation/virtualbox >=app-emulation/virtualbox-bin-2.2.0 ) )
106 wireshark-plugins? ( net-analyzer/wireshark:= )
108 >=app-emulation/xen-4.6.0
109 app-emulation/xen-tools:=
113 >=x11-libs/libpciaccess-0.10.9
126 "${FILESDIR}"/${PN}-5.2.0-do-not-use-sysconf.patch
127 "${FILESDIR}"/${PN}-1.2.16-fix_paths_in_libvirt-guests_sh.patch
128 "${FILESDIR}"/${PN}-5.2.0-fix-paths-for-apparmor.patch
132 # Check kernel configuration:
134 use fuse && CONFIG_CHECK+="
137 use lvm && CONFIG_CHECK+="
142 use lxc && CONFIG_CHECK+="
163 ~!GRKERNSEC_CHROOT_MOUNT
164 ~!GRKERNSEC_CHROOT_DOUBLE
165 ~!GRKERNSEC_CHROOT_PIVOT
166 ~!GRKERNSEC_CHROOT_CHMOD
167 ~!GRKERNSEC_CHROOT_CAPS"
169 kernel_is lt 4 7 && use lxc && CONFIG_CHECK+="
170 ~DEVPTS_MULTIPLE_INSTANCES"
172 use macvtap && CONFIG_CHECK+="
175 use virt-network && CONFIG_CHECK+="
179 ~NETFILTER_XT_CONNMARK
181 ~NETFILTER_XT_TARGET_CHECKSUM
185 ~IP_NF_TARGET_MASQUERADE
189 # Bandwidth Limiting Support
190 use virt-network && CONFIG_CHECK+="
200 # Handle specific kernel versions for different features
201 kernel_is lt 3 6 && CONFIG_CHECK+=" ~CGROUP_MEM_RES_CTLR"
202 if kernel_is ge 3 6; then
203 CONFIG_CHECK+=" ~MEMCG ~MEMCG_SWAP "
204 kernel_is lt 4 5 && CONFIG_CHECK+=" ~MEMCG_KMEM "
207 ERROR_USER_NS="Optional depending on LXC configuration."
209 if [[ -n ${CONFIG_CHECK} ]]; then
215 touch "${S}/.mailmap"
219 if [[ ${PV} = *9999* ]]; then
220 # Reinitialize submodules as this is required for gnulib's bootstrap
222 # git checkouts require bootstrapping to create the configure script.
223 # Additionally the submodules must be cloned to the right locations
225 ./bootstrap || die "bootstrap failed"
227 git submodule status .gnulib | awk '{ print $1 }'
228 git hash-object bootstrap.conf
229 git ls-tree -d HEAD gnulib/local | awk '{ print $3 }'
230 ) >.git-module-status
233 # Tweak the init script:
234 cp "${FILESDIR}/libvirtd.init-r18" "${S}/libvirtd.init" || die
235 sed -e "s/USE_FLAG_FIREWALLD/$(usex firewalld 'need firewalld' '')/" \
236 -i "${S}/libvirtd.init" || die "sed failed"
244 $(use_with apparmor apparmor-profiles)
246 $(use_with caps capng)
249 $(use_with firewalld)
251 $(use_with glusterfs)
252 $(use_with glusterfs storage-gluster)
253 $(use_with iscsi storage-iscsi)
254 $(use_with iscsi-direct storage-iscsi-direct)
257 $(use_with lvm storage-lvm)
258 $(use_with lvm storage-mpath)
262 $(use_with numa numactl)
263 $(use_with numa numad)
265 $(use_with parted storage-disk)
266 $(use_with pcap libpcap)
268 $(use_with policykit polkit)
270 $(use_with qemu yajl)
271 $(use_with rbd storage-rbd)
275 $(use_with vepa virtualport)
276 $(use_with virt-network network)
277 $(use_with wireshark-plugins wireshark-dissector)
278 $(use_with xen libxl)
279 $(use_with zfs storage-zfs)
286 --with-init-script=systemd
287 --with-qemu-group=$(usex caps qemu root)
288 --with-qemu-user=$(usex caps qemu root)
299 if use virtualbox && has_version app-emulation/virtualbox-ose; then
300 myeconfargs+=( --with-vbox=/usr/lib/virtualbox-ose/ )
302 myeconfargs+=( $(use_with virtualbox vbox) )
305 econf "${myeconfargs[@]}"
307 if [[ ${PV} = *9999* ]]; then
308 # Restore gnulib's config.sub and config.guess
310 (cd .gnulib && git reset --hard > /dev/null)
317 # remove problematic tests, bug #591416, bug #591418
318 sed -i -e 's#commandtest$(EXEEXT) # #' \
319 -e 's#virfirewalltest$(EXEEXT) # #' \
320 -e 's#nwfilterebiptablestest$(EXEEXT) # #' \
321 -e 's#nwfilterxml2firewalltest$(EXEEXT)$##' \
324 export VIR_TEST_DEBUG=1
325 HOME="${T}" emake check || die "tests failed"
329 emake DESTDIR="${D}" \
330 SYSTEMD_UNIT_DIR="$(systemd_get_systemunitdir)" install
332 find "${D}" -name '*.la' -delete || die
334 # Remove bogus, empty directories. They are either not used, or
335 # libvirtd is able to create them on demand
336 rm -rf "${D}"/etc/sysconfig
339 newbashcomp "${S}/tools/bash-completion/vsh" virsh
340 bashcomp_alias virsh virt-admin
342 use libvirtd || return 0
343 # From here, only libvirtd-related instructions, be warned!
345 systemd_install_serviced \
346 "${FILESDIR}"/libvirtd.service.conf libvirtd.service
348 systemd_newtmpfilesd "${FILESDIR}"/libvirtd.tmpfiles.conf libvirtd.conf
350 newinitd "${S}/libvirtd.init" libvirtd || die
351 newinitd "${FILESDIR}/libvirt-guests.init-r4" libvirt-guests || die
352 newinitd "${FILESDIR}/virtlockd.init-r1" virtlockd || die
353 newinitd "${FILESDIR}/virtlogd.init-r1" virtlogd || die
355 newconfd "${FILESDIR}/libvirtd.confd-r5" libvirtd || die
356 newconfd "${FILESDIR}/libvirt-guests.confd" libvirt-guests || die
358 DOC_CONTENTS=$(<"${FILESDIR}/README.gentoo-r2")
359 DISABLE_AUTOFORMATTING=true
360 readme.gentoo_create_doc
364 # we only ever want to generate this once
365 if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then
366 rm -rf "${D}"/etc/libvirt/qemu/networks/default.xml
371 if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then
372 touch "${ROOT}"/etc/libvirt/qemu/networks/default.xml
375 use libvirtd || return 0
376 # From here, only libvirtd-related instructions, be warned!
378 readme.gentoo_print_elog