summaryrefslogtreecommitdiff
blob: 18fd09264c099dc57dba1ab790926382e327acc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="2"

inherit eutils linux-mod

DESCRIPTION="extensions not yet accepted in the main kernel/iptables (patch-o-matic(-ng) successor)"
HOMEPAGE="http://xtables-addons.sourceforge.net/"
SRC_URI="mirror://sourceforge/xtables-addons/${P}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"
IUSE=""

MODULES="quota2 lscan length2 ipv4options ipset ipp2p geoip fuzzy condition tee tarpit sysrq steal logmark ipmark echo dhcpmac delude chaos"

for mod in ${MODULES}; do
	IUSE="${IUSE} xtables_addons_modules_${mod}"
done

RDEPEND="virtual/modutils
	>=net-firewall/iptables-1.4.3
	>virtual/linux-sources-2.6.22
	xtables_addons_modules_ipset? ( !net-firewall/ipset )"

DEPEND="${RDEPEND}"

pkg_setup()	{
	get_version
	check_modules_supported
	# CONFIG_IP_NF_CONNTRACK{,_MARK} doesn't exist in >virtual/linux-sources-2.6.22
	CONFIG_CHECK="NF_CONNTRACK NF_CONNTRACK_MARK"
	linux-mod_pkg_setup
}

src_prepare() {
	local all_modules
	all_modules=$(sed -n '/^build_/{s/build_\(.*\)=.*/\L\1/;G;s/\n/ /;s/ $//;h}; ${x;p}' "${S}/mconfig")
	if [[ ${all_modules} != ${MODULES} ]]; then
		ewarn "QA: Modules in mconfig differ from \$MODULES in ebuild."
		ewarn "Please, update MODULES in ebuild."
		ewarn "'${all_modules}'"
	fi

	for mod in ${MODULES}; do
		if use xtables_addons_modules_${mod}; then
			sed "s/\(build_${mod}=\).*/\1m/I" -i mconfig || die
			if [[ ${mod} != ipset ]]; then
				MODULE_NAMES+=" xt_$(sed -n "s/build_\(${mod}\)=.*/\1/Ip" mconfig)(xtables_addons:${S}/extensions:)"
			else
				for ipset_mod in $(sed -n '/^obj-m/{s:obj-m [+]= ::;s:[.]o::g;p}' "${S}/extensions/ipset/Kbuild"); do
					MODULE_NAMES+=" ${ipset_mod}(xtables_addons:${S}/extensions/ipset:)"
				done
			fi
		else
			sed "s/\(build_${mod}=\).*/\1n/I" -i mconfig || die
		fi
	done

	if [[ -z ${MODULE_NAMES} ]]; then
		eerror "All modules are disabled. What do you want me to build?"
		eerror "Please, set XTABLES_ADDONS_MODULES to any of"
		eerror "${MODULES}"
		die "All modules are disabled."
	fi

	MODULE_NAMES="compat_xtables(xtables_addons:${S}/extensions:)${MODULE_NAMES}"

	sed -e 's/depmod -a/true/' -i Makefile.{in,am} || die
	sed -e '/^all:/{s:modules ::}' \
		-e '/^install:/{s: modules_install::}' -i extensions/GNUmakefile.in || die
}

src_configure() {
	econf --prefix=/ \
		--libexecdir=/lib/ \
		--with-kbuild="${KV_DIR}"
}

src_compile() {
	emake CFLAGS="${CFLAGS}" CC="$(tc-getCC)" || die
	# don't build modules in ipset directory (linux-mod_src_compile builds all)
	touch ${S}/extensions/ipset/.built
	BUILD_TARGETS="modules" linux-mod_src_compile
}

src_install() {
	emake DESTDIR="${D}" install || die
	linux-mod_src_install
	dodoc README doc/changelog.txt || die
}