openvswitch-2.0.0-r3.ebuild 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. # Copyright 1999-2014 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=">=sys-apps/openrc-0.10.5
  14. ssl? ( dev-libs/openssl )
  15. monitor? (
  16. ${PYTHON_DEPS}
  17. dev-python/twisted-core
  18. dev-python/twisted-conch
  19. dev-python/twisted-web
  20. dev-python/PyQt4[${PYTHON_USEDEP}]
  21. dev-python/zope-interface[${PYTHON_USEDEP}] )
  22. debug? ( dev-lang/perl )"
  23. DEPEND="${RDEPEND}
  24. virtual/pkgconfig"
  25. CONFIG_CHECK="~NET_CLS_ACT ~NET_CLS_U32 ~NET_SCH_INGRESS ~NET_ACT_POLICE ~IPV6 ~TUN"
  26. MODULE_NAMES="openvswitch(net:${S}/datapath/linux)"
  27. BUILD_TARGETS="all"
  28. pkg_setup() {
  29. if use modules ; then
  30. CONFIG_CHECK+=" ~!OPENVSWITCH"
  31. kernel_is ge 2 6 32 || die "Linux >=2.6.32 and <3.10 required"
  32. kernel_is lt 3 14 || die "Linux >=2.6.18 and <3.14 required"
  33. linux-mod_pkg_setup
  34. else
  35. CONFIG_CHECK+=" ~OPENVSWITCH"
  36. linux-info_pkg_setup
  37. fi
  38. use monitor && python-single-r1_pkg_setup
  39. }
  40. src_prepare() {
  41. # Never build kernelmodules, doing this manually
  42. sed -i \
  43. -e '/^SUBDIRS/d' \
  44. datapath/Makefile.in || die "sed failed"
  45. epatch "${FILESDIR}/prevent-traceback.patch"
  46. epatch "${FILESDIR}/kernel-3.11-support.patch"
  47. epatch "${FILESDIR}/xcp-interface-reconfigure.patch"
  48. # epatch "${FILESDIR}/atomic-test.patch"
  49. epatch "${FILESDIR}/kernel-3.12-support.patch"
  50. epatch "${FILESDIR}/configure.patch"
  51. eautoreconf
  52. }
  53. src_configure() {
  54. set_arch_to_kernel
  55. use monitor || export ovs_cv_python="no"
  56. #pyside is staticly disabled
  57. export ovs_cv_pyuic4="no"
  58. local linux_config
  59. use modules && linux_config="--with-linux=${KV_OUT_DIR}"
  60. econf ${linux_config} \
  61. --with-rundir=/var/run/openvswitch \
  62. --with-logdir=/var/log/openvswitch \
  63. --with-pkidir=/etc/ssl/openvswitch \
  64. --with-dbdir=/var/lib/openvswitch \
  65. $(use_enable ssl) \
  66. $(use_enable !debug ndebug)
  67. }
  68. src_compile() {
  69. default
  70. use monitor && python_fix_shebang \
  71. utilities/ovs-{pcap,tcpundump,test,vlan-test} \
  72. utilities/bugtool/ovs-bugtool \
  73. ovsdb/ovsdbmonitor/ovsdbmonitor
  74. use modules && linux-mod_src_compile
  75. }
  76. src_install() {
  77. default
  78. if use monitor ; then
  79. python_domodule "${ED}"/usr/share/openvswitch/python/*
  80. rm -r "${ED}/usr/share/openvswitch/python"
  81. python_optimize "${ED}/usr/share/ovsdbmonitor"
  82. fi
  83. # not working without the brcompat_mod kernel module which did not get
  84. # included in the kernel and we can't build it anymore
  85. rm "${D}/usr/sbin/ovs-brcompatd" "${D}/usr/share/man/man8/ovs-brcompatd.8"
  86. keepdir /var/{lib,log}/openvswitch
  87. keepdir /etc/ssl/openvswitch
  88. fperms 0750 /etc/ssl/openvswitch
  89. rm -rf "${ED}/var/run"
  90. use monitor || rmdir "${ED}/usr/share/ovsdbmonitor"
  91. use debug || rm "${ED}/usr/bin/ovs-parse-leaks"
  92. newconfd "${FILESDIR}/ovsdb-server_conf2" ovsdb-server
  93. newconfd "${FILESDIR}/ovs-vswitchd_conf" ovs-vswitchd
  94. newconfd "${FILESDIR}/ovs-controller_conf" ovs-controller
  95. newinitd "${FILESDIR}/ovsdb-server-r1" ovsdb-server
  96. newinitd "${FILESDIR}/ovs-vswitchd-r1" ovs-vswitchd
  97. newinitd "${FILESDIR}/ovs-controller-r1" ovs-controller
  98. systemd_dounit "${FILESDIR}/ovsdb-server.service"
  99. systemd_dounit "${FILESDIR}/ovs-vswitchd.service"
  100. systemd_dounit "${FILESDIR}/ovs-controller.service"
  101. systemd_newtmpfilesd "${FILESDIR}/openvswitch.tmpfiles" openvswitch.conf
  102. insinto /etc/logrotate.d
  103. newins rhel/etc_logrotate.d_openvswitch openvswitch
  104. use modules && linux-mod_src_install
  105. }
  106. pkg_postinst() {
  107. use modules && linux-mod_pkg_postinst
  108. for pv in ${REPLACING_VERSIONS}; do
  109. if ! version_is_at_least 1.9.0 ${pv} ; then
  110. ewarn "The configuration database for Open vSwitch got moved in version 1.9.0 from"
  111. ewarn " /etc/openvswitch"
  112. ewarn "to"
  113. ewarn " /var/lib/openvswitch"
  114. ewarn "Please copy/move the database manually before running the schema upgrade."
  115. ewarn "The PKI files are now supposed to go to /etc/ssl/openvswitch"
  116. fi
  117. done
  118. elog "Use the following command to create an initial database for ovsdb-server:"
  119. elog " emerge --config =${CATEGORY}/${PF}"
  120. elog "(will create a database in /var/lib/openvswitch/conf.db)"
  121. elog "or to convert the database to the current schema after upgrading."
  122. }
  123. pkg_config() {
  124. local db="${EPREFIX}/var/lib/openvswitch/conf.db"
  125. if [ -e "${db}" ] ; then
  126. einfo "Database '${db}' already exists, doing schema migration..."
  127. einfo "(if the migration fails, make sure that ovsdb-server is not running)"
  128. "${EPREFIX}/usr/bin/ovsdb-tool" convert "${db}" "${EPREFIX}/usr/share/openvswitch/vswitch.ovsschema" || die "converting database failed"
  129. else
  130. einfo "Creating new database '${db}'..."
  131. "${EPREFIX}/usr/bin/ovsdb-tool" create "${db}" "${EPREFIX}/usr/share/openvswitch/vswitch.ovsschema" || die "creating database failed"
  132. fi
  133. }