app-emulation/libvirt: keyword 5.8.0 on ~ppc64
[gentoo.git] / app-emulation / libvirt / libvirt-5.8.0.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python3_{5,6,7} )
7
8 inherit autotools bash-completion-r1 eutils linux-info python-any-r1 readme.gentoo-r1 systemd
9
10 if [[ ${PV} = *9999* ]]; then
11         inherit git-r3
12         EGIT_REPO_URI="https://libvirt.org/git/libvirt.git"
13         SRC_URI=""
14         KEYWORDS=""
15         SLOT="0"
16 else
17         SRC_URI="https://libvirt.org/sources/${P}.tar.xz"
18         KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86"
19         SLOT="0/${PV}"
20 fi
21
22 DESCRIPTION="C toolkit to manipulate virtual machines"
23 HOMEPAGE="http://www.libvirt.org/"
24 LICENSE="LGPL-2.1"
25 IUSE="
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
30 "
31
32 REQUIRED_USE="
33         firewalld? ( virt-network )
34         libvirtd? ( || ( lxc openvz qemu virtualbox xen ) )
35         lxc? ( caps libvirtd )
36         openvz? ( libvirtd )
37         policykit? ( dbus )
38         qemu? ( libvirtd )
39         vepa? ( macvtap )
40         virt-network? ( libvirtd )
41         virtualbox? ( libvirtd )
42         xen? ( libvirtd )"
43
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
49 RDEPEND="
50         acct-user/qemu
51         policykit? ( acct-group/libvirt )
52         app-misc/scrub
53         dev-libs/libgcrypt:0
54         dev-libs/libnl:3
55         >=dev-libs/libxml2-2.7.6
56         >=net-analyzer/openbsd-netcat-1.105-r1
57         >=net-libs/gnutls-1.0.25:0=
58         net-libs/libssh2
59         net-libs/libtirpc
60         net-libs/rpcsvc-proto
61         >=net-misc/curl-7.18.0
62         sys-apps/dmidecode
63         >=sys-apps/util-linux-2.17
64         sys-devel/gettext
65         sys-libs/ncurses:0=
66         sys-libs/readline:=
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 )
81         numa? (
82                 >sys-process/numactl-2.0.2
83                 sys-process/numad
84         )
85         parted? (
86                 >=sys-block/parted-1.8[device-mapper]
87                 sys-fs/lvm2[-device-mapper-only(-)]
88         )
89         pcap? ( >=net-libs/libpcap-1.0.0 )
90         pm-utils? ( sys-power/pm-utils )
91         policykit? ( >=sys-auth/polkit-0.9 )
92         qemu? (
93                 >=app-emulation/qemu-1.5.0
94                 dev-libs/yajl
95         )
96         rbd? ( sys-cluster/ceph )
97         sasl? ( dev-libs/cyrus-sasl )
98         selinux? ( >=sys-libs/libselinux-2.0.85 )
99         virt-network? (
100                 net-dns/dnsmasq[script]
101                 net-firewall/ebtables
102                 >=net-firewall/iptables-1.4.10[ipv6]
103                 net-misc/radvd
104                 sys-apps/iproute2[-minimal]
105         )
106         virtualbox? ( || ( app-emulation/virtualbox >=app-emulation/virtualbox-bin-2.2.0 ) )
107         wireshark-plugins? ( net-analyzer/wireshark:= )
108         xen? (
109                 >=app-emulation/xen-4.6.0
110                 app-emulation/xen-tools:=
111         )
112         udev? (
113                 virtual/udev
114                 >=x11-libs/libpciaccess-0.10.9
115         )
116         zfs? ( sys-fs/zfs )"
117
118 DEPEND="${RDEPEND}
119         ${PYTHON_DEPS}
120         app-text/xhtml1
121         dev-lang/perl
122         dev-libs/libxslt
123         dev-perl/XML-XPath
124         virtual/pkgconfig"
125
126 PATCHES=(
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
130 )
131
132 pkg_setup() {
133         # Check kernel configuration:
134         CONFIG_CHECK=""
135         use fuse && CONFIG_CHECK+="
136                 ~FUSE_FS"
137
138         use lvm && CONFIG_CHECK+="
139                 ~BLK_DEV_DM
140                 ~DM_MULTIPATH
141                 ~DM_SNAPSHOT"
142
143         use lxc && CONFIG_CHECK+="
144                 ~BLK_CGROUP
145                 ~CGROUP_CPUACCT
146                 ~CGROUP_DEVICE
147                 ~CGROUP_FREEZER
148                 ~CGROUP_NET_PRIO
149                 ~CGROUP_PERF
150                 ~CGROUPS
151                 ~CGROUP_SCHED
152                 ~CPUSETS
153                 ~IPC_NS
154                 ~MACVLAN
155                 ~NAMESPACES
156                 ~NET_CLS_CGROUP
157                 ~NET_NS
158                 ~PID_NS
159                 ~POSIX_MQUEUE
160                 ~SECURITYFS
161                 ~USER_NS
162                 ~UTS_NS
163                 ~VETH
164                 ~!GRKERNSEC_CHROOT_MOUNT
165                 ~!GRKERNSEC_CHROOT_DOUBLE
166                 ~!GRKERNSEC_CHROOT_PIVOT
167                 ~!GRKERNSEC_CHROOT_CHMOD
168                 ~!GRKERNSEC_CHROOT_CAPS"
169
170         kernel_is lt 4 7 && use lxc && CONFIG_CHECK+="
171                 ~DEVPTS_MULTIPLE_INSTANCES"
172
173         use macvtap && CONFIG_CHECK+="
174                 ~MACVTAP"
175
176         use virt-network && CONFIG_CHECK+="
177                 ~BRIDGE_EBT_MARK_T
178                 ~BRIDGE_NF_EBTABLES
179                 ~NETFILTER_ADVANCED
180                 ~NETFILTER_XT_CONNMARK
181                 ~NETFILTER_XT_MARK
182                 ~NETFILTER_XT_TARGET_CHECKSUM
183                 ~IP_NF_FILTER
184                 ~IP_NF_MANGLE
185                 ~IP_NF_NAT
186                 ~IP_NF_TARGET_MASQUERADE
187                 ~IP6_NF_FILTER
188                 ~IP6_NF_MANGLE
189                 ~IP6_NF_NAT"
190         # Bandwidth Limiting Support
191         use virt-network && CONFIG_CHECK+="
192                 ~BRIDGE_EBT_T_NAT
193                 ~IP_NF_TARGET_REJECT
194                 ~NET_ACT_POLICE
195                 ~NET_CLS_FW
196                 ~NET_CLS_U32
197                 ~NET_SCH_HTB
198                 ~NET_SCH_INGRESS
199                 ~NET_SCH_SFQ"
200
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 "
206         fi
207
208         ERROR_USER_NS="Optional depending on LXC configuration."
209
210         if [[ -n ${CONFIG_CHECK} ]]; then
211                 linux-info_pkg_setup
212         fi
213 }
214
215 src_prepare() {
216         touch "${S}/.mailmap"
217
218         default
219
220         if [[ ${PV} = *9999* ]]; then
221                 # Reinitialize submodules as this is required for gnulib's bootstrap
222                 git submodule init
223                 # git checkouts require bootstrapping to create the configure script.
224                 # Additionally the submodules must be cloned to the right locations
225                 # bug #377279
226                 ./bootstrap || die "bootstrap failed"
227                 (
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
232         fi
233
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"
238
239         eautoreconf
240 }
241
242 src_configure() {
243         local myeconfargs=(
244                 $(use_with apparmor)
245                 $(use_with apparmor apparmor-profiles)
246                 $(use_with audit)
247                 $(use_with caps capng)
248                 $(use_with dbus)
249                 $(use_with dtrace)
250                 $(use_with firewalld)
251                 $(use_with fuse)
252                 $(use_with glusterfs)
253                 $(use_with glusterfs storage-gluster)
254                 $(use_with iscsi storage-iscsi)
255                 $(use_with iscsi-direct storage-iscsi-direct)
256                 $(use_with libvirtd)
257                 $(use_with libssh)
258                 $(use_with lvm storage-lvm)
259                 $(use_with lvm storage-mpath)
260                 $(use_with lxc)
261                 $(use_with macvtap)
262                 $(use_enable nls)
263                 $(use_with numa numactl)
264                 $(use_with numa numad)
265                 $(use_with openvz)
266                 $(use_with parted storage-disk)
267                 $(use_with pcap libpcap)
268                 $(use_with phyp)
269                 $(use_with pm-utils )
270                 $(use_with policykit polkit)
271                 $(use_with qemu)
272                 $(use_with qemu yajl)
273                 $(use_with rbd storage-rbd)
274                 $(use_with sasl)
275                 $(use_with selinux)
276                 $(use_with udev)
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)
282
283                 --without-hal
284                 --without-netcf
285                 --without-sanlock
286
287                 --with-esx
288                 --with-init-script=systemd
289                 --with-qemu-group=$(usex caps qemu root)
290                 --with-qemu-user=$(usex caps qemu root)
291                 --with-remote
292                 --with-storage-fs
293                 --with-vmware
294
295                 --disable-static
296                 --disable-werror
297
298                 --localstatedir="$EPREFIX/var"
299                 --with-runstatedir="$EPREFIX/run"
300         )
301
302         if use virtualbox && has_version app-emulation/virtualbox-ose; then
303                 myeconfargs+=( --with-vbox=/usr/lib/virtualbox-ose/ )
304         else
305                 myeconfargs+=( $(use_with virtualbox vbox) )
306         fi
307
308         econf "${myeconfargs[@]}"
309
310         if [[ ${PV} = *9999* ]]; then
311                 # Restore gnulib's config.sub and config.guess
312                 # bug #377279
313                 (cd .gnulib && git reset --hard > /dev/null)
314         fi
315 }
316
317 src_test() {
318         cd "${BUILD_DIR}"
319
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)$##' \
325                 tests/Makefile
326
327         export VIR_TEST_DEBUG=1
328         HOME="${T}" emake check
329 }
330
331 src_install() {
332         emake DESTDIR="${D}" \
333                 SYSTEMD_UNIT_DIR="$(systemd_get_systemunitdir)" install
334
335         find "${D}" -name '*.la' -delete || die
336
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
340         rm -rf "${D}"/var
341         rm -rf "${D}"/run
342
343         newbashcomp "${S}/tools/bash-completion/vsh" virsh
344         bashcomp_alias virsh virt-admin
345
346         use libvirtd || return 0
347         # From here, only libvirtd-related instructions, be warned!
348
349         systemd_install_serviced \
350                 "${FILESDIR}"/libvirtd.service.conf libvirtd.service
351
352         systemd_newtmpfilesd "${FILESDIR}"/libvirtd.tmpfiles.conf libvirtd.conf
353
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
358
359         newconfd "${FILESDIR}/libvirtd.confd-r5" libvirtd
360         newconfd "${FILESDIR}/libvirt-guests.confd" libvirt-guests
361
362         DOC_CONTENTS=$(<"${FILESDIR}/README.gentoo-r2")
363         DISABLE_AUTOFORMATTING=true
364         readme.gentoo_create_doc
365 }
366
367 pkg_preinst() {
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
371         fi
372 }
373
374 pkg_postinst() {
375         if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then
376                 touch "${ROOT}"/etc/libvirt/qemu/networks/default.xml
377         fi
378
379         use libvirtd || return 0
380         # From here, only libvirtd-related instructions, be warned!
381
382         readme.gentoo_print_elog
383 }