openvswitch-2.5.0.ebuild 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. PYTHON_COMPAT=( python2_7 )
  5. inherit eutils linux-info linux-mod python-single-r1 systemd autotools
  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 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:= )
  19. monitor? (
  20. ${PYTHON_DEPS}
  21. dev-python/twisted-core
  22. dev-python/twisted-conch
  23. dev-python/twisted-web
  24. dev-python/PyQt4[${PYTHON_USEDEP}]
  25. dev-python/zope-interface[${PYTHON_USEDEP}] )
  26. debug? ( dev-lang/perl )"
  27. DEPEND="${RDEPEND}
  28. virtual/pkgconfig"
  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 2 6 32 || die "Linux >= 2.6.32 and <= 4.3 required for userspace modules"
  36. kernel_is le 4 3 999 || die "Linux >= 2.6.32 and <= 4.3 required for userspace modules"
  37. linux-mod_pkg_setup
  38. else
  39. CONFIG_CHECK+=" ~OPENVSWITCH"
  40. linux-info_pkg_setup
  41. fi
  42. use monitor && python-single-r1_pkg_setup
  43. }
  44. src_prepare() {
  45. # Never build kernelmodules, doing this manually
  46. sed -i \
  47. -e '/^SUBDIRS/d' \
  48. datapath/Makefile.in || die "sed failed"
  49. epatch "${FILESDIR}/xcp-interface-reconfigure-2.3.2.patch"
  50. eautoreconf
  51. }
  52. src_configure() {
  53. set_arch_to_kernel
  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. PYTHON=python2.7 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 monitor && python_fix_shebang \
  70. # utilities/ovs-{pcap,tcpundump,test,vlan-test} \
  71. # utilities/bugtool/ovs-bugtool
  72. if use monitor; then
  73. sed -i \
  74. 's/^#\!\ python2\.7/#\!\/usr\/bin\/env\ python2\.7/' \
  75. utilities/ovs-{pcap,parse-backtrace,dpctl-top,l3ping,tcpundump,test,vlan-test} \
  76. utilities/bugtool/ovs-bugtool || die "sed died :("
  77. fi
  78. use modules && linux-mod_src_compile
  79. }
  80. src_install() {
  81. default
  82. if use monitor ; then
  83. python_domodule "${ED}"/usr/share/openvswitch/python/*
  84. rm -r "${ED}/usr/share/openvswitch/python"
  85. python_optimize "${ED}/usr/share/ovsdbmonitor"
  86. fi
  87. # not working without the brcompat_mod kernel module which did not get
  88. # included in the kernel and we can't build it anymore
  89. rm "${D}/usr/sbin/ovs-brcompatd" "${D}/usr/share/man/man8/ovs-brcompatd.8"
  90. keepdir /var/{lib,log}/openvswitch
  91. keepdir /etc/ssl/openvswitch
  92. fperms 0750 /etc/ssl/openvswitch
  93. rm -rf "${ED}/var/run"
  94. use monitor || rmdir "${ED}/usr/share/ovsdbmonitor"
  95. use debug || rm "${ED}/usr/bin/ovs-parse-leaks"
  96. newconfd "${FILESDIR}/ovsdb-server_conf2" ovsdb-server
  97. newconfd "${FILESDIR}/ovs-vswitchd_conf" ovs-vswitchd
  98. newinitd "${FILESDIR}/ovsdb-server-r1" ovsdb-server
  99. newinitd "${FILESDIR}/ovs-vswitchd-r1" ovs-vswitchd
  100. systemd_dounit "${FILESDIR}/ovsdb-server.service"
  101. systemd_dounit "${FILESDIR}/ovs-vswitchd.service"
  102. systemd_newtmpfilesd "${FILESDIR}/openvswitch.tmpfiles" openvswitch.conf
  103. insinto /etc/logrotate.d
  104. newins rhel/etc_logrotate.d_openvswitch openvswitch
  105. use modules && linux-mod_src_install
  106. }
  107. pkg_postinst() {
  108. use modules && linux-mod_pkg_postinst
  109. for pv in ${REPLACING_VERSIONS}; do
  110. if ! version_is_at_least 1.9.0 ${pv} ; then
  111. ewarn "The configuration database for Open vSwitch got moved in version 1.9.0 from"
  112. ewarn " /etc/openvswitch"
  113. ewarn "to"
  114. ewarn " /var/lib/openvswitch"
  115. ewarn "Please copy/move the database manually before running the schema upgrade."
  116. ewarn "The PKI files are now supposed to go to /etc/ssl/openvswitch"
  117. fi
  118. done
  119. elog "Use the following command to create an initial database for ovsdb-server:"
  120. elog " emerge --config =${CATEGORY}/${PF}"
  121. elog "(will create a database in /var/lib/openvswitch/conf.db)"
  122. elog "or to convert the database to the current schema after upgrading."
  123. }
  124. pkg_config() {
  125. local db="${EPREFIX}/var/lib/openvswitch/conf.db"
  126. if [ -e "${db}" ] ; then
  127. einfo "Database '${db}' already exists, doing schema migration..."
  128. einfo "(if the migration fails, make sure that ovsdb-server is not running)"
  129. "${EPREFIX}/usr/bin/ovsdb-tool" convert "${db}" "${EPREFIX}/usr/share/openvswitch/vswitch.ovsschema" || die "converting database failed"
  130. else
  131. einfo "Creating new database '${db}'..."
  132. "${EPREFIX}/usr/bin/ovsdb-tool" create "${db}" "${EPREFIX}/usr/share/openvswitch/vswitch.ovsschema" || die "creating database failed"
  133. fi
  134. }