libvirt-2.5.0-r2.ebuild 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. inherit autotools eutils user linux-info systemd readme.gentoo-r1
  5. if [[ ${PV} = *9999* ]]; then
  6. inherit git-r3
  7. EGIT_REPO_URI="git://libvirt.org/libvirt.git"
  8. SRC_URI=""
  9. KEYWORDS=""
  10. SLOT="0"
  11. else
  12. # Versions with 4 numbers are stable updates:
  13. if [[ ${PV} =~ ^[0-9]+(\.[0-9]+){3} ]]; then
  14. SRC_URI="http://libvirt.org/sources/stable_updates/${P}.tar.xz"
  15. else
  16. SRC_URI="http://libvirt.org/sources/${P}.tar.xz"
  17. fi
  18. KEYWORDS="amd64 x86"
  19. SLOT="0/${PV}"
  20. fi
  21. DESCRIPTION="C toolkit to manipulate virtual machines"
  22. HOMEPAGE="http://www.libvirt.org/"
  23. LICENSE="LGPL-2.1"
  24. IUSE="
  25. apparmor audit +caps +dbus firewalld fuse glusterfs iscsi +libvirtd lvm
  26. libssh lxc +macvtap nfs nls numa openvz parted pcap phyp policykit
  27. +qemu rbd sasl selinux +udev uml +vepa virtualbox virt-network
  28. wireshark-plugins xen zeroconf zfs elibc_glibc
  29. "
  30. REQUIRED_USE="
  31. firewalld? ( virt-network )
  32. libvirtd? ( || ( lxc openvz qemu uml virtualbox xen ) )
  33. lxc? ( caps libvirtd )
  34. openvz? ( libvirtd )
  35. policykit? ( dbus )
  36. qemu? ( libvirtd )
  37. uml? ( libvirtd )
  38. vepa? ( macvtap )
  39. virt-network? ( libvirtd )
  40. virtualbox? ( libvirtd )
  41. xen? ( libvirtd )"
  42. # gettext.sh command is used by the libvirt command wrappers, and it's
  43. # non-optional, so put it into RDEPEND.
  44. # We can use both libnl:1.1 and libnl:3, but if you have both installed, the
  45. # package will use 3 by default. Since we don't have slot pinning in an API,
  46. # we must go with the most recent
  47. RDEPEND="
  48. app-misc/scrub
  49. dev-libs/libgcrypt:0
  50. dev-libs/libnl:3
  51. >=dev-libs/libxml2-2.7.6
  52. || ( >=net-analyzer/netcat6-1.0-r2 >=net-analyzer/openbsd-netcat-1.105-r1 )
  53. >=net-libs/gnutls-1.0.25:0=
  54. net-libs/libssh2
  55. >=net-misc/curl-7.18.0
  56. sys-apps/dmidecode
  57. >=sys-apps/util-linux-2.17
  58. sys-devel/gettext
  59. sys-libs/ncurses:0=
  60. sys-libs/readline:=
  61. apparmor? ( sys-libs/libapparmor )
  62. audit? ( sys-process/audit )
  63. caps? ( sys-libs/libcap-ng )
  64. dbus? ( sys-apps/dbus )
  65. elibc_glibc? ( sys-libs/glibc[rpc(+)] )
  66. firewalld? ( net-firewall/firewalld )
  67. fuse? ( >=sys-fs/fuse-2.8.6 )
  68. glusterfs? ( >=sys-cluster/glusterfs-3.4.1 )
  69. iscsi? ( sys-block/open-iscsi )
  70. libssh? ( net-libs/libssh )
  71. lvm? ( >=sys-fs/lvm2-2.02.48-r2[-device-mapper-only(-)] )
  72. nfs? ( net-fs/nfs-utils )
  73. numa? (
  74. >sys-process/numactl-2.0.2
  75. sys-process/numad
  76. )
  77. openvz? ( sys-kernel/openvz-sources:* )
  78. parted? (
  79. >=sys-block/parted-1.8[device-mapper]
  80. sys-fs/lvm2[-device-mapper-only(-)]
  81. )
  82. pcap? ( >=net-libs/libpcap-1.0.0 )
  83. policykit? ( >=sys-auth/polkit-0.9 )
  84. qemu? (
  85. >=app-emulation/qemu-0.13.0
  86. dev-libs/yajl
  87. )
  88. rbd? ( sys-cluster/ceph )
  89. sasl? ( dev-libs/cyrus-sasl )
  90. selinux? ( >=sys-libs/libselinux-2.0.85 )
  91. virt-network? (
  92. net-dns/dnsmasq[script]
  93. net-firewall/ebtables
  94. >=net-firewall/iptables-1.4.10[ipv6]
  95. net-misc/radvd
  96. sys-apps/iproute2[-minimal]
  97. )
  98. virtualbox? ( || ( app-emulation/virtualbox >=app-emulation/virtualbox-bin-2.2.0 ) )
  99. wireshark-plugins? ( net-analyzer/wireshark:= )
  100. xen? (
  101. app-emulation/xen
  102. app-emulation/xen-tools:=
  103. )
  104. udev? (
  105. virtual/udev
  106. >=x11-libs/libpciaccess-0.10.9
  107. )
  108. zeroconf? ( >=net-dns/avahi-0.6[dbus] )
  109. zfs? ( sys-fs/zfs )"
  110. DEPEND="${RDEPEND}
  111. app-text/xhtml1
  112. dev-lang/perl
  113. dev-libs/libxslt
  114. dev-perl/XML-XPath
  115. virtual/pkgconfig"
  116. PATCHES=(
  117. "${FILESDIR}"/${PN}-1.3.0-do_not_use_sysconf.patch
  118. "${FILESDIR}"/${PN}-1.2.16-fix_paths_in_libvirt-guests_sh.patch
  119. "${FILESDIR}"/${PN}-1.3.1-fix_paths_for_apparmor.patch
  120. "${FILESDIR}"/${PN}-1.3.4-glibc-2.23.patch
  121. )
  122. pkg_setup() {
  123. if use qemu; then
  124. enewgroup qemu 77
  125. enewuser qemu 77 -1 -1 "qemu,kvm"
  126. fi
  127. use policykit && enewgroup libvirt
  128. # Check kernel configuration:
  129. CONFIG_CHECK=""
  130. use fuse && CONFIG_CHECK+="
  131. ~FUSE_FS"
  132. use lvm && CONFIG_CHECK+="
  133. ~BLK_DEV_DM
  134. ~DM_MULTIPATH
  135. ~DM_SNAPSHOT"
  136. use lxc && CONFIG_CHECK+="
  137. ~BLK_CGROUP
  138. ~CGROUP_CPUACCT
  139. ~CGROUP_DEVICE
  140. ~CGROUP_FREEZER
  141. ~CGROUP_NET_PRIO
  142. ~CGROUP_PERF
  143. ~CGROUPS
  144. ~CGROUP_SCHED
  145. ~CPUSETS
  146. ~IPC_NS
  147. ~MACVLAN
  148. ~NAMESPACES
  149. ~NET_CLS_CGROUP
  150. ~NET_NS
  151. ~PID_NS
  152. ~POSIX_MQUEUE
  153. ~SECURITYFS
  154. ~USER_NS
  155. ~UTS_NS
  156. ~VETH
  157. ~!GRKERNSEC_CHROOT_MOUNT
  158. ~!GRKERNSEC_CHROOT_DOUBLE
  159. ~!GRKERNSEC_CHROOT_PIVOT
  160. ~!GRKERNSEC_CHROOT_CHMOD
  161. ~!GRKERNSEC_CHROOT_CAPS"
  162. kernel_is lt 4 7 && use lxc && CONFIG_CHECK+="
  163. ~DEVPTS_MULTIPLE_INSTANCES"
  164. use macvtap && CONFIG_CHECK+="
  165. ~MACVTAP"
  166. use virt-network && CONFIG_CHECK+="
  167. ~BRIDGE_EBT_MARK_T
  168. ~BRIDGE_NF_EBTABLES
  169. ~NETFILTER_ADVANCED
  170. ~NETFILTER_XT_CONNMARK
  171. ~NETFILTER_XT_MARK
  172. ~NETFILTER_XT_TARGET_CHECKSUM"
  173. # Bandwidth Limiting Support
  174. use virt-network && CONFIG_CHECK+="
  175. ~BRIDGE_EBT_T_NAT
  176. ~NET_ACT_POLICE
  177. ~NET_CLS_FW
  178. ~NET_CLS_U32
  179. ~NET_SCH_HTB
  180. ~NET_SCH_INGRESS
  181. ~NET_SCH_SFQ"
  182. # Handle specific kernel versions for different features
  183. kernel_is lt 3 6 && CONFIG_CHECK+=" ~CGROUP_MEM_RES_CTLR"
  184. if kernel_is ge 3 6; then
  185. CONFIG_CHECK+=" ~MEMCG ~MEMCG_SWAP "
  186. kernel_is lt 4 5 && CONFIG_CHECK+=" ~MEMCG_KMEM "
  187. fi
  188. ERROR_USER_NS="Optional depending on LXC configuration."
  189. if [[ -n ${CONFIG_CHECK} ]]; then
  190. linux-info_pkg_setup
  191. fi
  192. }
  193. src_prepare() {
  194. touch "${S}/.mailmap"
  195. default
  196. if [[ ${PV} = *9999* ]]; then
  197. # git checkouts require bootstrapping to create the configure script.
  198. # Additionally the submodules must be cloned to the right locations
  199. # bug #377279
  200. ./bootstrap || die "bootstrap failed"
  201. (
  202. git submodule status | sed 's/^[ +-]//;s/ .*//'
  203. git hash-object bootstrap.conf
  204. ) >.git-module-status
  205. fi
  206. # Tweak the init script:
  207. cp "${FILESDIR}/libvirtd.init-r16" "${S}/libvirtd.init" || die
  208. sed -e "s/USE_FLAG_FIREWALLD/$(usex firewalld 'need firewalld' '')/" \
  209. -e "s/USE_FLAG_AVAHI/$(usex zeroconf 'use avahi-daemon' '')/" \
  210. -e "s/USE_FLAG_ISCSI/$(usex iscsi 'use iscsid' '')/" \
  211. -e "s/USE_FLAG_RBD/$(usex rbd 'use ceph' '')/" \
  212. -i "${S}/libvirtd.init" || die "sed failed"
  213. eautoreconf
  214. }
  215. src_configure() {
  216. local myeconfargs=(
  217. $(use_with apparmor)
  218. $(use_with apparmor apparmor-profiles)
  219. $(use_with audit)
  220. $(use_with caps capng)
  221. $(use_with dbus)
  222. $(use_with firewalld)
  223. $(use_with fuse)
  224. $(use_with glusterfs)
  225. $(use_with glusterfs storage-gluster)
  226. $(use_with iscsi storage-iscsi)
  227. $(use_with libvirtd)
  228. $(use_with libssh)
  229. $(use_with lvm storage-lvm)
  230. $(use_with lvm storage-mpath)
  231. $(use_with lxc)
  232. $(use_with macvtap)
  233. $(use_enable nls)
  234. $(use_with numa numactl)
  235. $(use_with numa numad)
  236. $(use_with openvz)
  237. $(use_with parted storage-disk)
  238. $(use_with pcap libpcap)
  239. $(use_with phyp)
  240. $(use_with policykit polkit)
  241. $(use_with qemu)
  242. $(use_with qemu yajl)
  243. $(use_with rbd storage-rbd)
  244. $(use_with sasl)
  245. $(use_with selinux)
  246. $(use_with udev)
  247. $(use_with uml)
  248. $(use_with vepa virtualport)
  249. $(use_with virt-network network)
  250. $(use_with wireshark-plugins wireshark-dissector)
  251. $(use_with xen)
  252. $(use_with xen xen-inotify)
  253. $(use_with xen libxl)
  254. $(use_with zeroconf avahi)
  255. $(use_with zfs storage-zfs)
  256. --without-hal
  257. --without-netcf
  258. --without-sanlock
  259. --without-xenapi
  260. --with-esx
  261. --with-init-script=systemd
  262. --with-qemu-group=$(usex caps qemu root)
  263. --with-qemu-user=$(usex caps qemu root)
  264. --with-remote
  265. --with-storage-fs
  266. --with-vmware
  267. --disable-static
  268. --disable-werror
  269. --with-html-subdir=${PF}/html
  270. --localstatedir=/var
  271. )
  272. if use virtualbox && has_version app-emulation/virtualbox-ose; then
  273. myeconfargs+=( --with-vbox=/usr/lib/virtualbox-ose/ )
  274. else
  275. myeconfargs+=( $(use_with virtualbox vbox) )
  276. fi
  277. econf "${myeconfargs[@]}"
  278. if [[ ${PV} = *9999* ]]; then
  279. # Restore gnulib's config.sub and config.guess
  280. # bug #377279
  281. (cd .gnulib && git reset --hard > /dev/null)
  282. fi
  283. }
  284. src_test() {
  285. cd "${BUILD_DIR}"
  286. # remove problematic tests, bug #591416, bug #591418
  287. sed -i -e 's#commandtest$(EXEEXT) # #' \
  288. -e 's#virfirewalltest$(EXEEXT) # #' \
  289. -e 's#nwfilterebiptablestest$(EXEEXT) # #' \
  290. -e 's#nwfilterxml2firewalltest$(EXEEXT)$##' \
  291. tests/Makefile
  292. export VIR_TEST_DEBUG=1
  293. HOME="${T}" emake check || die "tests failed"
  294. }
  295. src_install() {
  296. emake DESTDIR="${D}" \
  297. SYSTEMD_UNIT_DIR="$(systemd_get_systemunitdir)" install
  298. find "${D}" -name '*.la' -delete || die
  299. # Remove bogus, empty directories. They are either not used, or
  300. # libvirtd is able to create them on demand
  301. rm -rf "${D}"/etc/sysconfig
  302. rm -rf "${D}"/var/cache
  303. rm -rf "${D}"/var/run
  304. rm -rf "${D}"/var/log
  305. use libvirtd || return 0
  306. # From here, only libvirtd-related instructions, be warned!
  307. systemd_install_serviced \
  308. "${FILESDIR}"/libvirtd.service.conf libvirtd.service
  309. systemd_newtmpfilesd "${FILESDIR}"/libvirtd.tmpfiles.conf libvirtd.conf
  310. newinitd "${S}/libvirtd.init" libvirtd || die
  311. newinitd "${FILESDIR}/libvirt-guests.init-r2" libvirt-guests || die
  312. newinitd "${FILESDIR}/virtlockd.init-r1" virtlockd || die
  313. newinitd "${FILESDIR}/virtlogd.init-r1" virtlogd || die
  314. newconfd "${FILESDIR}/libvirtd.confd-r5" libvirtd || die
  315. newconfd "${FILESDIR}/libvirt-guests.confd" libvirt-guests || die
  316. DOC_CONTENTS=$(<"${FILESDIR}/README.gentoo-r2")
  317. DISABLE_AUTOFORMATTING=true
  318. readme.gentoo_create_doc
  319. }
  320. pkg_preinst() {
  321. # we only ever want to generate this once
  322. if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then
  323. rm -rf "${D}"/etc/libvirt/qemu/networks/default.xml
  324. fi
  325. }
  326. pkg_postinst() {
  327. if [[ -e "${ROOT}"/etc/libvirt/qemu/networks/default.xml ]]; then
  328. touch "${ROOT}"/etc/libvirt/qemu/networks/default.xml
  329. fi
  330. use libvirtd || return 0
  331. # From here, only libvirtd-related instructions, be warned!
  332. FORCE_PRINT_ELOG=1 # remove for next version bump
  333. readme.gentoo_print_elog
  334. }