-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_sensor
executable file
·128 lines (106 loc) · 1.89 KB
/
build_sensor
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh
root_dir=`pwd`
echo $root_dir
export root_dir
make_libs()
{
echo "******** Build libs ********"
cd src/tinyframe
./autogen.sh
chmod +x configure
./configure --prefix=$root_dir
make ||exit 0;
make install
cd -
cd src/dnswire
./autogen.sh
chmod +x configure
export tinyframe_CFLAGS="-I$root_dir/include/"
export tinyframe_LIBS="-L$root_dir/lib/ -ltinyframe"
./configure --prefix=$root_dir --disable-examples
#./configure --prefix=$root_dir
make ||exit 0;
make install
cd -
}
make_apps()
{
echo "******** Build apps ********"
cd src/sensor
make ||exit 0;
make install
cd -
}
make_clean()
{
echo "******** Clean ********"
if [ -d bin ];then rm -rf bin; fi
if [ -d share ];then rm -rf share; fi
if [ -d include ];then rm -rf include; fi
if [ -d lib ];then rm -rf lib; fi
#clean libs
cd src/tinyframe
make uninstall
make distclean
cd -
cd src/dnswire
make uninstall
make distclean
cd -
#clean apps
cd src/sensor
make clean
cd -
#clean rpm
cd rpmbuild
rm -rf BUILD BUILDROOT RPMS SOURCES SRPMS
cd -
}
build_rpm()
{
cd rpmbuild
rm -rf BUILD BUILDROOT RPMS SOURCES SRPMS
mkdir -pv ./{BUILD,BUILDROOT,RPMS,SOURCES,SRPMS}
echo "%_topdir "`pwd` > ~/.rpmmacros
rpmbuild -D "dist "`git rev-parse --short HEAD` -bb SPECS/dnstap_sensor.spec
cp RPMS/x86_64/dnstap-sensor-*.rpm $root_dir
cd -
}
if [ ! -d bin ];then mkdir bin; fi
if [ ! -d include ];then mkdir include; fi
if [ ! -d lib ];then mkdir lib; fi
if [ "`ls -A $root_dir/src/dnswire`" = "" ]; then
git submodule init
git submodule update
cd src/dnswire
git submodule init
git submodule update
cd -
fi
if [ $# -eq 0 ]
then
make_libs
make_apps
build_rpm
else
while [ $# -gt 0 ]
do
case $1 in
-l)
make_libs
;;
-a)
make_apps
;;
-r)
build_rpm
;;
-c)
make_clean
;;
*)
echo "Invalid paraments, MUST be [-r|-l|-a|-c]"
esac
shift
done
fi