openvswitch-2.6.1.ebuild 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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}
  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 7 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 ist 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. for SCRIPT in ovs-{pcap,parse-backtrace,dpctl-top,l3ping,tcpundump,test,vlan-test} bugtool/ovs-bugtool; do
  75. sed -e '1s|^.*$|#!/usr/bin/python|' -i utilities/"${SCRIPT}" || die
  76. python_foreach_impl python_doscript utilities/"${SCRIPT}"
  77. done
  78. python_foreach_impl python_optimize "${ED%/}"/usr/share/ovsdbmonitor
  79. rm -r "${ED%/}"/usr/share/openvswitch/python || die
  80. keepdir /var/{lib,log}/openvswitch
  81. keepdir /etc/ssl/openvswitch
  82. fperms 0750 /etc/ssl/openvswitch
  83. rm -rf "${ED%/}"/var/run || die
  84. # monitor is statically enabled for bug 596206
  85. #if ! use monitor ; then
  86. # rm -r "${ED%/}"/usr/share/ovsdbmonitor || die
  87. #fi
  88. newconfd "${FILESDIR}/ovsdb-server_conf2" ovsdb-server
  89. newconfd "${FILESDIR}/ovs-vswitchd_conf" ovs-vswitchd
  90. newinitd "${FILESDIR}/ovsdb-server-r1" ovsdb-server
  91. newinitd "${FILESDIR}/ovs-vswitchd-r1" ovs-vswitchd
  92. systemd_dounit "${FILESDIR}/ovsdb-server.service"
  93. systemd_dounit "${FILESDIR}/ovs-vswitchd.service"
  94. systemd_newtmpfilesd "${FILESDIR}/openvswitch.tmpfiles" openvswitch.conf
  95. insinto /etc/logrotate.d
  96. newins rhel/etc_logrotate.d_openvswitch openvswitch
  97. use modules && linux-mod_src_install
  98. }
  99. pkg_postinst() {
  100. use modules && linux-mod_pkg_postinst
  101. local pv
  102. for pv in ${REPLACING_VERSIONS}; do
  103. if ! version_is_at_least 1.9.0 ${pv} ; then
  104. ewarn "The configuration database for Open vSwitch got moved in version 1.9.0 from"
  105. ewarn " /etc/openvswitch"
  106. ewarn "to"
  107. ewarn " /var/lib/openvswitch"
  108. ewarn "Please copy/move the database manually before running the schema upgrade."
  109. ewarn "The PKI files are now supposed to go to /etc/ssl/openvswitch"
  110. fi
  111. done
  112. elog "Use the following command to create an initial database for ovsdb-server:"
  113. elog " emerge --config =${CATEGORY}/${PF}"
  114. elog "(will create a database in /var/lib/openvswitch/conf.db)"
  115. elog "or to convert the database to the current schema after upgrading."
  116. }
  117. pkg_config() {
  118. local db="${EROOT%/}"/var/lib/openvswitch/conf.db
  119. if [[ -e "${db}" ]] ; then
  120. einfo "Database '${db}' already exists, doing schema migration..."
  121. einfo "(if the migration fails, make sure that ovsdb-server is not running)"
  122. ovsdb-tool convert "${db}" \
  123. "${EROOT%/}"/usr/share/openvswitch/vswitch.ovsschema || die "converting database failed"
  124. else
  125. einfo "Creating new database '${db}'..."
  126. ovsdb-tool create "${db}" \
  127. "${EROOT%/}"/usr/share/openvswitch/vswitch.ovsschema || die "creating database failed"
  128. fi
  129. }