-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·51 lines (44 loc) · 1.07 KB
/
build.sh
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
pwd=$(dirname $(readlink -f $0))
build_dir=build-ipvs
ipvs=net/netfilter/ipvs
mkdir -p ${build_dir}
gen_makefile()
{
grep KERNELDIR Makefile > 0
if [ $? -eq 0 ]; then
return 0
fi
cat <<EOF>> Makefile
# build ipvs as kernel module out of kernel source tree
KERNELDIR ?=/lib/modules/\$(shell uname -r)/build
PWD :=\$(shell pwd)
default:
\$(MAKE) -C \$(KERNELDIR) M=\$(PWD) \$(CONFIGS) modules
clean:
@rm -rf *.o *~ core .depend .*.cmd *.ko *.ko.unsigned *.mod.c .tmp_versions \
Module.symvers modules.order
.PHONY: modules modules_install clean
EOF
}
patch_ipvs()
{
cat patch-ipvs/$1.patch |patch -tp0
}
build_ipvs()
{
echo build $version
cd ./kernel-src && cat $version.*| tar -xz && cd ..
cp ./kernel-src/${version}/${ipvs} ${build_dir}/${version}-ipvs -r
patch_ipvs $version
cd ./${build_dir}/${version}-ipvs
gen_makefile
make && mkdir -p ../$version-ipvs-ko && mv ./*.ko ../$version-ipvs-ko
cd ../../
}
if [ $# != 1 ];then
echo "need kernel-version"
echo "usage: ./$0 $(for i in $(cat kernel-src/current);do echo -n " $i ";done)"
exit 0
fi
version=$1
build_ipvs