Fri, 10 Aug 2012 14:26:56 +0200
Import package vendor original specs for necessary manipulations.
1 ##
2 ## snmp.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2011 OpenPKG Foundation e.V. <http://openpkg.net/>
4 ##
5 ## Permission to use, copy, modify, and distribute this software for
6 ## any purpose with or without fee is hereby granted, provided that
7 ## the above copyright notice and this permission notice appear in all
8 ## copies.
9 ##
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21 ## SUCH DAMAGE.
22 ##
24 # package information
25 Name: snmp
26 Summary: Simple Network Management Protocol (SNMP) Toolkit
27 URL: http://www.net-snmp.org/
28 Vendor: The NET-SNMP Project
29 Packager: OpenPKG Foundation e.V.
30 Distribution: OpenPKG Community
31 Class: BASE
32 Group: Network
33 License: BSD
34 Version: 5.7
35 Release: 20110915
37 # package options
38 %option with_fsl yes
39 %option with_perl no
40 %option with_shared no
41 %option with_mib_host no
42 %option with_mib_smux no
43 %option with_mib_tables no
44 %option with_mib_sendmail no
46 # list of sources
47 Source0: http://switch.dl.sourceforge.net/net-snmp/%{version}/net-snmp-%{version}.tar.gz
48 Source1: rc.snmp
49 Source2: fsl.snmp
50 Source3: snmpd.conf
51 Source4: snmptrapd.conf
52 Patch0: snmp.patch
53 Patch1: snmp_agentx.patch
55 # build information
56 Prefix: %{l_prefix}
57 BuildRoot: %{l_buildroot}
58 BuildPreReq: OpenPKG, openpkg >= 20060823, gcc
59 PreReq: OpenPKG, openpkg >= 20060823
60 BuildPreReq: openssl
61 PreReq: openssl
62 %if "%{with_fsl}" == "yes"
63 BuildPreReq: fsl
64 PreReq: fsl
65 %endif
66 %if "%{with_perl}" == "yes"
67 BuildPreReq: perl
68 PreReq: perl
69 %endif
70 AutoReq: no
71 AutoReqProv: no
73 %description
74 This is a toolkit relating to the Simple Network Management Protocol
75 (SNMP), including an extensible agent, an SNMP library, tools to
76 request or set information from SNMP agents, tools to generate and
77 handle SNMP traps, a version of the unix 'netstat' command using
78 SNMP, etc.
80 %track
81 prog snmp = {
82 version = %{version}
83 url = http://sourceforge.net/projects/net-snmp/files/
84 regex = net-snmp-(\d+\.\d+\.\d+[a-z]?)\.tar\.gz
85 }
87 %prep
88 # unpack and patch package
89 %setup -q -n net-snmp-%{version}
90 %patch -p0
91 %patch -p0 -P 1
93 # provide a default PID file location
94 %{l_shtool} subst %{l_value -s -a} \
95 agent/snmpd.c \
96 apps/snmptrapd.c
98 # adjust package for not requiring --enable-shared for --with-perl-modules
99 # (because it technically working also with static libraries on most platforms)
100 %{l_shtool} subst \
101 -e 's/if test "x$enable_shared" != "xyes"; then/if false; then/g' \
102 configure
104 # remove incorrectly escaped shell construct quoting
105 %{l_shtool} subst \
106 -e 's;x\$OSTYPE;x;' \
107 -e 's;\(PERLPROG -e.*system\)([^)][^)]*;\1(echo;' \
108 configure
110 # adjust package to install Perl packages into RPM_BUILD_ROOT
111 %{l_shtool} subst \
112 -e "s;perl Makefile.PL;perl Makefile.PL PERL=$perl FULLPERL=$perl PREFIX=${RPM_BUILD_ROOT}%{l_prefix} INSTALLDIRS=vendor;g" \
113 -e 's/cd perl ; $(MAKE))/cd perl ; $(MAKE) pure_all)/g' \
114 -e 's/cd perl ; $(MAKE) install/cd perl ; $(MAKE) pure_install/g' \
115 Makefile.in
117 %build
118 # disable search for db library
119 ( echo "ac_cv_lib_db1_dbopen=no"
120 echo "ac_cv_lib_db_dbopen=no"
121 echo "ac_cv_lib_rpmdb_db_create=yes"
122 echo "ac_cv_lib_db_3_0_db_create=no"
123 ) >config.cache
125 # determine additional MIBs to include
126 mibs=""
127 %if "%{with_mib_host}" == "yes"
128 mibs="$mibs host"
129 %endif
130 %if "%{with_mib_smux}" == "yes"
131 mibs="$mibs smux"
132 %endif
133 %if "%{with_mib_sendmail}" == "yes"
134 mibs="$mibs mibII/mta_sendmail"
135 %endif
137 # use correct libraries for platform
138 case "%{l_platform -t}" in
139 *-hpux* ) loclibs="-lnm" ;;
140 esac
142 # configure package
143 CONFIG_SHELL=%{l_bash} \
144 ./configure \
145 --cache-file=./config.cache \
146 --with-cc="%{l_cc}" \
147 --with-cflags="%{l_cflags -O} %{l_cppflags}" \
148 --with-ldflags="%{l_ldflags} %{l_fsl_ldflags}" \
149 --with-libs="%{l_fsl_libs} $loclibs" \
150 --prefix=%{l_prefix} \
151 --with-logfile=/dev/null \
152 --with-persistent-directory=%{l_prefix}/var/snmp \
153 --with-openssl=%{l_prefix} \
154 --enable-silent-libtool \
155 %if "%{with_shared}" == "no"
156 --disable-shared \
157 %endif
158 %if "%{with_mib_host}" == "yes" || "%{with_mib_smux}" == "yes" || "%{with_mib_sendmail}" == "yes"
159 --with-mib-modules="$mibs" \
160 %endif
161 %if "%{with_mib_tables}" == "no"
162 --with-out-mib-modules="mibII/tcpTable mibII/udpTable" \
163 %endif
164 %if "%{with_perl}" == "yes"
165 --with-perl-modules \
166 --enable-embedded-perl \
167 %else
168 --without-perl-modules \
169 --disable-embedded-perl \
170 %endif
171 --with-defaults
173 # build package
174 %{l_make} %{l_mflags} touchit
175 %{l_make} %{l_mflags}
177 %install
178 rm -rf $RPM_BUILD_ROOT
180 # install package
181 %{l_shtool} subst -v \
182 -e "s;^\\(prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
183 -e "s;^\\(exec_prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
184 -e "s;^\\(persistentdir.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/var/snmp;g" \
185 `find . -type f -name Makefile -print`
186 %{l_make} %{l_mflags} install
188 # create additional directories
189 %{l_shtool} mkdir -f -p -m 755 \
190 $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
191 $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
192 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
193 $RPM_BUILD_ROOT%{l_prefix}/etc/snmp
195 # install default configuration
196 %{l_shtool} install -c -m 644 \
197 %{SOURCE snmpd.conf} %{SOURCE snmptrapd.conf} \
198 $RPM_BUILD_ROOT%{l_prefix}/etc/snmp/
200 # strip down installation
201 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
202 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ipf-mod.pl
203 ln $RPM_BUILD_ROOT%{l_prefix}/bin/snmptrap \
204 $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
205 strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
206 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
207 %if "%{with_perl}" == "yes"
208 find ${RPM_BUILD_ROOT}${l_prefix} -name .packlist -print | xargs rm -f
209 %endif
211 # install run-command script
212 %{l_shtool} mkdir -f -p -m 755 \
213 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
214 %{l_shtool} install -c -m 755 %{l_value -s -a} \
215 %{SOURCE rc.snmp} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
217 # install OSSP fsl configuration
218 %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
219 %{l_shtool} install -c -m 644 %{l_value -s -a} \
220 %{SOURCE fsl.snmp} \
221 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
223 # determine installation files
224 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
225 %{l_files_std} \
226 '%config %{l_prefix}/etc/fsl/fsl.snmp' \
227 '%config %{l_prefix}/etc/snmp/*.conf'
229 %files -f files
231 %clean
232 rm -rf $RPM_BUILD_ROOT
234 %post
235 # after upgrade, restart service
236 [ $1 -eq 2 ] || exit 0
237 eval `%{l_rc} snmp status 2>/dev/null`
238 [ ".$snmp_active" = .yes ] && %{l_rc} snmp restart
239 exit 0
241 %preun
242 # before erase, stop service and remove log files
243 [ $1 -eq 0 ] || exit 0
244 %{l_rc} snmp stop 2>/dev/null
245 rm -f $RPM_INSTALL_PREFIX/var/snmp/*
246 exit 0