libvirt-1.3.5-r2.ebuild 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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
  5. BACKPORTS="20160709" # CVE-2016-5008
  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.gz"
  16. else
  17. SRC_URI="http://libvirt.org/sources/${P}.tar.gz"
  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="apparmor audit avahi +caps firewalld fuse glusterfs iscsi +libvirtd lvm \
  29. lxc +macvtap nfs nls numa openvz parted pcap phyp policykit +qemu rbd sasl \
  30. selinux systemd +udev uml +vepa virtualbox virt-network wireshark-plugins \
  31. xen elibc_glibc"
  32. REQUIRED_USE="
  33. firewalld? ( virt-network )
  34. libvirtd? ( || ( lxc openvz qemu uml virtualbox xen ) )
  35. lxc? ( caps libvirtd )
  36. openvz? ( libvirtd )
  37. qemu? ( libvirtd )
  38. uml? ( libvirtd )
  39. vepa? ( macvtap )
  40. virt-network? ( libvirtd )
  41. virtualbox? ( libvirtd )
  42. xen? ( libvirtd )"
  43. # gettext.sh command is used by the libvirt command wrappers, and it's
  44. # non-optional, so put it into RDEPEND.
  45. # We can use both libnl:1.1 and libnl:3, but if you have both installed, the
  46. # package will use 3 by default. Since we don't have slot pinning in an API,
  47. # we must go with the most recent
  48. RDEPEND="
  49. app-misc/scrub
  50. dev-libs/libgcrypt:0
  51. dev-libs/libnl:3
  52. >=dev-libs/libxml2-2.7.6
  53. || ( >=net-analyzer/netcat6-1.0-r2 >=net-analyzer/openbsd-netcat-1.105-r1 )
  54. >=net-libs/gnutls-1.0.25:0=
  55. net-libs/libssh2
  56. >=net-misc/curl-7.18.0
  57. sys-apps/dmidecode
  58. >=sys-apps/util-linux-2.17
  59. sys-devel/gettext
  60. sys-libs/ncurses:0=
  61. sys-libs/readline:=
  62. apparmor? ( sys-libs/libapparmor )
  63. audit? ( sys-process/audit )
  64. avahi? ( >=net-dns/avahi-0.6[dbus] )
  65. caps? ( sys-libs/libcap-ng )
  66. elibc_glibc? ( sys-libs/glibc[rpc(+)] )
  67. firewalld? ( net-firewall/firewalld )
  68. fuse? ( >=sys-fs/fuse-2.8.6 )
  69. glusterfs? ( >=sys-cluster/glusterfs-3.4.1 )
  70. iscsi? ( sys-block/open-iscsi )
  71. lvm? ( >=sys-fs/lvm2-2.02.48-r2[-device-mapper-only(-)] )
  72. lxc? ( !systemd? ( sys-power/pm-utils ) )
  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. !systemd? ( sys-power/pm-utils )
  89. )
  90. rbd? ( sys-cluster/ceph )
  91. sasl? ( dev-libs/cyrus-sasl )
  92. selinux? ( >=sys-libs/libselinux-2.0.85 )
  93. systemd? ( sys-apps/systemd )
  94. virt-network? (
  95. net-dns/dnsmasq[script]
  96. net-firewall/ebtables
  97. >=net-firewall/iptables-1.4.10[ipv6]
  98. net-misc/radvd
  99. sys-apps/iproute2[-minimal]
  100. )
  101. virtualbox? ( || ( app-emulation/virtualbox >=app-emulation/virtualbox-bin-2.2.0 ) )
  102. wireshark-plugins? ( net-analyzer/wireshark:= )
  103. xen? (
  104. app-emulation/xen
  105. app-emulation/xen-tools:=
  106. )
  107. udev? (
  108. virtual/udev
  109. >=x11-libs/libpciaccess-0.10.9
  110. )"
  111. DEPEND="${RDEPEND}
  112. app-text/xhtml1
  113. dev-lang/perl
  114. dev-libs/libxslt
  115. dev-perl/XML-XPath
  116. virtual/pkgconfig"
  117. pkg_setup() {
  118. if use qemu; then
  119. enewgroup qemu 77
  120. enewuser qemu 77 -1 -1 "qemu,kvm"
  121. fi
  122. # Check kernel configuration:
  123. CONFIG_CHECK=""
  124. use fuse && CONFIG_CHECK+="
  125. ~FUSE_FS"
  126. use lvm && CONFIG_CHECK+="
  127. ~BLK_DEV_DM
  128. ~DM_MULTIPATH
  129. ~DM_SNAPSHOT"
  130. use lxc && CONFIG_CHECK+="
  131. ~BLK_CGROUP
  132. ~CGROUP_CPUACCT
  133. ~CGROUP_DEVICE
  134. ~CGROUP_FREEZER
  135. ~CGROUP_NET_PRIO
  136. ~CGROUP_PERF
  137. ~CGROUPS
  138. ~CGROUP_SCHED
  139. ~CPUSETS
  140. ~DEVPTS_MULTIPLE_INSTANCES
  141. ~IPC_NS
  142. ~MACVLAN
  143. ~NAMESPACES
  144. ~NET_CLS_CGROUP
  145. ~NET_NS
  146. ~PID_NS
  147. ~POSIX_MQUEUE
  148. ~SECURITYFS
  149. ~USER_NS
  150. ~UTS_NS
  151. ~VETH
  152. ~!GRKERNSEC_CHROOT_MOUNT
  153. ~!GRKERNSEC_CHROOT_DOUBLE
  154. ~!GRKERNSEC_CHROOT_PIVOT
  155. ~!GRKERNSEC_CHROOT_CHMOD
  156. ~!GRKERNSEC_CHROOT_CAPS"
  157. # Handle specific kernel versions for different features
  158. kernel_is lt 3 6 && CONFIG_CHECK+=" ~CGROUP_MEM_RES_CTLR"
  159. if $(kernel_is ge 3 6); then
  160. CONFIG_CHECK+=" ~MEMCG ~MEMCG_SWAP "
  161. if $(kernel_is lt 4 5); then
  162. CONFIG_CHECK+=" ~MEMCG_KMEM "
  163. fi
  164. fi
  165. use macvtap && CONFIG_CHECK+="
  166. ~MACVTAP"
  167. use virt-network && CONFIG_CHECK+="
  168. ~BRIDGE_EBT_MARK_T
  169. ~BRIDGE_NF_EBTABLES
  170. ~NETFILTER_ADVANCED
  171. ~NETFILTER_XT_CONNMARK
  172. ~NETFILTER_XT_MARK
  173. ~NETFILTER_XT_TARGET_CHECKSUM"
  174. # Bandwidth Limiting Support
  175. use virt-network && CONFIG_CHECK+="
  176. ~BRIDGE_EBT_T_NAT
  177. ~NET_ACT_POLICE
  178. ~NET_CLS_FW
  179. ~NET_CLS_U32
  180. ~NET_SCH_HTB
  181. ~NET_SCH_INGRESS
  182. ~NET_SCH_SFQ"
  183. ERROR_USER_NS="Optional depending on LXC configuration."
  184. if [[ -n ${CONFIG_CHECK} ]]; then
  185. linux-info_pkg_setup
  186. fi
  187. }
  188. src_prepare() {
  189. touch "${S}/.mailmap"
  190. if [[ ${PV} = *9999* ]]; then
  191. # git checkouts require bootstrapping to create the configure script.
  192. # Additionally the submodules must be cloned to the right locations
  193. # bug #377279
  194. ./bootstrap || die "bootstrap failed"
  195. (
  196. git submodule status | sed 's/^[ +-]//;s/ .*//'
  197. git hash-object bootstrap.conf
  198. ) >.git-module-status
  199. fi
  200. epatch \
  201. "${FILESDIR}"/${PN}-1.3.0-do_not_use_sysconf.patch \
  202. "${FILESDIR}"/${PN}-1.2.16-fix_paths_in_libvirt-guests_sh.patch \
  203. "${FILESDIR}"/${PN}-1.3.1-fix_paths_for_apparmor.patch \
  204. "${FILESDIR}"/${PN}-1.2.21-avoid_deprecated_pc_file.patch \
  205. "${FILESDIR}"/${PN}-1.3.4-glibc-2.23.patch
  206. [[ -n ${BACKPORTS} ]] &&
  207. EPATCH_FORCE=yes EPATCH_SUFFIX="patch" \
  208. EPATCH_SOURCE="${WORKDIR}/patches" epatch
  209. epatch_user
  210. # Tweak the init script:
  211. cp "${FILESDIR}/libvirtd.init-r16" "${S}/libvirtd.init" || die
  212. sed -e "s/USE_FLAG_FIREWALLD/$(usex firewalld 'need firewalld' '')/" \
  213. -e "s/USE_FLAG_AVAHI/$(usex avahi 'use avahi-daemon' '')/" \
  214. -e "s/USE_FLAG_ISCSI/$(usex iscsi 'use iscsid' '')/" \
  215. -e "s/USE_FLAG_RBD/$(usex rbd 'use ceph' '')/" \
  216. -i "${S}/libvirtd.init" || die "sed failed"
  217. AUTOTOOLS_AUTORECONF=true
  218. autotools-utils_src_prepare
  219. }
  220. src_configure() {
  221. local myeconfargs=(
  222. $(use_with apparmor)
  223. $(use_with apparmor apparmor-profiles)
  224. $(use_with audit)
  225. $(use_with avahi)
  226. $(use_with caps capng)
  227. $(use_with firewalld)
  228. $(use_with fuse)
  229. $(use_with glusterfs)
  230. $(use_with glusterfs storage-gluster)
  231. $(use_with iscsi storage-iscsi)
  232. $(use_with libvirtd)
  233. $(use_with lvm storage-lvm)
  234. $(use_with lvm storage-mpath)
  235. $(use_with lxc)
  236. $(use_with macvtap)
  237. $(use_enable nls)
  238. $(use_with numa numactl)
  239. $(use_with numa numad)
  240. $(use_with openvz)
  241. $(use_with parted storage-disk)
  242. $(use_with pcap libpcap)
  243. $(use_with phyp)
  244. $(use_with policykit polkit)
  245. $(use_with qemu)
  246. $(use_with qemu yajl)
  247. $(use_with rbd storage-rbd)
  248. $(use_with sasl)
  249. $(use_with selinux)
  250. $(use_with systemd systemd-daemon)
  251. $(usex systemd --with-init-script=systemd '')
  252. $(use_with udev)
  253. $(use_with uml)
  254. $(use_with vepa virtualport)
  255. $(use_with virt-network network)
  256. $(use_with wireshark-plugins wireshark-dissector)
  257. $(use_with xen)
  258. $(use_with xen xen-inotify)
  259. $(usex xen --with-libxl '')
  260. --without-hal
  261. --without-netcf
  262. --without-sanlock
  263. --without-xenapi
  264. --with-esx
  265. --with-qemu-group=$(usex caps qemu root)
  266. --with-qemu-user=$(usex caps qemu root)
  267. --with-remote
  268. --with-storage-fs
  269. --with-vmware
  270. --disable-static
  271. --disable-werror
  272. --with-html-subdir=${PF}/html
  273. --localstatedir=/var
  274. )
  275. if use virtualbox && has_version app-emulation/virtualbox-ose; then
  276. myeconfargs+=( --with-vbox=/usr/lib/virtualbox-ose/ )
  277. else
  278. myeconfargs+=( $(use_with virtualbox vbox) )
  279. fi
  280. autotools-utils_src_configure
  281. if [[ ${PV} = *9999* ]]; then
  282. # Restore gnulib's config.sub and config.guess
  283. # bug #377279
  284. (cd .gnulib && git reset --hard > /dev/null)
  285. fi
  286. # Workaround: Sometimes this subdirectory is missing and leads to a
  287. # build failure.
  288. mkdir -p "${BUILD_DIR}"/docs/internals
  289. }
  290. src_test() {
  291. # Explicitly allow parallel build of tests
  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. use systemd && 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. }