iproute2-4.10.0.ebuild 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. inherit eutils toolchain-funcs flag-o-matic multilib
  5. if [[ ${PV} == "9999" ]] ; then
  6. EGIT_REPO_URI="git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git"
  7. inherit git-2
  8. else
  9. SRC_URI="mirror://kernel/linux/utils/net/${PN}/${P}.tar.xz"
  10. KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
  11. fi
  12. DESCRIPTION="kernel routing and traffic control utilities"
  13. HOMEPAGE="https://wiki.linuxfoundation.org/networking/iproute2"
  14. LICENSE="GPL-2"
  15. SLOT="0"
  16. IUSE="atm berkdb +iptables ipv6 minimal selinux"
  17. # We could make libmnl optional, but it's tiny, so eh
  18. RDEPEND="!net-misc/arpd
  19. !minimal? ( net-libs/libmnl )
  20. iptables? ( >=net-firewall/iptables-1.4.20:= )
  21. berkdb? ( sys-libs/db:= )
  22. atm? ( net-dialup/linux-atm )
  23. selinux? ( sys-libs/libselinux )"
  24. # We require newer linux-headers for ipset support #549948 and some defines #553876
  25. DEPEND="${RDEPEND}
  26. app-arch/xz-utils
  27. iptables? ( virtual/pkgconfig )
  28. sys-devel/bison
  29. sys-devel/flex
  30. >=sys-kernel/linux-headers-3.16
  31. elibc_glibc? ( >=sys-libs/glibc-2.7 )"
  32. PATCHES=(
  33. "${FILESDIR}"/${PN}-3.1.0-mtu.patch #291907
  34. )
  35. src_prepare() {
  36. if ! use ipv6 ; then
  37. PATCHES+=(
  38. "${FILESDIR}"/${PN}-4.2.0-no-ipv6.patch #326849
  39. )
  40. fi
  41. epatch "${PATCHES[@]}"
  42. sed -i \
  43. -e '/^CC :=/d' \
  44. -e "/^LIBDIR/s:=.*:=/$(get_libdir):" \
  45. -e "s:-O2:${CFLAGS} ${CPPFLAGS}:" \
  46. -e "/^HOSTCC/s:=.*:= $(tc-getBUILD_CC):" \
  47. -e "/^WFLAGS/s:-Werror::" \
  48. -e "/^DBM_INCLUDE/s:=.*:=${T}:" \
  49. Makefile || die
  50. # Use /run instead of /var/run.
  51. sed -i \
  52. -e 's:/var/run:/run:g' \
  53. include/namespace.h \
  54. man/man8/ip-netns.8 || die
  55. # build against system headers
  56. rm -r include/netinet #include/linux include/ip{,6}tables{,_common}.h include/libiptc
  57. sed -i 's:TCPI_OPT_ECN_SEEN:16:' misc/ss.c || die
  58. use minimal && sed -i -e '/^SUBDIRS=/s:=.*:=lib tc ip:' Makefile
  59. }
  60. src_configure() {
  61. tc-export AR CC PKG_CONFIG
  62. # This sure is ugly. Should probably move into toolchain-funcs at some point.
  63. local setns
  64. pushd "${T}" >/dev/null
  65. printf '#include <sched.h>\nint main(){return setns(0, 0);}\n' > test.c
  66. ${CC} ${CFLAGS} ${CPPFLAGS} -D_GNU_SOURCE ${LDFLAGS} test.c >&/dev/null && setns=y || setns=n
  67. echo 'int main(){return 0;}' > test.c
  68. ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} test.c -lresolv >&/dev/null || sed -i '/^LDLIBS/s:-lresolv::' "${S}"/Makefile
  69. popd >/dev/null
  70. cat <<-EOF > Config
  71. TC_CONFIG_ATM := $(usex atm y n)
  72. TC_CONFIG_XT := $(usex iptables y n)
  73. TC_CONFIG_NO_XT := $(usex iptables n y)
  74. # We've locked in recent enough kernel headers #549948
  75. TC_CONFIG_IPSET := y
  76. HAVE_BERKELEY_DB := $(usex berkdb y n)
  77. HAVE_MNL := $(usex minimal n y)
  78. HAVE_SELINUX := $(usex selinux y n)
  79. IP_CONFIG_SETNS := ${setns}
  80. # Use correct iptables dir, #144265 #293709
  81. IPT_LIB_DIR := $(use iptables && ${PKG_CONFIG} xtables --variable=xtlibdir)
  82. EOF
  83. }
  84. src_install() {
  85. if use minimal ; then
  86. into /
  87. dosbin tc/tc
  88. dobin ip/ip
  89. return 0
  90. fi
  91. emake \
  92. DESTDIR="${D}" \
  93. LIBDIR="${EPREFIX}"/$(get_libdir) \
  94. SBINDIR="${EPREFIX}"/sbin \
  95. CONFDIR="${EPREFIX}"/etc/iproute2 \
  96. DOCDIR="${EPREFIX}"/usr/share/doc/${PF} \
  97. MANDIR="${EPREFIX}"/usr/share/man \
  98. ARPDDIR="${EPREFIX}"/var/lib/arpd \
  99. install
  100. rm "${ED}"/usr/share/doc/${PF}/*.{sgml,tex} || die #455988
  101. dodir /bin
  102. mv "${ED}"/{s,}bin/ip || die #330115
  103. dolib.a lib/libnetlink.a
  104. insinto /usr/include
  105. doins include/libnetlink.h
  106. # This local header pulls in a lot of linux headers it
  107. # doesn't directly need. Delete this header that requires
  108. # linux-headers-3.8 until that goes stable. #467716
  109. sed -i '/linux\/netconf.h/d' "${ED}"/usr/include/libnetlink.h || die
  110. if use berkdb ; then
  111. dodir /var/lib/arpd
  112. # bug 47482, arpd doesn't need to be in /sbin
  113. dodir /usr/bin
  114. mv "${ED}"/sbin/arpd "${ED}"/usr/bin/ || die
  115. fi
  116. }