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 ~ppc64 ~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 pm-utils 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/util-linux-2.17
67 apparmor? ( sys-libs/libapparmor )
68 audit? ( sys-process/audit )
69 caps? ( sys-libs/libcap-ng )
70 dbus? ( sys-apps/dbus )
71 dtrace? ( dev-util/systemtap )
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 lxc? ( !sys-apps/systemd[-cgroup-hybrid(+)] )
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 pm-utils? ( sys-power/pm-utils )
91 policykit? ( >=sys-auth/polkit-0.9 )
93 >=app-emulation/qemu-1.5.0
96 rbd? ( sys-cluster/ceph )
97 sasl? ( dev-libs/cyrus-sasl )
98 selinux? ( >=sys-libs/libselinux-2.0.85 )
100 net-dns/dnsmasq[script]
101 net-firewall/ebtables
102 >=net-firewall/iptables-1.4.10[ipv6]
104 sys-apps/iproute2[-minimal]
106 virtualbox? ( || ( app-emulation/virtualbox >=app-emulation/virtualbox-bin-2.2.0 ) )
107 wireshark-plugins? ( net-analyzer/wireshark:= )
109 >=app-emulation/xen-4.6.0
110 app-emulation/xen-tools:=
114 >=x11-libs/libpciaccess-0.10.9
127 "${FILESDIR}"/${PN}-5.7.0-do-not-use-sysconf.patch
128 "${FILESDIR}"/${PN}-1.2.16-fix_paths_in_libvirt-guests_sh.patch
129 "${FILESDIR}"/${PN}-5.2.0-fix-paths-for-apparmor.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-r18" "${S}/libvirtd.init" || die
236 sed -e "s/USE_FLAG_FIREWALLD/$(usex firewalld 'need firewalld' '')/" \
237 -i "${S}/libvirtd.init" || die "sed failed"
245 $(use_with apparmor apparmor-profiles)
247 $(use_with caps capng)
250 $(use_with firewalld)
252 $(use_with glusterfs)
253 $(use_with glusterfs storage-gluster)
254 $(use_with iscsi storage-iscsi)
255 $(use_with iscsi-direct storage-iscsi-direct)
258 $(use_with lvm storage-lvm)
259 $(use_with lvm storage-mpath)
263 $(use_with numa numactl)
264 $(use_with numa numad)
266 $(use_with parted storage-disk)
267 $(use_with pcap libpcap)
269 $(use_with pm-utils )
270 $(use_with policykit polkit)
272 $(use_with qemu yajl)
273 $(use_with rbd storage-rbd)
277 $(use_with vepa virtualport)
278 $(use_with virt-network network)
279 $(use_with wireshark-plugins wireshark-dissector)
280 $(use_with xen libxl)
281 $(use_with zfs storage-zfs)
288 --with-init-script=systemd
289 --with-qemu-group=$(usex caps qemu root)
290 --with-qemu-user=$(usex caps qemu root)
298 --localstatedir="$EPREFIX/var"
299 --with-runstatedir="$EPREFIX/run"
302 if use virtualbox && has_version app-emulation/virtualbox-ose; then
303 myeconfargs+=( --with-vbox=/usr/lib/virtualbox-ose/ )
305 myeconfargs+=( $(use_with virtualbox vbox) )
308 econf "${myeconfargs[@]}"
310 if [[ ${PV} = *9999* ]]; then
311 # Restore gnulib's config.sub and config.guess
313 (cd .gnulib && git reset --hard > /dev/null)
320 # remove problematic tests, bug #591416, bug #591418
321 sed -i -e 's#commandtest$(EXEEXT) # #' \
322 -e 's#virfirewalltest$(EXEEXT) # #' \
323 -e 's#nwfilterebiptablestest$(EXEEXT) # #' \
324 -e 's#nwfilterxml2firewalltest$(EXEEXT)$##' \
327 export VIR_TEST_DEBUG=1
328 HOME="${T}" emake check
332 emake DESTDIR="${D}" \
333 SYSTEMD_UNIT_DIR="$(systemd_get_systemunitdir)" install
335 find "${D}" -name '*.la' -delete || die
337 # Remove bogus, empty directories. They are either not used, or
338 # libvirtd is able to create them on demand
339 rm -rf "${D}"/etc/sysconfig
343 newbashcomp "${S}/tools/bash-completion/vsh" virsh
344 bashcomp_alias virsh virt-admin
346 use libvirtd || return 0
347 # From here, only libvirtd-related instructions, be warned!
349 systemd_install_serviced \
350 "${FILESDIR}"/libvirtd.service.conf libvirtd.service
352 systemd_newtmpfilesd "${FILESDIR}"/libvirtd.tmpfiles.conf libvirtd.conf
354 newinitd "${S}/libvirtd.init" libvirtd
355 newinitd "${FILESDIR}/libvirt-guests.init-r4" libvirt-guests
356 newinitd "${FILESDIR}/virtlockd.init-r1" virtlockd
357 newinitd "${FILESDIR}/virtlogd.init-r1" virtlogd
359 newconfd "${FILESDIR}/libvirtd.confd-r5" libvirtd
360 newconfd "${FILESDIR}/libvirt-guests.confd" libvirt-guests
362 DOC_CONTENTS=$(<"${FILESDIR}/README.gentoo-r2")
363 DISABLE_AUTOFORMATTING=true
364 readme.gentoo_create_doc
368 # we only ever want to generate this once
369 if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then
370 rm -rf "${D}"/etc/libvirt/qemu/networks/default.xml
375 if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then
376 touch "${ROOT}"/etc/libvirt/qemu/networks/default.xml
379 use libvirtd || return 0
380 # From here, only libvirtd-related instructions, be warned!
382 readme.gentoo_print_elog