libvirt-2.1.0-r2.ebuild 9.5 KB

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