-
Notifications
You must be signed in to change notification settings - Fork 5
/
prepare-nfdump.sh
executable file
·159 lines (127 loc) · 5.76 KB
/
prepare-nfdump.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/sh
#
# Copyright (c) 2013-2015, Tomas Podermanski
#
# This file is part of libnf.net project.
#
# Libnf is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Libnf is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with libnf. If not, see <http://www.gnu.org/licenses/>.
#
#
NFDUMP_VERSION="1.6.25"
NFDUMP="nfdump-$NFDUMP_VERSION"
NFDUMP_MD5="9c79e52b5b00c7ae7a31e8c681cf17cb"
NFDUMP_SRC="$NFDUMP.tar.gz"
NFDUMP_URL="https://github.com/phaag/nfdump/archive/v$NFDUMP_VERSION.tar.gz"
BZIP2_VERSION="1.0.6"
BZIP2="bzip2-$BZIP2_VERSION"
BZIP2_MD5="00b516f4704d4a7cb50a1d97e6e8e15b"
BZIP2_SRC="$BZIP2.tar.gz"
#BZIP2_URL="http://www.bzip.org/1.0.6/$BZIP2_SRC"
BZIP2_URL="https://netcologne.dl.sourceforge.net/project/bzip2/$BZIP2_SRC"
echo ""
echo "##########################################################"
echo "# STAGE 1.1: getting and patching nfdump sources #"
echo "##########################################################"
if [ ! -f $NFDUMP_SRC ] ; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!! !!"
echo "!! If automatic download fails please get nfdump !!"
echo "!! sources manually !!"
echo "!! !!"
echo "!! VERSION: $NFDUMP !!"
echo "!! URL: $NFDUMP_URL !!"
echo "!! FILE: $NFDUMP.tar.gz !!"
echo "!! !!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
wget -nv -O $NFDUMP_SRC $NFDUMP_URL || curl -L -o $NFDUMP_SRC $NFDUMP_URL || exit 1
fi
rm -rf nfdump/ $NFDUMP
./md5sum.sh $NFDUMP_MD5 $NFDUMP_SRC || exit 1
tar xzf $NFDUMP_SRC || exit 1
mv $NFDUMP nfdump || exit 1
(cd nfdump && ./bootstrap && ./configure && make clean) || exit 1
# for version < 1.6.18
#(cd nfdump && patch -p1 < ../nfdump-bugs.patch && cd .. ) || exit 1
# for version < 1.6.4
#(cd nfdump && patch -p1 < ../nfdump-thread.patch && cd .. ) || exit 1
# for version >= 1.6.4
#(cd nfdump && patch -p1 < ../nfdump-thread-nffile.patch && cd .. ) || exit 1
(cd nfdump && patch -p1 < ../nfdump-thread-nfx.patch && cd .. ) || exit 1
if [ ! -f nfdump/README ]; then
echo > nfdump/README
fi
echo ""
echo "##########################################################"
echo "# STAGE 1.1: fetching BZ2 source codes #"
echo "##########################################################"
wget -nv -O $BZIP2_SRC $BZIP2_URL || curl -L -o $BZIP2_SRC $BZIP2_URL || exit 1
rm -rf bzip2/ $BZIP2
./md5sum.sh $BZIP2_MD5 $BZIP2_SRC || exit 1
tar xzf $BZIP2_SRC || exit 1
mv $BZIP2 bzip2 || exit 1
echo ""
echo "##########################################################"
echo "# STAGE 2: preparing configure and nfdump sources #"
echo "##########################################################"
##echo "Getting configure.in from original nfdump"
##cp nfdump/configure.ac configure.ac
##echo "Adding LT_INT into configure.ac"
##perl -pi -w -e 's/(AM_INIT_AUTOMAKE.*)/$1\nLT_INIT()\n/g;' configure.ac
##echo "Replacing AC_REVISIONin configure.ac"
##sed -i -e 's/AC_REVISION.*//g' configure.ac #makefiles
##echo "Changing AC_INIT to AC_DEFINE in configure.ac"
##perl -pi -w -e 's/AC_INIT\((.*)\)/AC_DEFINE\(NFDUMP_VERSION,["$1"],[nfdump]\)/g;' configure.ac
##echo "Adding own AC_INIT in configure.ac"
##perl -pi -w -e 's/(AC_PREREQ.*)/$1\nAC_INIT\(libnf, '${LIBNF_VERSION}', tpoder\@cis.vutbr.cz\)/g;' configure.ac
##echo "Enabling NEL/NSEL in configure.ac"
##perl -pi -w -e 's/(AC_PROG_YACC)/CFLAGS="\$CFLAGS -DNSEL"\n\n$1/g;' configure.ac
##echo "Removing AC_OUTPUT and text from configure.ac"
##sed -i -e 's/AC_OUTPUT.*//g' configure.ac #makefiles
##sed -i -e 's/echo ".*//g' configure.ac #comments
##echo "Adding pthread.h checj into configure.ac"
##perl -pi -w -e 's/AC_HEADER_STDC/AC_HEADER_STDC\nAC_CHECK_HEADERS(pthread.h)\nLIBS="\$LIBS -lpthread"/g;' configure.ac
##echo "Adding extra configuration into configure.ac"
##cat >> configure.ac << EOT
##AC_OUTPUT(Makefile include/Makefile src/Makefile examples/Makefile)
##echo ""
##echo "The libnf extends the source code of nfdump tool"
##echo "developed by Peter Haag. Unmodified nfdump sources are"
##echo "placed in the nfudump directory that is distributed"
##echo "together with libnf package. Thanks for using libnf."
##echo "For more info visit http://libnf.net."
##echo ""
##EOT
FILES="nffile.c nfx.c nftree.c minilzo.c lz4.c nf_common.c grammar.y scanner.l \
ipconv.c output_util.c"
echo "Creating symlinks for $FILES"
for f in $FILES ; do
(cd src && rm -f $f && ln -s ../nfdump/bin/$f && cd ..) || exit 1
done
rm src/grammar.c
rm src/scanner.c
echo ""
echo "##########################################################"
echo "# STAGE 3: checking definitions of all items in libnf #"
echo "##########################################################"
echo ""
./check_items_map.pl || exit 1
echo ""
echo "##########################################################"
echo "# STAGE 4: creating final ./configure and Makefiles #"
echo "##########################################################"
./bootstrap || exit 1
echo ""
echo "##########################################################"
echo "# OK: it seems that all steps went well #"
echo "##########################################################"