1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/snmp/snmp.spec Fri Mar 25 20:06:11 2011 +0100 1.3 @@ -0,0 +1,243 @@ 1.4 +## 1.5 +## snmp.spec -- OpenPKG RPM Package Specification 1.6 +## Copyright (c) 2000-2011 OpenPKG Foundation e.V. <http://openpkg.net/> 1.7 +## 1.8 +## Permission to use, copy, modify, and distribute this software for 1.9 +## any purpose with or without fee is hereby granted, provided that 1.10 +## the above copyright notice and this permission notice appear in all 1.11 +## copies. 1.12 +## 1.13 +## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 1.14 +## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1.15 +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1.16 +## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR 1.17 +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.18 +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.19 +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 1.20 +## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 1.21 +## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 1.22 +## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 1.23 +## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1.24 +## SUCH DAMAGE. 1.25 +## 1.26 + 1.27 +# package information 1.28 +Name: snmp 1.29 +Summary: Simple Network Management Protocol (SNMP) Toolkit 1.30 +URL: http://www.net-snmp.org/ 1.31 +Vendor: The NET-SNMP Project 1.32 +Packager: OpenPKG Foundation e.V. 1.33 +Distribution: OpenPKG Community 1.34 +Class: BASE 1.35 +Group: Network 1.36 +License: BSD 1.37 +Version: 5.6.1 1.38 +Release: 20110104 1.39 + 1.40 +# package options 1.41 +%option with_fsl yes 1.42 +%option with_perl no 1.43 +%option with_shared no 1.44 +%option with_mib_host no 1.45 +%option with_mib_smux no 1.46 +%option with_mib_tables no 1.47 +%option with_mib_sendmail no 1.48 + 1.49 +# list of sources 1.50 +Source0: http://switch.dl.sourceforge.net/net-snmp/net-snmp-%{version}.tar.gz 1.51 +Source1: rc.snmp 1.52 +Source2: fsl.snmp 1.53 +Source3: snmpd.conf 1.54 +Source4: snmptrapd.conf 1.55 +Patch0: snmp.patch 1.56 + 1.57 +# build information 1.58 +BuildPreReq: OpenPKG, openpkg >= 20100101, gcc 1.59 +PreReq: OpenPKG, openpkg >= 20100101 1.60 +BuildPreReq: openssl 1.61 +PreReq: openssl 1.62 +%if "%{with_fsl}" == "yes" 1.63 +BuildPreReq: fsl 1.64 +PreReq: fsl 1.65 +%endif 1.66 +%if "%{with_perl}" == "yes" 1.67 +BuildPreReq: perl 1.68 +PreReq: perl 1.69 +%endif 1.70 + 1.71 +%description 1.72 + This is a toolkit relating to the Simple Network Management Protocol 1.73 + (SNMP), including an extensible agent, an SNMP library, tools to 1.74 + request or set information from SNMP agents, tools to generate and 1.75 + handle SNMP traps, a version of the unix 'netstat' command using 1.76 + SNMP, etc. 1.77 + 1.78 +%track 1.79 + prog snmp = { 1.80 + version = %{version} 1.81 + url = http://sourceforge.net/projects/net-snmp/files/ 1.82 + regex = net-snmp-(\d+\.\d+\.\d+[a-z]?)\.tar\.gz 1.83 + } 1.84 + 1.85 +%prep 1.86 + # unpack and patch package 1.87 + %setup -q -n net-snmp-%{version} 1.88 + %patch -p0 1.89 + 1.90 + # provide a default PID file location 1.91 + %{l_shtool} subst %{l_value -s -a} \ 1.92 + agent/snmpd.c \ 1.93 + apps/snmptrapd.c 1.94 + 1.95 + # adjust package for RPM support in Host MIB 1.96 + # (because OpenPKG RPM is a little bit different) 1.97 + %{l_shtool} subst \ 1.98 + -e 's;/usr/include/rpm;%{l_prefix}/include/rpm;g' \ 1.99 + -e 's;-lpopt\([^a-z]\);-lrpmpopt\1;g' \ 1.100 + -e 's;db-3\.1;rpmdb;g' \ 1.101 + -e 's;-lz\([^a-z]\);-lrpz\1;g' \ 1.102 + -e 's;-lrpm\([^a-z]\);-lrpm -lrpmio\1;g' \ 1.103 + -e 's;-lrpmio\([^a-z]\);-lrpmio -lrpmpopt -lrpmbz2 -lrpmz\1;g' \ 1.104 + configure 1.105 + 1.106 + # adjust package for not requiring --enable-shared for --with-perl-modules 1.107 + # (because it technically working also with static libraries on most platforms) 1.108 + %{l_shtool} subst \ 1.109 + -e 's/if test "x$enable_shared" != "xyes"; then/if false; then/g' \ 1.110 + configure 1.111 + 1.112 + # adjust package to install Perl packages into RPM_BUILD_ROOT 1.113 + %{l_shtool} subst \ 1.114 + -e "s;perl Makefile.PL;perl Makefile.PL PERL=$perl FULLPERL=$perl PREFIX=${RPM_BUILD_ROOT}%{l_prefix} INSTALLDIRS=vendor;g" \ 1.115 + -e 's/cd perl ; $(MAKE))/cd perl ; $(MAKE) pure_all)/g' \ 1.116 + -e 's/cd perl ; $(MAKE) install/cd perl ; $(MAKE) pure_install/g' \ 1.117 + Makefile.in 1.118 + 1.119 +%build 1.120 + # disable search for db library 1.121 + ( echo "ac_cv_lib_db1_dbopen=no" 1.122 + echo "ac_cv_lib_db_dbopen=no" 1.123 + echo "ac_cv_lib_rpmdb_db_create=yes" 1.124 + echo "ac_cv_lib_db_3_0_db_create=no" 1.125 + ) >config.cache 1.126 + 1.127 + # determine additional MIBs to include 1.128 + mibs="" 1.129 +%if "%{with_mib_host}" == "yes" 1.130 + mibs="$mibs host" 1.131 +%endif 1.132 +%if "%{with_mib_smux}" == "yes" 1.133 + mibs="$mibs smux" 1.134 +%endif 1.135 +%if "%{with_mib_sendmail}" == "yes" 1.136 + mibs="$mibs mibII/mta_sendmail" 1.137 +%endif 1.138 + 1.139 + # use correct libraries for platform 1.140 + case "%{l_platform -t}" in 1.141 + *-hpux* ) loclibs="-lnm" ;; 1.142 + esac 1.143 + 1.144 + # configure package 1.145 + ./configure \ 1.146 + --cache-file=./config.cache \ 1.147 + --with-cc="%{l_cc}" \ 1.148 + --with-cflags="%{l_cflags -O} %{l_cppflags}" \ 1.149 + --with-ldflags="%{l_ldflags} %{l_fsl_ldflags}" \ 1.150 + --with-libs="%{l_fsl_libs} $loclibs" \ 1.151 + --prefix=%{l_prefix} \ 1.152 + --with-logfile=/dev/null \ 1.153 + --with-persistent-directory=%{l_prefix}/var/snmp \ 1.154 + --with-openssl=%{l_prefix} \ 1.155 + --enable-silent-libtool \ 1.156 +%if "%{with_shared}" == "no" 1.157 + --disable-shared \ 1.158 +%endif 1.159 +%if "%{with_mib_host}" == "yes" || "%{with_mib_smux}" == "yes" || "%{with_mib_sendmail}" == "yes" 1.160 + --with-mib-modules="$mibs" \ 1.161 +%endif 1.162 +%if "%{with_mib_tables}" == "no" 1.163 + --with-out-mib-modules="mibII/tcpTable mibII/udpTable" \ 1.164 +%endif 1.165 +%if "%{with_perl}" == "yes" 1.166 + --with-perl-modules \ 1.167 + --enable-embedded-perl \ 1.168 +%else 1.169 + --without-perl-modules \ 1.170 + --disable-embedded-perl \ 1.171 +%endif 1.172 + --with-defaults 1.173 + 1.174 + # build package 1.175 + %{l_make} %{l_mflags} touchit 1.176 + %{l_make} %{l_mflags} 1.177 + 1.178 +%install 1.179 + 1.180 + # install package 1.181 + %{l_shtool} subst -v \ 1.182 + -e "s;^\\(prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \ 1.183 + -e "s;^\\(exec_prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \ 1.184 + -e "s;^\\(persistentdir.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/var/snmp;g" \ 1.185 + `find . -type f -name Makefile -print` 1.186 + %{l_make} %{l_mflags} install 1.187 + 1.188 + # create additional directories 1.189 + %{l_shtool} mkdir -f -p -m 755 \ 1.190 + $RPM_BUILD_ROOT%{l_prefix}/var/snmp \ 1.191 + $RPM_BUILD_ROOT%{l_prefix}/var/snmp \ 1.192 + $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \ 1.193 + $RPM_BUILD_ROOT%{l_prefix}/etc/snmp 1.194 + 1.195 + # install default configuration 1.196 + %{l_shtool} install -c -m 644 \ 1.197 + %{SOURCE snmpd.conf} %{SOURCE snmptrapd.conf} \ 1.198 + $RPM_BUILD_ROOT%{l_prefix}/etc/snmp/ 1.199 + 1.200 + # strip down installation 1.201 + rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform 1.202 + rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ipf-mod.pl 1.203 + ln $RPM_BUILD_ROOT%{l_prefix}/bin/snmptrap \ 1.204 + $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform 1.205 + strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true 1.206 + strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true 1.207 +%if "%{with_perl}" == "yes" 1.208 + find ${RPM_BUILD_ROOT}${l_prefix} -name .packlist -print | xargs rm -f 1.209 +%endif 1.210 + 1.211 + # install run-command script 1.212 + %{l_shtool} mkdir -f -p -m 755 \ 1.213 + $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d 1.214 + %{l_shtool} install -c -m 755 %{l_value -s -a} \ 1.215 + %{SOURCE rc.snmp} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ 1.216 + 1.217 + # install OSSP fsl configuration 1.218 + %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl 1.219 + %{l_shtool} install -c -m 644 %{l_value -s -a} \ 1.220 + %{SOURCE fsl.snmp} \ 1.221 + $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/ 1.222 + 1.223 + # determine installation files 1.224 + %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ 1.225 + %{l_files_std} \ 1.226 + '%config %{l_prefix}/etc/fsl/fsl.snmp' \ 1.227 + '%config %{l_prefix}/etc/snmp/*.conf' 1.228 + 1.229 +%files -f files 1.230 + 1.231 +%clean 1.232 + 1.233 +%post 1.234 + # after upgrade, restart service 1.235 + [ $1 -eq 2 ] || exit 0 1.236 + eval `%{l_rc} snmp status 2>/dev/null` 1.237 + [ ".$snmp_active" = .yes ] && %{l_rc} snmp restart 1.238 + exit 0 1.239 + 1.240 +%preun 1.241 + # before erase, stop service and remove log files 1.242 + [ $1 -eq 0 ] || exit 0 1.243 + %{l_rc} snmp stop 2>/dev/null 1.244 + rm -f $RPM_INSTALL_PREFIX/var/snmp/* 1.245 + exit 0 1.246 +