| 1 |
# Copyright 1999-2011 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/net-firewall/ipset/ipset-6.8.ebuild,v 1.1 2011/07/24 10:59:11 pva Exp $
|
| 4 |
|
| 5 |
EAPI="4"
|
| 6 |
inherit autotools linux-info linux-mod
|
| 7 |
|
| 8 |
DESCRIPTION="IPset tool for iptables, successor to ippool."
|
| 9 |
HOMEPAGE="http://ipset.netfilter.org/"
|
| 10 |
SRC_URI="http://ipset.netfilter.org/${P}.tar.bz2"
|
| 11 |
|
| 12 |
LICENSE="GPL-2"
|
| 13 |
SLOT="0"
|
| 14 |
KEYWORDS="~amd64 ~x86"
|
| 15 |
IUSE="modules"
|
| 16 |
|
| 17 |
RDEPEND=">=net-firewall/iptables-1.4.4
|
| 18 |
net-libs/libmnl"
|
| 19 |
DEPEND="${RDEPEND}"
|
| 20 |
|
| 21 |
# configurable from outside, e.g. /etc/make.conf
|
| 22 |
IP_NF_SET_MAX=${IP_NF_SET_MAX:-256}
|
| 23 |
|
| 24 |
BUILD_TARGETS="modules"
|
| 25 |
MODULE_NAMES_ARG="kernel/net/netfilter/ipset/:${S}/kernel/net/netfilter/ipset"
|
| 26 |
MODULE_NAMES="xt_set(kernel/net/netfilter/ipset/:${S}/kernel/net/netfilter/)"
|
| 27 |
for i in ip_set{,_bitmap_{ip{,mac},port},_hash_{ip{,port{,ip,net}},net,net{port,iface}},_list_set}; do
|
| 28 |
MODULE_NAMES+=" ${i}(${MODULE_NAMES_ARG})"
|
| 29 |
done
|
| 30 |
CONFIG_CHECK="NETFILTER IP6_NF_IPTABLES !IP_SET"
|
| 31 |
ERROR_NETFILTER="ipset requires NETFILTER support in your kernel."
|
| 32 |
ERROR_IP6_NF_IPTABLES="ipset requires IP6_NF_IPTABLES support in your kernel."
|
| 33 |
ERROR_IP_SET="There is IP_SET support in your kernel. Please build ipset with modules USE flag disabled or you may have troubles loading correct modules."
|
| 34 |
|
| 35 |
check_header_patch() {
|
| 36 |
if ! $(grep -q NFNL_SUBSYS_IPSET "${KV_DIR}/include/linux/netfilter/nfnetlink.h"); then
|
| 37 |
eerror "Sorry, but you have to patch kernel sources with the following patch:"
|
| 38 |
eerror " # cd ${KV_DIR}"
|
| 39 |
eerror " # patch -i ${S}/netlink.patch -p1"
|
| 40 |
eerror "You do not need to recompile your kernel."
|
| 41 |
die "Unpatched kernel"
|
| 42 |
fi
|
| 43 |
}
|
| 44 |
|
| 45 |
pkg_setup() {
|
| 46 |
get_version
|
| 47 |
|
| 48 |
build_modules=0
|
| 49 |
if use modules; then
|
| 50 |
kernel_is -lt 2 6 35 && die "${PN} requires kernel greater then 2.6.35."
|
| 51 |
if linux_config_src_exists && linux_chkconfig_builtin "MODULES" ; then
|
| 52 |
if linux_chkconfig_builtin "IP_NF_SET"; then #274577
|
| 53 |
einfo "Modular kernel detected but IP_NF_SET=y, will not build kernel modules"
|
| 54 |
else
|
| 55 |
if kernel_is -gt 2 6 39; then
|
| 56 |
einfo "This kernel has modules inside, will not build kernel modules"
|
| 57 |
else
|
| 58 |
einfo "Modular kernel detected, will build kernel modules"
|
| 59 |
build_modules=1
|
| 60 |
fi
|
| 61 |
fi
|
| 62 |
else
|
| 63 |
einfo "Nonmodular kernel detected, will not build kernel modules"
|
| 64 |
fi
|
| 65 |
fi
|
| 66 |
|
| 67 |
[[ ${build_modules} -eq 1 ]] && linux-mod_pkg_setup
|
| 68 |
}
|
| 69 |
|
| 70 |
src_prepare() {
|
| 71 |
[[ ${build_modules} -eq 1 ]] && check_header_patch
|
| 72 |
eautoreconf
|
| 73 |
}
|
| 74 |
|
| 75 |
src_configure() {
|
| 76 |
econf \
|
| 77 |
--with-maxsets=${IP_NF_SET_MAX} \
|
| 78 |
--libdir="${EPREFIX}"/$(get_libdir) \
|
| 79 |
--with-ksource="${KV_DIR}" \
|
| 80 |
--with-kbuild="${KV_OUT_DIR}"
|
| 81 |
}
|
| 82 |
|
| 83 |
src_compile() {
|
| 84 |
einfo "Building userspace"
|
| 85 |
emake
|
| 86 |
|
| 87 |
if [[ ${build_modules} -eq 1 ]]; then
|
| 88 |
einfo "Building kernel modules"
|
| 89 |
set_arch_to_kernel
|
| 90 |
emake modules
|
| 91 |
fi
|
| 92 |
}
|
| 93 |
|
| 94 |
src_install() {
|
| 95 |
einfo "Installing userspace"
|
| 96 |
emake DESTDIR="${D}" install
|
| 97 |
|
| 98 |
if [[ ${build_modules} -eq 1 ]]; then
|
| 99 |
einfo "Installing kernel modules"
|
| 100 |
linux-mod_src_install
|
| 101 |
fi
|
| 102 |
find "${ED}" \( -name '*.la' -o -name '*.a' \) -exec rm -f '{}' +
|
| 103 |
}
|
| 104 |
|
| 105 |
pkg_postinst() {
|
| 106 |
linux-mod_pkg_postinst
|
| 107 |
elog "Note you need to rebuid and run kernel with netlink.patch or you'll get error:"
|
| 108 |
elog "Kernel error received: Invalid argument"
|
| 109 |
}
|