ipset-6.24.ebuild 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. MODULES_OPTIONAL_USE=modules
  5. inherit 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 ~arm64 ~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. pkg_setup() {
  25. get_version
  26. CONFIG_CHECK="NETFILTER"
  27. ERROR_NETFILTER="ipset requires NETFILTER support in your kernel."
  28. # It does still build without NET_NS, but it may be needed in future.
  29. #CONFIG_CHECK="${CONFIG_CHECK} NET_NS"
  30. #ERROR_NET_NS="ipset requires NET_NS (network namespace) support in your kernel."
  31. build_modules=0
  32. if use modules; then
  33. kernel_is -lt 2 6 35 && die "${PN} requires kernel greater then 2.6.35."
  34. if linux_config_src_exists && linux_chkconfig_builtin "MODULES" ; then
  35. if linux_chkconfig_present "IP_NF_SET" || \
  36. linux_chkconfig_present "IP_SET"; then #274577
  37. eerror "There is IP{,_NF}_SET or NETFILTER_XT_SET support in your kernel."
  38. eerror "Please either build ipset with modules USE flag disabled"
  39. eerror "or rebuild kernel without IP_SET support and make sure"
  40. eerror "there is NO kernel ip_set* modules in /lib/modules/<your_kernel>/... ."
  41. die "USE=modules and in-kernel ipset support detected."
  42. else
  43. einfo "Modular kernel detected. Gonna build kernel modules..."
  44. build_modules=1
  45. fi
  46. else
  47. eerror "Nonmodular kernel detected, but USE=modules. Either build"
  48. eerror "modular kernel (without IP_SET) or disable USE=modules"
  49. die "Nonmodular kernel detected, will not build kernel modules"
  50. fi
  51. fi
  52. [[ ${build_modules} -eq 1 ]] && linux-mod_pkg_setup
  53. }
  54. src_configure() {
  55. econf \
  56. $(use_with modules kmod) \
  57. --disable-static \
  58. --with-maxsets=${IP_NF_SET_MAX} \
  59. --libdir="${EPREFIX}/$(get_libdir)" \
  60. --with-ksource="${KV_DIR}" \
  61. --with-kbuild="${KV_OUT_DIR}"
  62. }
  63. src_compile() {
  64. einfo "Building userspace"
  65. emake
  66. if [[ ${build_modules} -eq 1 ]]; then
  67. einfo "Building kernel modules"
  68. set_arch_to_kernel
  69. emake modules
  70. fi
  71. }
  72. src_install() {
  73. einfo "Installing userspace"
  74. default
  75. prune_libtool_files
  76. newinitd "${FILESDIR}"/ipset.initd-r3 ${PN}
  77. newconfd "${FILESDIR}"/ipset.confd ${PN}
  78. keepdir /var/lib/ipset
  79. if [[ ${build_modules} -eq 1 ]]; then
  80. einfo "Installing kernel modules"
  81. linux-mod_src_install
  82. fi
  83. }