openvswitch-2.1.3.ebuild 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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.12 required for userspace modules"
  32. kernel_is lt 3 12 || die "Linux >= 2.6.32 and <= 3.12 required for userspace modules"
  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}/xcp-interface-reconfigure.patch"
  46. epatch "${FILESDIR}/kernel-3.12-support.patch"
  47. eautoreconf
  48. }
  49. src_configure() {
  50. set_arch_to_kernel
  51. use monitor || export ovs_cv_python="no"
  52. #pyside is staticly disabled
  53. export ovs_cv_pyuic4="no"
  54. local linux_config
  55. use modules && linux_config="--with-linux=${KV_OUT_DIR}"
  56. econf ${linux_config} \
  57. --with-rundir=/var/run/openvswitch \
  58. --with-logdir=/var/log/openvswitch \
  59. --with-pkidir=/etc/ssl/openvswitch \
  60. --with-dbdir=/var/lib/openvswitch \
  61. $(use_enable ssl) \
  62. $(use_enable !debug ndebug)
  63. }
  64. src_compile() {
  65. default
  66. use monitor && python_fix_shebang \
  67. utilities/ovs-{pcap,tcpundump,test,vlan-test} \
  68. utilities/bugtool/ovs-bugtool
  69. use modules && linux-mod_src_compile
  70. }
  71. src_install() {
  72. default
  73. if use monitor ; then
  74. python_domodule "${ED}"/usr/share/openvswitch/python/*
  75. rm -r "${ED}/usr/share/openvswitch/python"
  76. python_optimize "${ED}/usr/share/ovsdbmonitor"
  77. fi
  78. # not working without the brcompat_mod kernel module which did not get
  79. # included in the kernel and we can't build it anymore
  80. rm "${D}/usr/sbin/ovs-brcompatd" "${D}/usr/share/man/man8/ovs-brcompatd.8"
  81. keepdir /var/{lib,log}/openvswitch
  82. keepdir /etc/ssl/openvswitch
  83. fperms 0750 /etc/ssl/openvswitch
  84. rm -rf "${ED}/var/run"
  85. use monitor || rmdir "${ED}/usr/share/ovsdbmonitor"
  86. use debug || rm "${ED}/usr/bin/ovs-parse-leaks"
  87. newconfd "${FILESDIR}/ovsdb-server_conf2" ovsdb-server
  88. newconfd "${FILESDIR}/ovs-vswitchd_conf" ovs-vswitchd
  89. newinitd "${FILESDIR}/ovsdb-server-r1" ovsdb-server
  90. newinitd "${FILESDIR}/ovs-vswitchd-r1" ovs-vswitchd
  91. systemd_dounit "${FILESDIR}/ovsdb-server.service"
  92. systemd_dounit "${FILESDIR}/ovs-vswitchd.service"
  93. systemd_newtmpfilesd "${FILESDIR}/openvswitch.tmpfiles" openvswitch.conf
  94. insinto /etc/logrotate.d
  95. newins rhel/etc_logrotate.d_openvswitch openvswitch
  96. use modules && linux-mod_src_install
  97. }
  98. pkg_postinst() {
  99. use modules && linux-mod_pkg_postinst
  100. for pv in ${REPLACING_VERSIONS}; do
  101. if ! version_is_at_least 1.9.0 ${pv} ; then
  102. ewarn "The configuration database for Open vSwitch got moved in version 1.9.0 from"
  103. ewarn " /etc/openvswitch"
  104. ewarn "to"
  105. ewarn " /var/lib/openvswitch"
  106. ewarn "Please copy/move the database manually before running the schema upgrade."
  107. ewarn "The PKI files are now supposed to go to /etc/ssl/openvswitch"
  108. fi
  109. done
  110. elog "Use the following command to create an initial database for ovsdb-server:"
  111. elog " emerge --config =${CATEGORY}/${PF}"
  112. elog "(will create a database in /var/lib/openvswitch/conf.db)"
  113. elog "or to convert the database to the current schema after upgrading."
  114. }
  115. pkg_config() {
  116. local db="${EPREFIX}/var/lib/openvswitch/conf.db"
  117. if [ -e "${db}" ] ; then
  118. einfo "Database '${db}' already exists, doing schema migration..."
  119. einfo "(if the migration fails, make sure that ovsdb-server is not running)"
  120. "${EPREFIX}/usr/bin/ovsdb-tool" convert "${db}" "${EPREFIX}/usr/share/openvswitch/vswitch.ovsschema" || die "converting database failed"
  121. else
  122. einfo "Creating new database '${db}'..."
  123. "${EPREFIX}/usr/bin/ovsdb-tool" create "${db}" "${EPREFIX}/usr/share/openvswitch/vswitch.ovsschema" || die "creating database failed"
  124. fi
  125. }