openvswitch-2.7.0.ebuild 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. PYTHON_COMPAT=( python{2_7,3_4,3_5} )
  5. inherit autotools eutils linux-info linux-mod python-r1 systemd
  6. DESCRIPTION="Production quality, multilayer virtual switch"
  7. HOMEPAGE="http://openvswitch.org"
  8. SRC_URI="http://openvswitch.org/releases/${P}.tar.gz"
  9. LICENSE="Apache-2.0 GPL-2"
  10. SLOT="0"
  11. KEYWORDS="amd64 ~arm64 x86"
  12. IUSE="debug modules monitor +ssl"
  13. RDEPEND="
  14. || (
  15. >=sys-apps/openrc-0.10.5
  16. sys-apps/systemd
  17. )
  18. ssl? ( dev-libs/openssl:0= )
  19. ${PYTHON_DEPS}
  20. ~dev-python/ovs-${PV}[${PYTHON_USEDEP}]
  21. dev-python/twisted-core
  22. dev-python/twisted-conch
  23. dev-python/twisted-web
  24. dev-python/zope-interface[${PYTHON_USEDEP}]
  25. debug? ( dev-lang/perl )"
  26. DEPEND="${RDEPEND}
  27. virtual/pkgconfig"
  28. PATCHES="${FILESDIR}/xcp-interface-reconfigure-2.3.2.patch"
  29. CONFIG_CHECK="~NET_CLS_ACT ~NET_CLS_U32 ~NET_SCH_INGRESS ~NET_ACT_POLICE ~IPV6 ~TUN"
  30. MODULE_NAMES="openvswitch(net:${S}/datapath/linux)"
  31. BUILD_TARGETS="all"
  32. pkg_setup() {
  33. if use modules ; then
  34. CONFIG_CHECK+=" ~!OPENVSWITCH"
  35. kernel_is ge 3 10 0 || die "Linux >= 3.10.0 and <= 4.8 required for userspace modules"
  36. kernel_is le 4 9 999 || die "Linux >= 3.10.0 and <= 4.8 required for userspace modules"
  37. linux-mod_pkg_setup
  38. else
  39. CONFIG_CHECK+=" ~OPENVSWITCH"
  40. linux-info_pkg_setup
  41. fi
  42. }
  43. src_prepare() {
  44. # Never build kernelmodules, doing this manually
  45. sed -i \
  46. -e '/^SUBDIRS/d' \
  47. datapath/Makefile.in || die "sed failed"
  48. eautoreconf
  49. default
  50. }
  51. src_configure() {
  52. set_arch_to_kernel
  53. # monitor is statically enabled for bug 596206
  54. use monitor || export ovs_cv_python="no"
  55. # pyside is staticly disabled
  56. export ovs_cv_pyuic4="no"
  57. local linux_config
  58. use modules && linux_config="--with-linux=${KV_OUT_DIR}"
  59. econf ${linux_config} \
  60. --with-rundir=/var/run/openvswitch \
  61. --with-logdir=/var/log/openvswitch \
  62. --with-pkidir=/etc/ssl/openvswitch \
  63. --with-dbdir=/var/lib/openvswitch \
  64. $(use_enable ssl) \
  65. $(use_enable !debug ndebug)
  66. }
  67. src_compile() {
  68. default
  69. use modules && linux-mod_src_compile
  70. }
  71. src_install() {
  72. default
  73. local SCRIPT
  74. if use monitor; then
  75. for SCRIPT in ovs-{pcap,parse-backtrace,dpctl-top,l3ping,tcpdump,tcpundump,test,vlan-test} bugtool/ovs-bugtool; do
  76. sed -e '1s|^.*$|#!/usr/bin/python|' -i utilities/"${SCRIPT}"
  77. python_foreach_impl python_doscript utilities/"${SCRIPT}"
  78. done
  79. rm -r "${ED%/}"/usr/share/openvswitch/python || die
  80. fi
  81. keepdir /var/{lib,log}/openvswitch
  82. keepdir /etc/ssl/openvswitch
  83. fperms 0750 /etc/ssl/openvswitch
  84. rm -rf "${ED%/}"/var/run || die
  85. newconfd "${FILESDIR}/ovsdb-server_conf2" ovsdb-server
  86. newconfd "${FILESDIR}/ovs-vswitchd_conf" ovs-vswitchd
  87. newinitd "${FILESDIR}/ovsdb-server-r1" ovsdb-server
  88. newinitd "${FILESDIR}/ovs-vswitchd-r1" ovs-vswitchd
  89. systemd_dounit "${FILESDIR}/ovsdb-server.service"
  90. systemd_dounit "${FILESDIR}/ovs-vswitchd.service"
  91. systemd_newtmpfilesd "${FILESDIR}/openvswitch.tmpfiles" openvswitch.conf
  92. insinto /etc/logrotate.d
  93. newins rhel/etc_logrotate.d_openvswitch openvswitch
  94. use modules && linux-mod_src_install
  95. }
  96. pkg_postinst() {
  97. use modules && linux-mod_pkg_postinst
  98. local pv
  99. for pv in ${REPLACING_VERSIONS}; do
  100. if ! version_is_at_least 1.9.0 ${pv} ; then
  101. ewarn "The configuration database for Open vSwitch got moved in version 1.9.0 from"
  102. ewarn " /etc/openvswitch"
  103. ewarn "to"
  104. ewarn " /var/lib/openvswitch"
  105. ewarn "Please copy/move the database manually before running the schema upgrade."
  106. ewarn "The PKI files are now supposed to go to /etc/ssl/openvswitch"
  107. fi
  108. done
  109. elog "Use the following command to create an initial database for ovsdb-server:"
  110. elog " emerge --config =${CATEGORY}/${PF}"
  111. elog "(will create a database in /var/lib/openvswitch/conf.db)"
  112. elog "or to convert the database to the current schema after upgrading."
  113. }
  114. pkg_config() {
  115. local db="${EROOT%/}"/var/lib/openvswitch/conf.db
  116. if [[ -e "${db}" ]] ; then
  117. einfo "Database '${db}' already exists, doing schema migration..."
  118. einfo "(if the migration fails, make sure that ovsdb-server is not running)"
  119. ovsdb-tool convert "${db}" \
  120. "${EROOT%/}"/usr/share/openvswitch/vswitch.ovsschema || die "converting database failed"
  121. else
  122. einfo "Creating new database '${db}'..."
  123. ovsdb-tool create "${db}" \
  124. "${EROOT%/}"/usr/share/openvswitch/vswitch.ovsschema || die "creating database failed"
  125. fi
  126. }