1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_{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 firewalld fuse glusterfs iscsi iscsi-direct
27 +libvirtd lvm libssh lxc +macvtap nfs nls numa openvz parted pcap phyp
28 policykit +qemu rbd sasl selinux +udev +vepa virtualbox virt-network
29 wireshark-plugins xen zeroconf 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 firewalld? ( >=net-firewall/firewalld-0.6.3 )
73 fuse? ( >=sys-fs/fuse-2.8.6:= )
74 glusterfs? ( >=sys-cluster/glusterfs-3.4.1 )
75 iscsi? ( sys-block/open-iscsi )
76 iscsi-direct? ( >=net-libs/libiscsi-1.18.0 )
77 libssh? ( net-libs/libssh )
78 lvm? ( >=sys-fs/lvm2-2.02.48-r2[-device-mapper-only(-)] )
79 nfs? ( net-fs/nfs-utils )
81 >sys-process/numactl-2.0.2
85 >=sys-block/parted-1.8[device-mapper]
86 sys-fs/lvm2[-device-mapper-only(-)]
88 pcap? ( >=net-libs/libpcap-1.0.0 )
89 policykit? ( >=sys-auth/polkit-0.9 )
91 >=app-emulation/qemu-1.5.0
94 rbd? ( sys-cluster/ceph )
95 sasl? ( dev-libs/cyrus-sasl )
96 selinux? ( >=sys-libs/libselinux-2.0.85 )
98 net-dns/dnsmasq[script]
100 >=net-firewall/iptables-1.4.10[ipv6]
102 sys-apps/iproute2[-minimal]
104 virtualbox? ( || ( app-emulation/virtualbox >=app-emulation/virtualbox-bin-2.2.0 ) )
105 wireshark-plugins? ( net-analyzer/wireshark:= )
107 >=app-emulation/xen-4.6.0
108 app-emulation/xen-tools:=
112 >=x11-libs/libpciaccess-0.10.9
114 zeroconf? ( >=net-dns/avahi-0.6[dbus] )
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
129 "${FILESDIR}"/${PN}-5.2.0-md-clear.patch
133 # Check kernel configuration:
135 use fuse && CONFIG_CHECK+="
138 use lvm && CONFIG_CHECK+="
143 use lxc && CONFIG_CHECK+="
164 ~!GRKERNSEC_CHROOT_MOUNT
165 ~!GRKERNSEC_CHROOT_DOUBLE
166 ~!GRKERNSEC_CHROOT_PIVOT
167 ~!GRKERNSEC_CHROOT_CHMOD
168 ~!GRKERNSEC_CHROOT_CAPS"
170 kernel_is lt 4 7 && use lxc && CONFIG_CHECK+="
171 ~DEVPTS_MULTIPLE_INSTANCES"
173 use macvtap && CONFIG_CHECK+="
176 use virt-network && CONFIG_CHECK+="
180 ~NETFILTER_XT_CONNMARK
182 ~NETFILTER_XT_TARGET_CHECKSUM
186 ~IP_NF_TARGET_MASQUERADE
190 # Bandwidth Limiting Support
191 use virt-network && CONFIG_CHECK+="
201 # Handle specific kernel versions for different features
202 kernel_is lt 3 6 && CONFIG_CHECK+=" ~CGROUP_MEM_RES_CTLR"
203 if kernel_is ge 3 6; then
204 CONFIG_CHECK+=" ~MEMCG ~MEMCG_SWAP "
205 kernel_is lt 4 5 && CONFIG_CHECK+=" ~MEMCG_KMEM "
208 ERROR_USER_NS="Optional depending on LXC configuration."
210 if [[ -n ${CONFIG_CHECK} ]]; then
216 touch "${S}/.mailmap"
220 if [[ ${PV} = *9999* ]]; then
221 # Reinitialize submodules as this is required for gnulib's bootstrap
223 # git checkouts require bootstrapping to create the configure script.
224 # Additionally the submodules must be cloned to the right locations
226 ./bootstrap || die "bootstrap failed"
228 git submodule status .gnulib | awk '{ print $1 }'
229 git hash-object bootstrap.conf
230 git ls-tree -d HEAD gnulib/local | awk '{ print $3 }'
231 ) >.git-module-status
234 # Tweak the init script:
235 cp "${FILESDIR}/libvirtd.init-r17" "${S}/libvirtd.init" || die
236 sed -e "s/USE_FLAG_FIREWALLD/$(usex firewalld 'need firewalld' '')/" \
237 -e "s/USE_FLAG_AVAHI/$(usex zeroconf 'use avahi-daemon' '')/" \
238 -e "s/USE_FLAG_ISCSI/$(usex iscsi 'use iscsid' '')/" \
239 -e "s/USE_FLAG_RBD/$(usex rbd 'use ceph' '')/" \
240 -i "${S}/libvirtd.init" || die "sed failed"
248 $(use_with apparmor apparmor-profiles)
250 $(use_with caps capng)
252 $(use_with firewalld)
254 $(use_with glusterfs)
255 $(use_with glusterfs storage-gluster)
256 $(use_with iscsi storage-iscsi)
257 $(use_with iscsi-direct storage-iscsi-direct)
260 $(use_with lvm storage-lvm)
261 $(use_with lvm storage-mpath)
265 $(use_with numa numactl)
266 $(use_with numa numad)
268 $(use_with parted storage-disk)
269 $(use_with pcap libpcap)
271 $(use_with policykit polkit)
273 $(use_with qemu yajl)
274 $(use_with rbd storage-rbd)
278 $(use_with vepa virtualport)
279 $(use_with virt-network network)
280 $(use_with wireshark-plugins wireshark-dissector)
281 $(use_with xen libxl)
282 $(use_with zeroconf avahi)
283 $(use_with zfs storage-zfs)
290 --with-init-script=systemd
291 --with-qemu-group=$(usex caps qemu root)
292 --with-qemu-user=$(usex caps qemu root)
300 --with-html-subdir=${PF}/html
304 if use virtualbox && has_version app-emulation/virtualbox-ose; then
305 myeconfargs+=( --with-vbox=/usr/lib/virtualbox-ose/ )
307 myeconfargs+=( $(use_with virtualbox vbox) )
310 econf "${myeconfargs[@]}"
312 if [[ ${PV} = *9999* ]]; then
313 # Restore gnulib's config.sub and config.guess
315 (cd .gnulib && git reset --hard > /dev/null)
322 # remove problematic tests, bug #591416, bug #591418
323 sed -i -e 's#commandtest$(EXEEXT) # #' \
324 -e 's#virfirewalltest$(EXEEXT) # #' \
325 -e 's#nwfilterebiptablestest$(EXEEXT) # #' \
326 -e 's#nwfilterxml2firewalltest$(EXEEXT)$##' \
329 export VIR_TEST_DEBUG=1
330 HOME="${T}" emake check
334 emake DESTDIR="${D}" \
335 SYSTEMD_UNIT_DIR="$(systemd_get_systemunitdir)" install
337 find "${D}" -name '*.la' -delete || die
339 # Remove bogus, empty directories. They are either not used, or
340 # libvirtd is able to create them on demand
341 rm -rf "${D}"/etc/sysconfig
344 newbashcomp "${S}/tools/bash-completion/vsh" virsh
345 bashcomp_alias virsh virt-admin
347 use libvirtd || return 0
348 # From here, only libvirtd-related instructions, be warned!
350 systemd_install_serviced \
351 "${FILESDIR}"/libvirtd.service.conf libvirtd.service
353 systemd_newtmpfilesd "${FILESDIR}"/libvirtd.tmpfiles.conf libvirtd.conf
355 newinitd "${S}/libvirtd.init" libvirtd
356 newinitd "${FILESDIR}/libvirt-guests.init-r3" libvirt-guests
357 newinitd "${FILESDIR}/virtlockd.init-r1" virtlockd
358 newinitd "${FILESDIR}/virtlogd.init-r1" virtlogd
360 newconfd "${FILESDIR}/libvirtd.confd-r5" libvirtd
361 newconfd "${FILESDIR}/libvirt-guests.confd" libvirt-guests
363 DOC_CONTENTS=$(<"${FILESDIR}/README.gentoo-r2")
364 DISABLE_AUTOFORMATTING=true
365 readme.gentoo_create_doc
369 # we only ever want to generate this once
370 if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then
371 rm -rf "${D}"/etc/libvirt/qemu/networks/default.xml
376 if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then
377 touch "${ROOT}"/etc/libvirt/qemu/networks/default.xml
380 use libvirtd || return 0
381 # From here, only libvirtd-related instructions, be warned!
383 readme.gentoo_print_elog