openvswitch-1.11.0.ebuild 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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
  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 +pyside +ssl"
  13. RDEPEND=">=sys-apps/openrc-0.10.5
  14. ssl? ( dev-libs/openssl )
  15. monitor? (
  16. ${PYTHON_DEPS}
  17. dev-python/twisted-core[${PYTHON_USEDEP}]
  18. dev-python/twisted-conch[${PYTHON_USEDEP}]
  19. dev-python/twisted-web[${PYTHON_USEDEP}]
  20. pyside? ( dev-python/pyside[${PYTHON_USEDEP}] )
  21. !pyside? ( dev-python/PyQt4[${PYTHON_USEDEP}] )
  22. dev-python/zope-interface[${PYTHON_USEDEP}] )
  23. debug? ( dev-lang/perl )"
  24. DEPEND="${RDEPEND}
  25. virtual/pkgconfig"
  26. CONFIG_CHECK="~NET_CLS_ACT ~NET_CLS_U32 ~NET_SCH_INGRESS ~NET_ACT_POLICE ~IPV6 ~TUN"
  27. MODULE_NAMES="openvswitch(net:${S}/datapath/linux)"
  28. BUILD_TARGETS="all"
  29. pkg_setup() {
  30. if use modules ; then
  31. CONFIG_CHECK+=" ~!OPENVSWITCH"
  32. linux-mod_pkg_setup
  33. kernel_is ge 2 6 18 || die "Linux >=2.6.18 and <3.2.9 required"
  34. kernel_is lt 3 9 || die "Linux >=2.6.18 and <3.9 required"
  35. else
  36. CONFIG_CHECK+=" ~OPENVSWITCH"
  37. linux-info_pkg_setup
  38. fi
  39. use monitor && python-single-r1_pkg_setup
  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. }
  47. src_configure() {
  48. set_arch_to_kernel
  49. use monitor || export ovs_cv_python="no"
  50. use pyside || export ovs_cv_pyuic4="no"
  51. local linux_config
  52. use modules && linux_config="--with-linux=${KERNEL_DIR}"
  53. econf ${linux_config} \
  54. --with-rundir=/var/run/openvswitch \
  55. --with-logdir=/var/log/openvswitch \
  56. --with-pkidir=/etc/ssl/openvswitch \
  57. --with-dbdir=/var/lib/openvswitch \
  58. $(use_enable ssl) \
  59. $(use_enable !debug ndebug)
  60. }
  61. src_compile() {
  62. default
  63. use monitor && python_fix_shebang \
  64. utilities/ovs-{pcap,tcpundump,test,vlan-test} \
  65. utilities/bugtool/ovs-bugtool \
  66. ovsdb/ovsdbmonitor/ovsdbmonitor
  67. use modules && linux-mod_src_compile
  68. }
  69. src_install() {
  70. default
  71. if use monitor ; then
  72. python_domodule "${ED}"/usr/share/openvswitch/python/*
  73. rm -r "${ED}/usr/share/openvswitch/python"
  74. python_optimize "${ED}/usr/share/ovsdbmonitor"
  75. fi
  76. keepdir /var/{lib,log}/openvswitch
  77. keepdir /etc/ssl/openvswitch
  78. fperms 0750 /etc/ssl/openvswitch
  79. rm -rf "${ED}/var/run"
  80. use monitor || rmdir "${ED}/usr/share/ovsdbmonitor"
  81. use debug || rm "${ED}/usr/bin/ovs-parse-leaks"
  82. newconfd "${FILESDIR}/ovsdb-server_conf" ovsdb-server
  83. newconfd "${FILESDIR}/ovs-vswitchd_conf" ovs-vswitchd
  84. newconfd "${FILESDIR}/ovs-controller_conf" ovs-controller
  85. newinitd "${FILESDIR}/ovsdb-server-r1" ovsdb-server
  86. newinitd "${FILESDIR}/ovs-vswitchd-r1" ovs-vswitchd
  87. newinitd "${FILESDIR}/ovs-controller-r1" ovs-controller
  88. insinto /etc/logrotate.d
  89. newins rhel/etc_logrotate.d_openvswitch openvswitch
  90. use modules && linux-mod_src_install
  91. }
  92. pkg_postinst() {
  93. use modules && linux-mod_pkg_postinst
  94. for pv in ${REPLACING_VERSIONS}; do
  95. if ! version_is_at_least 1.9.0 ${pv} ; then
  96. ewarn "The configuration database for Open vSwitch got moved in version 1.9.0 from"
  97. ewarn " /etc/openvswitch"
  98. ewarn "to"
  99. ewarn " /var/lib/openvswitch"
  100. ewarn "Please copy/move the database manually before running the schema upgrade."
  101. ewarn "The PKI files are now supposed to go to /etc/ssl/openvswitch"
  102. fi
  103. done
  104. elog "Use the following command to create an initial database for ovsdb-server:"
  105. elog " emerge --config =${CATEGORY}/${PF}"
  106. elog "(will create a database in /var/lib/openvswitch/conf.db)"
  107. elog "or to convert the database to the current schema after upgrading."
  108. }
  109. pkg_config() {
  110. local db="${EPREFIX}/var/lib/openvswitch/conf.db"
  111. if [ -e "${db}" ] ; then
  112. einfo "Database '${db}' already exists, doing schema migration..."
  113. einfo "(if the migration fails, make sure that ovsdb-server is not running)"
  114. "${EPREFIX}/usr/bin/ovsdb-tool" convert "${db}" "${EPREFIX}/usr/share/openvswitch/vswitch.ovsschema" || die "converting database failed"
  115. else
  116. einfo "Creating new database '${db}'..."
  117. "${EPREFIX}/usr/bin/ovsdb-tool" create "${db}" "${EPREFIX}/usr/share/openvswitch/vswitch.ovsschema" || die "creating database failed"
  118. fi
  119. }