ipset-6.16.ebuild 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # Copyright 1999-2014 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. inherit autotools linux-info linux-mod
  5. DESCRIPTION="IPset tool for iptables, successor to ippool"
  6. HOMEPAGE="http://ipset.netfilter.org/"
  7. SRC_URI="http://ipset.netfilter.org/${P}.tar.bz2"
  8. LICENSE="GPL-2"
  9. SLOT="0"
  10. KEYWORDS="~amd64 ~ppc ~x86"
  11. IUSE="modules"
  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,net{port,iface}},_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. build_modules=0
  38. if use modules; then
  39. kernel_is -lt 2 6 35 && die "${PN} requires kernel greater then 2.6.35."
  40. if linux_config_src_exists && linux_chkconfig_builtin "MODULES" ; then
  41. if linux_chkconfig_present "IP_NF_SET" || \
  42. linux_chkconfig_present "IP_SET"; then #274577
  43. eerror "There is IP{,_NF}_SET or NETFILTER_XT_SET support in your kernel."
  44. eerror "Please either build ipset with modules USE flag disabled"
  45. eerror "or rebuild kernel without IP_SET support and make sure"
  46. eerror "there is NO kernel ip_set* modules in /lib/modules/<your_kernel>/... ."
  47. die "USE=modules and in-kernel ipset support detected."
  48. else
  49. einfo "Modular kernel detected. Gonna build kernel modules..."
  50. build_modules=1
  51. fi
  52. else
  53. eerror "Nonmodular kernel detected, but USE=modules. Either build"
  54. eerror "modular kernel (without IP_SET) or disable USE=modules"
  55. die "Nonmodular kernel detected, will not build kernel modules"
  56. fi
  57. fi
  58. [[ ${build_modules} -eq 1 ]] && linux-mod_pkg_setup
  59. }
  60. src_prepare() {
  61. [[ ${build_modules} -eq 1 ]] && check_header_patch
  62. eautoreconf
  63. }
  64. src_configure() {
  65. econf \
  66. $(use_with modules kmod) \
  67. --disable-static \
  68. --with-maxsets=${IP_NF_SET_MAX} \
  69. --libdir="${EPREFIX}/$(get_libdir)" \
  70. --with-ksource="${KV_DIR}" \
  71. --with-kbuild="${KV_OUT_DIR}"
  72. }
  73. src_compile() {
  74. einfo "Building userspace"
  75. emake
  76. if [[ ${build_modules} -eq 1 ]]; then
  77. einfo "Building kernel modules"
  78. set_arch_to_kernel
  79. emake modules
  80. fi
  81. }
  82. src_install() {
  83. einfo "Installing userspace"
  84. default
  85. prune_libtool_files
  86. newinitd "${FILESDIR}"/ipset.initd-r2 ${PN}
  87. newconfd "${FILESDIR}"/ipset.confd ${PN}
  88. keepdir /var/lib/ipset
  89. if [[ ${build_modules} -eq 1 ]]; then
  90. einfo "Installing kernel modules"
  91. linux-mod_src_install
  92. fi
  93. }