Mon, 28 Jan 2013 17:37:18 +0100
Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.
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.1
35 Release: 20120800
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
54 Patch2: snmp_iface.patch
56 # build information
57 BuildPreReq: OpenPKG, openpkg >= 20100101, gcc, make
58 PreReq: OpenPKG, openpkg >= 20100101
59 BuildPreReq: openssl
60 PreReq: openssl
61 %if "%{with_fsl}" == "yes"
62 BuildPreReq: fsl
63 PreReq: fsl
64 %endif
65 %if "%{with_perl}" == "yes"
66 BuildPreReq: perl
67 PreReq: perl
68 %endif
70 %description
71 This is a toolkit relating to the Simple Network Management Protocol
72 (SNMP), including an extensible agent, an SNMP library, tools to
73 request or set information from SNMP agents, tools to generate and
74 handle SNMP traps, a version of the unix 'netstat' command using
75 SNMP, etc.
77 %track
78 prog snmp = {
79 version = %{version}
80 url = http://sourceforge.net/projects/net-snmp/files/
81 regex = net-snmp-(\d+\.\d+\.\d+[a-z]?)\.tar\.gz
82 }
84 %prep
85 # unpack and patch package
86 %setup -q -n net-snmp-%{version}
87 %patch -p0
88 %patch -p0 -P 1
89 %patch -p0 -P 2
91 # provide a default PID file location
92 %{l_shtool} subst %{l_value -s -a} \
93 agent/snmpd.c \
94 apps/snmptrapd.c
96 # adjust package for not requiring --enable-shared for --with-perl-modules
97 # (because it technically working also with static libraries on most platforms)
98 %{l_shtool} subst \
99 -e 's/if test "x$enable_shared" != "xyes"; then/if false; then/g' \
100 configure
102 # remove incorrectly escaped shell construct quoting
103 %{l_shtool} subst \
104 -e 's;x\$OSTYPE;x;' \
105 -e 's;\(PERLPROG -e.*system\)([^)][^)]*;\1(echo;' \
106 configure
108 # adjust package to install Perl packages into RPM_BUILD_ROOT
109 %{l_shtool} subst \
110 -e "s;perl Makefile.PL;perl Makefile.PL PERL=$perl FULLPERL=$perl PREFIX=${RPM_BUILD_ROOT}%{l_prefix} INSTALLDIRS=vendor;g" \
111 -e 's/cd perl ; $(MAKE))/cd perl ; $(MAKE) pure_all)/g' \
112 -e 's/cd perl ; $(MAKE) install/cd perl ; $(MAKE) pure_install/g' \
113 Makefile.in
115 %build
116 # disable search for db library
117 ( echo "ac_cv_lib_db1_dbopen=no"
118 echo "ac_cv_lib_db_dbopen=no"
119 echo "ac_cv_lib_rpmdb_db_create=yes"
120 echo "ac_cv_lib_db_3_0_db_create=no"
121 ) >config.cache
123 # determine additional MIBs to include
124 mibs=""
125 %if "%{with_mib_host}" == "yes"
126 mibs="$mibs host"
127 %endif
128 %if "%{with_mib_smux}" == "yes"
129 mibs="$mibs smux"
130 %endif
131 %if "%{with_mib_sendmail}" == "yes"
132 mibs="$mibs mibII/mta_sendmail"
133 %endif
135 # use correct libraries for platform
136 case "%{l_platform -t}" in
137 *-hpux* ) loclibs="-lnm" ;;
138 esac
140 # configure package
141 CONFIG_SHELL=%{l_bash} \
142 ./configure \
143 --cache-file=./config.cache \
144 --with-cc="%{l_cc}" \
145 --with-cflags="%{l_cflags -O} %{l_cppflags}" \
146 --with-ldflags="%{l_ldflags} %{l_fsl_ldflags}" \
147 --with-libs="%{l_fsl_libs} $loclibs" \
148 --prefix=%{l_prefix} \
149 --with-logfile=/dev/null \
150 --with-persistent-directory=%{l_prefix}/var/snmp \
151 --with-openssl=%{l_prefix} \
152 --enable-silent-libtool \
153 %if "%{with_shared}" == "no"
154 --disable-shared \
155 %endif
156 %if "%{with_mib_host}" == "yes" || "%{with_mib_smux}" == "yes" || "%{with_mib_sendmail}" == "yes"
157 --with-mib-modules="$mibs" \
158 %endif
159 %if "%{with_mib_tables}" == "no"
160 --with-out-mib-modules="mibII/tcpTable mibII/udpTable" \
161 %endif
162 %if "%{with_perl}" == "yes"
163 --with-perl-modules \
164 --enable-embedded-perl \
165 %else
166 --without-perl-modules \
167 --disable-embedded-perl \
168 %endif
169 --with-defaults
171 # build package
172 %{l_make} %{l_mflags -O} touchit
173 %{l_make} %{l_mflags -O}
175 %install
176 # install package
177 %{l_shtool} subst -v \
178 -e "s;^\\(prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
179 -e "s;^\\(exec_prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
180 -e "s;^\\(persistentdir.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/var/snmp;g" \
181 `find . -type f -name Makefile -print`
182 %{l_make} %{l_mflags} install
184 # create additional directories
185 %{l_shtool} mkdir -f -p -m 755 \
186 $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
187 $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
188 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
189 $RPM_BUILD_ROOT%{l_prefix}/etc/snmp
191 # install default configuration
192 %{l_shtool} install -c -m 644 \
193 %{SOURCE snmpd.conf} %{SOURCE snmptrapd.conf} \
194 $RPM_BUILD_ROOT%{l_prefix}/etc/snmp/
196 # strip down installation
197 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
198 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ipf-mod.pl
199 ln $RPM_BUILD_ROOT%{l_prefix}/bin/snmptrap \
200 $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
201 strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
202 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
203 %if "%{with_perl}" == "yes"
204 find ${RPM_BUILD_ROOT}${l_prefix} -name .packlist -print | xargs rm -f
205 %endif
207 # install run-command script
208 %{l_shtool} mkdir -f -p -m 755 \
209 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
210 %{l_shtool} install -c -m 755 %{l_value -s -a} \
211 %{SOURCE rc.snmp} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
213 # install OSSP fsl configuration
214 %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
215 %{l_shtool} install -c -m 644 %{l_value -s -a} \
216 %{SOURCE fsl.snmp} \
217 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
219 # determine installation files
220 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
221 %{l_files_std} \
222 '%config %{l_prefix}/etc/fsl/fsl.snmp' \
223 '%config %{l_prefix}/etc/snmp/*.conf'
225 %files -f files
227 %clean
229 %post
230 # after upgrade, restart service
231 [ $1 -eq 2 ] || exit 0
232 eval `%{l_rc} snmp status 2>/dev/null`
233 [ ".$snmp_active" = .yes ] && %{l_rc} snmp restart
234 exit 0
236 %preun
237 # before erase, stop service and remove log files
238 [ $1 -eq 0 ] || exit 0
239 %{l_rc} snmp stop 2>/dev/null
240 rm -f $RPM_INSTALL_PREFIX/var/snmp/*
241 exit 0