source: projects/specs/trunk/s/snort/snort-vl.spec @ 8191

Revision 8191, 16.2 KB checked in by Takemikaduchi, 10 years ago (diff)

new upstream release or rebuild

Line 
1################################################################
2# rpmbuild Package Options
3# ========================
4#
5# See README.build_rpms for more details.
6#
7#       --with flexresp
8#               Add flexresp capability to whatever package(s) you are
9#               building.
10#
11#       --with inline
12#               Add inline capability to whatever package(s) you are
13#               building. This will create its own inline package.
14#
15#       --with mysql
16#               Builds a binary/package with support for MySQL.
17#
18#       --with postgresql
19#               Builds a binary/package with support for PostgreSQL.
20#
21#       --with unixODBC
22#               Build a binary/package with support for unixODBC
23#
24#       --with oracle
25#               Builds a binary/package with support for Oracle.
26#
27# See pg 399 of _Red_Hat_RPM_Guide_ for rpmbuild --with and --without options.
28################################################################
29
30# Other useful bits
31%define OracleHome /opt/oracle/OraHome1
32%define SnortRulesDir %{_sysconfdir}/snort/rules
33%define noShell /bin/false
34
35# Handle the options noted above.
36# Default of no flexresp, but --with flexresp will enable it
37%define flexresp 1
38%{?_with_flexresp:%define flexresp 1}
39%{?_without_flexresp:%define flexresp 0}
40
41# Default of no MySQL, but --with mysql will enable it
42%define mysql 0
43%{?_with_mysql:%define mysql 1}
44%{?_without_mysql:%define mysql 0}
45
46# Default of no PostgreSQL, but --with postgresql will enable it
47%define postgresql 0
48%{?_with_postgresql:%define postgresql 1}
49%{?_without_postgresql:%define postgresql 0}
50
51# Default of no unixODBC, but --with unixODBC will enable it
52%define unixODBC 0
53%{?_with_unixODBC:%define unixODBC 1}
54%{?_without_unixODBC:%define unixODBC 0}
55
56# Default of no Oracle, but --with oracle will enable it
57%define oracle 0
58%{?_with_oracle:%define oracle 1}
59
60# If not inline then we'll conflict with it
61%define conflicts snort-inline
62
63# Default of no Inline, but --with inline will enable it
64%define inline 0
65%define inlinetext %{nil}
66%{?_with_inline:%define inline 1}
67%{?_with_inline:%define inlinetext -inline }
68%{?_with_inline:%define conflicts snort }
69
70%define vendor Snort.org
71%define for_distro RPMs
72%define release 1
73%define realname snort
74
75# Look for a directory to see if we're building under cAos
76# Exit status is usually 0 if the dir exists, 1 if not, so
77# we reverse that with the '!'
78%define caos %([ ! -d /usr/lib/rpm/caos ]; echo $?)
79
80%if %{caos}
81  # We are building for cAos (www.caosity.org) and the autobuilder doesn't
82  # have command line options so we have to fake the options for whatever
83  # packages we actually want here, in addition to tweaking the package
84  # info.
85  %define vendor cAos Linux
86  %define for_distro RPMs for cAos Linux
87  %define mysql 1
88  %define postgresql 1
89  %define release 1.caos
90%endif
91
92
93Name: %{realname}%{inlinetext}
94%{?_with_inline:%define Name: %{realname}-inline }
95Version: 2.9.5.6
96Epoch: 1
97Release: 1%{?_dist_release}
98Summary: An open source Network Intrusion Detection System (NIDS)
99Group: Applications/Internet
100License: GPL
101Url: http://www.snort.org/
102Source0: http://www.snort.org/snort-downloads/2.9.2/%{realname}-%{version}.tar.gz
103
104BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
105
106#Packager: Official Snort.org %{for_distro}
107#Vendor: %{vendor}
108Vendor:         Project Vine
109Distribution:   Vine Linux
110
111BuildRequires: autoconf, automake, flex, bison
112BuildRequires: pcre-devel
113BuildRequires: libpcap-devel
114BuildRequires: daq
115BuildRequires: libdnet-devel
116BuildRequires: zlib-devel
117BuildRequires: iptables-devel
118BuildRequires: libnfnetlink-devel
119BuildRequires: libnetfilter_queue-devel
120Conflicts: %{conflicts}
121
122%if %{flexresp}
123BuildRequires: libnet
124  %define EnableFlexresp --enable-flexresp
125%endif
126
127# Itables-devel removed from BuildReq as RH does not supply that package.
128# Will replace iptables-devel buildreq with a scripted solution. --jh
129%if %{inline}
130BuildRequires: libnet
131  %define EnableInline --enable-inline
132%endif
133
134%package mysql
135Summary: Snort with MySQL support
136Group: Applications/Internet
137Requires: %{name} = %{epoch}:%{version}-%{release}
138%if %{mysql}
139BuildRequires: mysql-devel
140%endif
141
142%description mysql
143Snort binary compiled with mysql support.
144
145%package postgresql
146Summary: Snort with PostgreSQL support
147Group: Applications/Internet
148Requires: %{name} = %{epoch}:%{version}-%{release}
149%if %{postgresql}
150BuildRequires: postgresql-devel
151%endif
152
153%description postgresql
154Snort binary compiled with postgresql support.
155
156%package unixODBC
157Summary: Snort with unixODBC support
158Group: Applications/Internet
159Requires: %{name} = %{epoch}:%{version}-%{release}
160%if %{unixODBC}
161BuildRequires: unixODBC-devel
162%endif
163
164%description unixODBC
165Snort binary compiled with unixODBC support.
166
167%package oracle
168Summary: Snort with Oracle support
169Group: Applications/Internet
170Requires: %{name} = %{epoch}:%{version}-%{release}
171
172%description oracle
173Snort binary compiled with Oracle support.
174
175EXPERIMENTAL!!  I don't have a way to test this, so let me know if it works!
176ORACLE_HOME=%{OracleHome}
177
178
179%description
180Snort is an open source network intrusion detection system, capable of
181performing real-time traffic analysis and packet logging on IP networks.
182It can perform protocol analysis, content searching/matching and can be
183used to detect a variety of attacks and probes, such as buffer overflows,
184stealth port scans, CGI attacks, SMB probes, OS fingerprinting attempts,
185and much more.
186
187Snort has three primary uses. It can be used as a straight packet sniffer
188like tcpdump(1), a packet logger (useful for network traffic debugging,
189etc), or as a full blown network intrusion detection system.
190
191You MUST edit /etc/snort/snort.conf to configure snort before it will work!
192
193There are 5 different packages available. All of them require the base
194snort rpm (this one). Additionally, you may need to chose a different
195binary to install if you want database support.
196
197If you install a different binary package %{_sbindir}/snort should end up
198being a symlink to a binary in one of the following configurations:
199
200        plain           Snort (this package, required)
201        mysql           Snort with mysql (optional)
202        postgresql      Snort with postgresql (optional)
203        unixODBC        Snort with unixODBC (optional)
204        oracle          Snort with oracle (optional, not official)
205        inline          Snort with inline support (optional)
206
207Please see the documentation in %{_docdir}/%{realname}-%{version} for more
208information on snort features and configuration.
209
210
211%prep
212%setup -q -n %{realname}-%{version}
213
214# When building from a Snort.org CVS snapshot tarball, you have to run
215# autojunk before you can build.
216if [ \( ! -s configure \) -a \( -x autojunk.sh \) ]; then
217    ./autojunk.sh
218fi
219
220# Make sure it worked, or die with a useful error message.
221if [ ! -s configure ]; then
222    echo "Can't find ./configure.  ./autojunk.sh not present or not executable?"
223    exit 2
224fi
225
226
227%build
228
229BuildSnort() {
230   %__mkdir "$1"
231   cd "$1"
232   %__ln_s ../configure ./configure
233
234   if [ "$1" = "plain" ] ; then
235        ./configure $SNORT_BASE_CONFIG \
236        --without-mysql \
237        --without-postgresql \
238        --without-oracle \
239        --without-odbc \
240        %{?EnableFlexresp} %{?EnableFlexresp2} \
241        %{?EnableInline}
242   fi
243
244   if [ "$1" = "mysql" ]; then
245        ./configure $SNORT_BASE_CONFIG \
246        --with-mysql \
247        --with-mysql-libraries=%{_libdir} \
248        --without-postgresql \
249        --without-oracle \
250        --without-odbc \
251        %{?EnableFlexresp} %{?EnableFlexresp2} \
252        %{?EnableInline}
253   fi
254
255   if [ "$1" = "postgresql" ]; then
256        ./configure $SNORT_BASE_CONFIG \
257        --without-mysql \
258        --with-postgresql \
259        --without-odbc \
260        --without-oracle \
261        %{?EnableFlexresp} %{?EnableFlexresp2} \
262        %{?EnableInline}
263   fi
264
265  if [ "$1" = "unixODBC" ]; then
266        ./configure $SNORT_BASE_CONFIG \
267        --without-mysql \
268        --without-postgresql \
269        --with-odbc=%{_libdir} \
270        --without-oracle \
271        %{?EnableFlexresp} %{?EnableFlexresp2} \
272        %{?EnableInline}
273   fi
274
275   if [ "$1" = "oracle" ]; then
276        export ORACLE_HOME=%{OracleHome}
277        ./configure $SNORT_BASE_CONFIG \
278        --without-mysql \
279        --without-postgresql \
280        --without-odbc \
281        --with-oracle=$ORACLE_HOME \
282        %{?EnableFlexresp} %{?EnableFlexresp2} \
283        %{?EnableInline}
284   fi
285
286   %__make
287   %__mv src/snort ../%{name}-"$1"
288   cd ..
289}
290
291
292CFLAGS="$RPM_OPT_FLAGS"
293export AM_CFLAGS="-g -O2"
294SNORT_BASE_CONFIG="--prefix=%{_prefix} \
295                   --bindir=%{_sbindir} \
296                   --sysconfdir=%{_sysconfdir}/snort \
297                   --with-libpcap-includes=%{_includedir} \
298                   --enable-decoder-preprocessor-rules --enable-targetbased \
299                   "
300
301# Always build snort-plain
302BuildSnort plain
303
304# Maybe build the others
305%if %{mysql}
306  BuildSnort mysql
307%endif
308
309%if %{postgresql}
310  BuildSnort postgresql
311%endif
312
313%if %{oracle}
314  BuildSnort oracle
315%endif
316
317%if %{unixODBC}
318  BuildSnort unixODBC
319%endif
320
321
322%install
323
324# Remove leftover CVS files in the tarball, if any...
325find . -type 'd' -name "CVS" -print | xargs %{__rm} -rf
326
327InstallSnort() {
328   if [ "$1" = "mysql" ]; then
329        %__install -p -m 0755 %{name}-mysql %{buildroot}%{_sbindir}/%{name}-mysql
330   fi
331
332   if [ "$1" = "postgresql" ]; then
333        %__install -p -m 0755 %{name}-postgresql %{buildroot}%{_sbindir}/%{name}-postgresql
334   fi
335
336   if [ "$1" = "unixODBC" ]; then
337        %__install -p -m 0755 %{name}-unixODBC %{buildroot}%{_sbindir}/%{name}-unixODBC
338   fi
339
340   if [ "$1" = "oracle" ]; then
341        %__install -p -m 0755 %{name}-oracle %{buildroot}%{_sbindir}/%{name}-oracle
342   fi
343
344   if [ "$1" = "plain" ]; then
345        %__rm -rf %{buildroot}
346
347        %__mkdir_p -m 0755 %{buildroot}%{_sbindir}
348        %__mkdir_p -m 0755 %{buildroot}%{SnortRulesDir}
349        %__mkdir_p -m 0755 %{buildroot}%{_sysconfdir}/snort
350        %__mkdir_p -m 0755 %{buildroot}%{_sysconfdir}/sysconfig
351        %__mkdir_p -m 0755 %{buildroot}%{_sysconfdir}/logrotate.d
352        %__mkdir_p -m 0755 %{buildroot}%{_var}/log/snort
353        %__mkdir_p -m 0755 %{buildroot}%{_initrddir}
354        %__mkdir_p -m 0755 %{buildroot}%{_mandir}/man8
355        %__mkdir_p -m 0755 %{buildroot}%{_docdir}/%{realname}-%{version}
356
357        %__install -p -m 0755 %{name}-plain %{buildroot}%{_sbindir}/%{name}-plain
358        %__mkdir_p -m 0755 %{buildroot}%{_libdir}/%{realname}-%{version}_dynamicengine
359        %__mkdir_p -m 0755 %{buildroot}%{_libdir}/%{realname}-%{version}_dynamicpreprocessor
360        %__install -p -m 0755 plain/src/dynamic-plugins/sf_engine/.libs/libsf_engine.so.0 %{buildroot}%{_libdir}/%{realname}-%{version}_dynamicengine
361        %__ln_s -f %{_libdir}/%{realname}-%{version}_dynamicengine/libsf_engine.so.0 %{buildroot}%{_libdir}/%{realname}-%{version}_dynamicengine/libsf_engine.so
362        %__install -p -m 0755 plain/src/dynamic-preprocessors/build/%{_prefix}/lib/snort_dynamicpreprocessor/*.so* %{buildroot}%{_libdir}/%{realname}-%{version}_dynamicpreprocessor
363       
364    for file in %{buildroot}%{_libdir}/%{realname}-%{version}_dynamicpreprocessor/*.so;  do 
365          preprocessor=`basename $file`
366          %__ln_s -f %{_libdir}/%{realname}-%{version}_dynamicpreprocessor/$preprocessor.0 $file     
367    done   
368       
369        %__install -p -m 0644 snort.8 %{buildroot}%{_mandir}/man8
370        %__gzip %{buildroot}%{_mandir}/man8/snort.8
371        %__install -p -m 0755 rpm/snortd %{buildroot}%{_initrddir}
372        %__install -p -m 0644 rpm/snort.sysconfig %{buildroot}/%{_sysconfdir}/sysconfig/%{realname}
373        %__install -p -m 0644 rpm/snort.logrotate %{buildroot}/%{_sysconfdir}/logrotate.d/snort
374        %__install -p -m 0644 etc/reference.config etc/classification.config \
375                etc/unicode.map etc/gen-msg.map \
376                etc/threshold.conf etc/snort.conf \
377                %{buildroot}/%{_sysconfdir}/snort
378        find doc -maxdepth 1 -type f -not -name 'Makefile*' -exec %__install -p -m 0644 {} %{buildroot}%{_docdir}/%{realname}-%{version} \;
379
380        %__rm -f %{buildroot}%{_docdir}/%{realname}-%{version}/Makefile.*
381    fi
382}
383
384# Fix the RULE_PATH
385%__sed -e 's;var RULE_PATH ../rules;var RULE_PATH %{SnortRulesDir};' \
386        < etc/snort.conf > etc/snort.conf.new
387%__rm -f etc/snort.conf
388%__mv etc/snort.conf.new etc/snort.conf
389
390# Fix dynamic-preproc paths
391%__sed -e 's;dynamicpreprocessor directory \/usr\/local/lib\/snort_dynamicpreprocessor;dynamicpreprocessor directory %{_libdir}\/%{realname}-%{version}_dynamicpreprocessor;' < etc/snort.conf > etc/snort.conf.new
392%__rm -f etc/snort.conf
393%__mv etc/snort.conf.new etc/snort.conf
394
395# Fix dynamic-engine paths
396%__sed -e 's;dynamicengine \/usr\/local/lib\/snort_dynamicengine;dynamicengine %{_libdir}\/%{realname}-%{version}_dynamicengine;' < etc/snort.conf > etc/snort.conf.new
397%__rm -f etc/snort.conf
398%__mv etc/snort.conf.new etc/snort.conf
399
400
401# Always install snort-plain
402InstallSnort plain
403
404# Maybe install the others
405%if %{mysql}
406  InstallSnort mysql
407%endif
408
409%if %{postgresql}
410  InstallSnort postgresql
411%endif
412
413%if %{unixODBC}
414  InstallSnort unixODBC
415%endif
416
417%if %{oracle}
418  InstallSnort oracle
419%endif
420
421
422%clean
423%__rm -rf %{buildroot}
424
425
426%pre
427# Don't do all this stuff if we are upgrading
428if [ $1 = 1 ] ; then
429        /usr/sbin/groupadd snort 2> /dev/null || true
430        /usr/sbin/useradd -M -d %{_var}/log/snort -s %{noShell} -c "Snort" -g snort snort 2>/dev/null || true
431fi
432
433%post mysql
434if [ -L %{_sbindir}/snort ] || [ ! -e %{_sbindir}/snort ] ; then
435        %__rm -f %{_sbindir}/snort; %__ln_s -f %{_sbindir}/%{name}-mysql %{_sbindir}/snort
436fi
437
438%post postgresql
439if [ -L %{_sbindir}/snort ] || [ ! -e %{_sbindir}/snort ] ; then
440        %__rm -f %{_sbindir}/snort; %__ln_s -f %{_sbindir}/%{name}-postgresql %{_sbindir}/snort
441fi
442
443%post unixODBC
444if [ -L %{_sbindir}/snort ] || [ ! -e %{_sbindir}/snort ] ; then
445        %__rm -f %{_sbindir}/snort; %__ln_s -f %{_sbindir}/%{name}-unixODBC %{_sbindir}/snort
446fi
447
448
449%post oracle
450if [ -L %{_sbindir}/snort ] || [ ! -e %{_sbindir}/snort ] ; then
451        %__rm -f %{_sbindir}/snort; %__ln_s %{_sbindir}/%{name}-oracle %{_sbindir}/snort
452fi
453
454%post
455# Make a symlink if there is no link for snort-plain
456if [ -L %{_sbindir}/snort ] || [ ! -e %{_sbindir}/snort ] ; then \
457        %__rm -f %{_sbindir}/snort; %__ln_s %{_sbindir}/%{name}-plain %{_sbindir}/snort; fi
458
459# We should restart it to activate the new binary if it was upgraded
460%{_initrddir}/snortd condrestart 1>/dev/null 2>/dev/null
461
462# Don't do all this stuff if we are upgrading
463if [ $1 = 1 ] ; then
464        %__chown -R snort.snort %{_var}/log/snort
465        /sbin/chkconfig --add snortd
466fi
467
468
469%preun
470if [ $1 = 0 ] ; then
471        # We get errors about not running, but we don't care
472        %{_initrddir}/snortd stop 2>/dev/null 1>/dev/null
473        /sbin/chkconfig --del snortd
474fi
475
476%postun
477# Try and restart, but don't bail if it fails
478if [ $1 -ge 1 ] ; then
479        %{_initrddir}/snortd condrestart  1>/dev/null 2>/dev/null || :
480fi
481
482# Only do this if we are actually removing snort
483if [ $1 = 0 ] ; then
484        if [ -L %{_sbindir}/snort ]; then
485                %__rm -f %{_sbindir}/snort
486        fi
487
488        /usr/sbin/userdel snort 2>/dev/null
489fi
490
491%postun mysql
492if [ -L %{_sbindir}/snort ]; then
493        %__rm -f %{_sbindir}/snort
494        %__ln_s -f %{_sbindir}/%{name}-plain %{_sbindir}/snort
495fi
496
497%postun postgresql
498if [ -L %{_sbindir}/snort ]; then
499        %__rm -f %{_sbindir}/snort
500        %__ln_s -f %{_sbindir}/%{name}-plain %{_sbindir}/snort
501fi
502
503%postun unixODBC
504if [ -L %{_sbindir}/snort ]; then
505        %__rm -f %{_sbindir}/snort
506        %__ln_s -f %{_sbindir}/%{name}-plain %{_sbindir}/snort
507fi
508
509%postun oracle
510if [ -L %{_sbindir}/snort ]; then
511        %__rm -f %{_sbindir}/snort
512        %__ln_s -f %{_sbindir}/%{name}-plain %{_sbindir}/snort
513fi
514
515%files
516%defattr(-,root,root,-)
517%{_sbindir}/%{name}-plain
518%{_mandir}/man8/snort.8.*
519%dir %{SnortRulesDir}
520%config(noreplace) %{_sysconfdir}/snort/classification.config
521%config(noreplace) %{_sysconfdir}/snort/reference.config
522%config(noreplace) %{_sysconfdir}/snort/threshold.conf
523%config(noreplace) %{_sysconfdir}/snort/*.map
524%config(noreplace) %{_sysconfdir}/logrotate.d/snort
525%config(noreplace) %{_sysconfdir}/snort/snort.conf
526%config(noreplace) %{_sysconfdir}/sysconfig/snort
527%config(noreplace) %{_initrddir}/snortd
528%attr(0755,snort,snort) %dir %{_var}/log/snort
529%dir %{_sysconfdir}/snort
530%{_docdir}/%{realname}-%{version}/*
531%dir %{_libdir}/%{realname}-%{version}_dynamicengine
532%{_libdir}/%{realname}-%{version}_dynamicengine/libsf_engine.*
533%dir %{_libdir}/%{realname}-%{version}_dynamicpreprocessor
534%{_libdir}/%{realname}-%{version}_dynamicpreprocessor/libsf_*_preproc.*
535
536%dir %{_docdir}/%{realname}-%{version}
537%docdir %{_docdir}/%{realname}-%{version}
538
539%if %{mysql}
540%files mysql
541%defattr(-,root,root,-)
542%{_sbindir}/%{name}-mysql
543%endif
544
545%if %{postgresql}
546%files postgresql
547%defattr(-,root,root,-)
548%{_sbindir}/%{name}-postgresql
549%endif
550
551%if %{unixODBC}
552%files unixODBC
553%defattr(-,root,root,-)
554%{_sbindir}/%{name}-unixODBC
555%endif
556
557%if %{oracle}
558%files oracle
559%defattr(-,root,root,-)
560%{_sbindir}/%{name}-oracle
561%endif
562
563
564%changelog
565* Wed Jan 15 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> - 2.9.5.6-1
566- new upstream release
567
568* Fri Mar 16 2012 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.9.2.1-1
569- initial build for Vine Linux (based on official srpm)
Note: See TracBrowser for help on using the repository browser.