File: patch_kernel

package info (click to toggle)
ipset 2.5.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 636 kB
  • ctags: 1,153
  • sloc: ansic: 10,075; makefile: 191; sh: 108; perl: 13
file content (70 lines) | stat: -rwxr-xr-x 1,465 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

# set -e

kconfig() {
	file=$1/net/ipv4/netfilter/Kconfig
	if [ "`grep 'config IP_NF_SET' $file`" ]; then
		return
	fi
	mv $file $file.orig
	grep -v endmenu $file.orig > $file
	cat Kconfig.ipset >> $file
	echo "endmenu" >> $file
}

config() {
	file=$1/net/ipv4/netfilter/Config.in
	if [ "`grep 'CONFIG_IP_NF_SET' $file`" ]; then
		return
	fi
	mv $file $file.orig
	grep -v endmenu $file.orig > $file
	cat Config.in.ipset >> $file
	echo "endmenu" >> $file
}

makefile() {
	file=$1/net/ipv4/netfilter/Makefile
	if [ "`grep CONFIG_IP_NF_SET $file`" ]; then
		return
	fi
	cp $file $file.orig
	cat Makefile.ipset >> $file
}

oldmakefile() {
	file=$1/net/ipv4/netfilter/Makefile
	if [ "`grep CONFIG_IP_NF_SET $file`" ]; then
		return
	fi
	lineno=`grep -n Rules.make $file | cut -f1 -d:`
	lineno=$((lineno-1))
	head -n $lineno $file > $file.head
	lineno=$((lineno+1))
	tail +$lineno $file > $file.tail
	cp $file $file.orig
	cat $file.head Makefile.ipset Makefile.export.ipset $file.tail > $file
}

tree() {
	cp include/linux/netfilter_ipv4/* $1/include/linux/netfilter_ipv4/
	cp *.c $1/net/ipv4/netfilter/
}

if [ -z "$1" ]; then
	echo "Error: missing kernel directory parameter."
	exit 1
fi
if [ -f $1/net/ipv4/netfilter/Kconfig ]; then
	tree $1
	kconfig $1
	makefile $1
elif [ -f $1/net/ipv4/netfilter/Config.in ]; then
	tree $1
	config $1
	oldmakefile $1
else
	echo "Error: The directory $1 doesn't look like a Linux 2.4/2.6 kernel source tree."
	exit 1
fi