1 |
# Copyright 1999-2006 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Header: /var/cvsroot/gentoo-x86/net-misc/l7-filter/l7-filter-2.6.ebuild,v 1.4 2006/10/14 21:42:51 agriffis Exp $ |
4 |
|
5 |
inherit linux-info eutils |
6 |
|
7 |
MY_P=netfilter-layer7-v${PV/_/-} |
8 |
DESCRIPTION="Kernel modules for layer 7 iptables filtering" |
9 |
HOMEPAGE="http://l7-filter.sourceforge.net" |
10 |
SRC_URI="mirror://sourceforge/l7-filter/${MY_P}.tar.gz |
11 |
mirror://gentoo/additional_patch_for_2.6.13.diff" |
12 |
|
13 |
LICENSE="GPL-2" |
14 |
KEYWORDS="~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86" |
15 |
IUSE="" |
16 |
#break repoman |
17 |
#SLOT="${KV}" |
18 |
SLOT="0" |
19 |
S=${WORKDIR}/${MY_P} |
20 |
RDEPEND="net-misc/l7-protocols" |
21 |
|
22 |
|
23 |
which_patch() { |
24 |
if kernel_is ge 2 6 18 |
25 |
then |
26 |
PATCH=kernel-2.6.18-layer7-2.6.patch |
27 |
elif kernel_is ge 2 6 17 |
28 |
then |
29 |
PATCH=for_older_kernels/kernel-2.6.17-layer7-2.5.patch |
30 |
elif kernel_is ge 2 6 13 |
31 |
then |
32 |
PATCH=for_older_kernels/kernel-2.6.13-2.6.16-layer7-2.2.patch |
33 |
elif kernel_is ge 2 6 11 |
34 |
then |
35 |
PATCH=for_older_kernels/kernel-2.6.11-2.6.12-layer7-1.4.patch |
36 |
elif kernel_is ge 2 6 9 |
37 |
then |
38 |
PATCH=for_older_kernels/kernel-2.6.9-2.6.10-layer7-1.2.patch |
39 |
elif kernel_is 2 4 |
40 |
then |
41 |
PATCH=kernel-2.4-layer7-2.2.patch |
42 |
else |
43 |
die "No L7-filter patch for Kernel version ${KV_FULL} - sorry not supported" |
44 |
fi |
45 |
} |
46 |
|
47 |
pkg_setup() { |
48 |
linux-info_pkg_setup |
49 |
pkg_preinstall |
50 |
pkg_postinst |
51 |
} |
52 |
|
53 |
src_unpack() { |
54 |
|
55 |
which_patch |
56 |
|
57 |
if [ -f ${KV_DIR}/include/linux/netfilter_ipv4/ipt_layer7.h ] |
58 |
then |
59 |
ewarn "already installed ${PN} for kernel ${KV_FULL}" |
60 |
ewarn "If this is an upgrade attempt, try unmerging first." |
61 |
ewarn "If this failes remove your kernel source from /usr/src" |
62 |
ewarn "and remerge your kernel sources" |
63 |
die |
64 |
fi |
65 |
|
66 |
unpack ${MY_P}.tar.gz |
67 |
|
68 |
[ ! -f "${S}/${PATCH}" ] && \ |
69 |
die "patch ${PATCH} not found. Please enter a bug at bugs.gentoo.org" |
70 |
|
71 |
|
72 |
cd ${S} |
73 |
|
74 |
mkdir kernel |
75 |
mkdir kernel/Documentation |
76 |
|
77 |
|
78 |
# create needed directories |
79 |
mkdir -p ${S}/kernel/net/ipv4/netfilter/regexp/ |
80 |
mkdir -p ${S}/kernel/include/linux/netfilter_ipv4/ |
81 |
|
82 |
cd ${KV_DIR} |
83 |
|
84 |
# start to copy needed files, if file not exists create an empty file |
85 |
FILES=$(patch -t --dry-run -p1 < ${S}/${PATCH} | grep "^patching file" | cut -f 3 -d ' ') |
86 |
for F in ${FILES}; |
87 |
do |
88 |
if [ -f "${F}" ]; |
89 |
then |
90 |
cp -P "${F}" "${S}/kernel/${F}" |
91 |
else |
92 |
touch "${S}/kernel/${F}" |
93 |
fi |
94 |
done |
95 |
|
96 |
#patch the copied kernel source |
97 |
cd ${S}/kernel |
98 |
EPATCH_OPTS="-F 3" epatch "${S}/${PATCH}" |
99 |
|
100 |
# https://bugs.gentoo.org/show_bug.cgi?id=106009#c5 |
101 |
if kernel_is eq 2 6 12 |
102 |
then |
103 |
epatch "${DISTDIR}"/additional_patch_for_2.6.13.diff |
104 |
fi |
105 |
} |
106 |
|
107 |
src_compile() { |
108 |
einfo "no compiling - just patching source" |
109 |
} |
110 |
|
111 |
src_install() { |
112 |
insinto "$(/bin/readlink -f ${KV_DIR})" |
113 |
doins -r kernel/* |
114 |
dodoc CHANGELOG README |
115 |
} |
116 |
|
117 |
pkg_preinstall() { |
118 |
if has collision-protect ${FEATURES}; then |
119 |
ewarn |
120 |
ewarn "Collisions are expected as this patches kernel code. Disable" |
121 |
ewarn "FEATURES=collision-protect before use" |
122 |
die 'incompatible FEATURES=collision-protect' |
123 |
fi |
124 |
} |
125 |
|
126 |
pkg_postinst() { |
127 |
ewarn "This may not work with all kernels. If it does not work please enter a bug at bugs.gentoo.org" |
128 |
ewarn "This only patches the current kernel source code. (${KV_DIR})" |
129 |
ewarn "Its up to you to recompile the kernel with the l7 options" |
130 |
ewarn |
131 |
ewarn 'You will also need to emerge iptables with the "extensions" or' |
132 |
ewarn '"l7filter" USE flag (depend which version of iptables you emerge)' |
133 |
} |
134 |
|
135 |
# |
136 |
# Unpatching of patched files is required to avoid a broken kernel source tree |
137 |
|
138 |
pkg_prerm() { |
139 |
# How to determine what version it was installed against? - measily |
140 |
eval $(/bin/fgrep KV=2 ${ROOT}/var/db/pkg/net-misc/${PF}/environment |\ |
141 |
/bin/head -1) |
142 |
KV_DIR=/usr/src/linux-"${KV}" |
143 |
if [ -d ${KV_DIR} ]; then |
144 |
ewarn "${KV_DIR} nolonger exists" |
145 |
return 0; |
146 |
fi |
147 |
echo "KV_DIR=$KV_DIR" |
148 |
if [ -f ${KV_DIR}/include/linux/netfilter_ipv4/ipt_layer7.h ] |
149 |
then |
150 |
einfo 'attempting to unpatch l7-patch from kernel ${KV_FULL}' |
151 |
which_patch |
152 |
if kernel_is eq 2 6 12 |
153 |
then |
154 |
|
155 |
patch -F 3 -d "${KV_DIR}" -R -p1 \ |
156 |
< "${DISTDIR}"/additional_patch_for_2.6.13.diff |
157 |
fi |
158 |
cd "${T}" |
159 |
unpack ${MY_P}.tar.gz |
160 |
EPATCH_SINGLE_MSG="removing previous patch" \ |
161 |
EPATCH_OPTS="-F 3 -d "${KV_DIR}" -R" epatch "${T}/${MY_P}/${PATCH}" |
162 |
fi |
163 |
} |