ipset-6.21.1.ebuild 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # Copyright 1999-2014 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. MODULES_OPTIONAL_USE=modules
  5. inherit autotools linux-info linux-mod
  6. DESCRIPTION="IPset tool for iptables, successor to ippool"
  7. HOMEPAGE="http://ipset.netfilter.org/"
  8. SRC_URI="http://ipset.netfilter.org/${P}.tar.bz2"
  9. LICENSE="GPL-2"
  10. SLOT="0"
  11. KEYWORDS="~amd64 ~ppc ~x86"
  12. RDEPEND=">=net-firewall/iptables-1.4.7
  13. net-libs/libmnl"
  14. DEPEND="${RDEPEND}"
  15. DOCS=( ChangeLog INSTALL README UPGRADE )
  16. # configurable from outside, e.g. /etc/make.conf
  17. IP_NF_SET_MAX=${IP_NF_SET_MAX:-256}
  18. BUILD_TARGETS="modules"
  19. MODULE_NAMES_ARG="kernel/net/netfilter/ipset/:${S}/kernel/net/netfilter/ipset"
  20. MODULE_NAMES="xt_set(kernel/net/netfilter/ipset/:${S}/kernel/net/netfilter/)"
  21. for i in ip_set{,_bitmap_{ip{,mac},port},_hash_{ip{,port{,ip,net}},net{,port{,net},iface,net}},_list_set}; do
  22. MODULE_NAMES+=" ${i}(${MODULE_NAMES_ARG})"
  23. done
  24. check_header_patch() {
  25. if ! $(grep -q NFNL_SUBSYS_IPSET "${KV_DIR}/include/linux/netfilter/nfnetlink.h"); then
  26. eerror "Sorry, but you have to patch kernel sources with the following patch:"
  27. eerror " # cd ${KV_DIR}"
  28. eerror " # patch -i ${S}/netlink.patch -p1"
  29. eerror "You should recompile and run new kernel to avoid runtime errors."
  30. die "Unpatched kernel"
  31. fi
  32. }
  33. pkg_setup() {
  34. get_version
  35. CONFIG_CHECK="NETFILTER"
  36. ERROR_NETFILTER="ipset requires NETFILTER support in your kernel."
  37. # It does still build without NET_NS, but it may be needed in future.
  38. #CONFIG_CHECK="${CONFIG_CHECK} NET_NS"
  39. #ERROR_NET_NS="ipset requires NET_NS (network namespace) support in your kernel."
  40. build_modules=0
  41. if use modules; then
  42. kernel_is -lt 2 6 35 && die "${PN} requires kernel greater then 2.6.35."
  43. if linux_config_src_exists && linux_chkconfig_builtin "MODULES" ; then
  44. if linux_chkconfig_present "IP_NF_SET" || \
  45. linux_chkconfig_present "IP_SET"; then #274577
  46. eerror "There is IP{,_NF}_SET or NETFILTER_XT_SET support in your kernel."
  47. eerror "Please either build ipset with modules USE flag disabled"
  48. eerror "or rebuild kernel without IP_SET support and make sure"
  49. eerror "there is NO kernel ip_set* modules in /lib/modules/<your_kernel>/... ."
  50. die "USE=modules and in-kernel ipset support detected."
  51. else
  52. einfo "Modular kernel detected. Gonna build kernel modules..."
  53. build_modules=1
  54. fi
  55. else
  56. eerror "Nonmodular kernel detected, but USE=modules. Either build"
  57. eerror "modular kernel (without IP_SET) or disable USE=modules"
  58. die "Nonmodular kernel detected, will not build kernel modules"
  59. fi
  60. fi
  61. [[ ${build_modules} -eq 1 ]] && linux-mod_pkg_setup
  62. }
  63. src_prepare() {
  64. [[ ${build_modules} -eq 1 ]] && check_header_patch
  65. eautoreconf
  66. }
  67. src_configure() {
  68. econf \
  69. $(use_with modules kmod) \
  70. --disable-static \
  71. --with-maxsets=${IP_NF_SET_MAX} \
  72. --libdir="${EPREFIX}/$(get_libdir)" \
  73. --with-ksource="${KV_DIR}" \
  74. --with-kbuild="${KV_OUT_DIR}"
  75. }
  76. src_compile() {
  77. einfo "Building userspace"
  78. emake
  79. if [[ ${build_modules} -eq 1 ]]; then
  80. einfo "Building kernel modules"
  81. set_arch_to_kernel
  82. emake modules
  83. fi
  84. }
  85. src_install() {
  86. einfo "Installing userspace"
  87. default
  88. prune_libtool_files
  89. newinitd "${FILESDIR}"/ipset.initd-r3 ${PN}
  90. newconfd "${FILESDIR}"/ipset.confd ${PN}
  91. keepdir /var/lib/ipset
  92. if [[ ${build_modules} -eq 1 ]]; then
  93. einfo "Installing kernel modules"
  94. linux-mod_src_install
  95. fi
  96. }