openvswitch-2.7.0-r1.ebuild 4.3 KB

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