ipset-6.30.ebuild 2.8 KB

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