michael@325: ## michael@325: ## snmp.spec -- OpenPKG RPM Package Specification michael@325: ## Copyright (c) 2000-2011 OpenPKG Foundation e.V. michael@325: ## michael@325: ## Permission to use, copy, modify, and distribute this software for michael@325: ## any purpose with or without fee is hereby granted, provided that michael@325: ## the above copyright notice and this permission notice appear in all michael@325: ## copies. michael@325: ## michael@325: ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED michael@325: ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF michael@325: ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. michael@325: ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR michael@325: ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@325: ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@325: ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF michael@325: ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND michael@325: ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, michael@325: ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT michael@325: ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@325: ## SUCH DAMAGE. michael@325: ## michael@325: michael@325: # package information michael@325: Name: snmp michael@325: Summary: Simple Network Management Protocol (SNMP) Toolkit michael@325: URL: http://www.net-snmp.org/ michael@325: Vendor: The NET-SNMP Project michael@325: Packager: OpenPKG Foundation e.V. michael@325: Distribution: OpenPKG Community michael@325: Class: BASE michael@325: Group: Network michael@325: License: BSD michael@588: Version: 5.7.1 michael@589: Release: 20120800 michael@325: michael@325: # package options michael@325: %option with_fsl yes michael@325: %option with_perl no michael@325: %option with_shared no michael@325: %option with_mib_host no michael@325: %option with_mib_smux no michael@325: %option with_mib_tables no michael@325: %option with_mib_sendmail no michael@325: michael@325: # list of sources michael@353: Source0: http://switch.dl.sourceforge.net/net-snmp/%{version}/net-snmp-%{version}.tar.gz michael@325: Source1: rc.snmp michael@325: Source2: fsl.snmp michael@325: Source3: snmpd.conf michael@325: Source4: snmptrapd.conf michael@325: Patch0: snmp.patch michael@384: Patch1: snmp_agentx.patch michael@588: Patch2: snmp_iface.patch michael@325: michael@325: # build information michael@636: BuildPreReq: OpenPKG, openpkg >= 20100101, gcc, make michael@589: PreReq: OpenPKG, openpkg >= 20100101 michael@325: BuildPreReq: openssl michael@325: PreReq: openssl michael@325: %if "%{with_fsl}" == "yes" michael@325: BuildPreReq: fsl michael@325: PreReq: fsl michael@325: %endif michael@325: %if "%{with_perl}" == "yes" michael@325: BuildPreReq: perl michael@325: PreReq: perl michael@325: %endif michael@325: michael@325: %description michael@325: This is a toolkit relating to the Simple Network Management Protocol michael@325: (SNMP), including an extensible agent, an SNMP library, tools to michael@325: request or set information from SNMP agents, tools to generate and michael@325: handle SNMP traps, a version of the unix 'netstat' command using michael@325: SNMP, etc. michael@325: michael@325: %track michael@325: prog snmp = { michael@325: version = %{version} michael@325: url = http://sourceforge.net/projects/net-snmp/files/ michael@325: regex = net-snmp-(\d+\.\d+\.\d+[a-z]?)\.tar\.gz michael@325: } michael@325: michael@325: %prep michael@325: # unpack and patch package michael@325: %setup -q -n net-snmp-%{version} michael@325: %patch -p0 michael@384: %patch -p0 -P 1 michael@588: %patch -p0 -P 2 michael@325: michael@325: # provide a default PID file location michael@325: %{l_shtool} subst %{l_value -s -a} \ michael@325: agent/snmpd.c \ michael@325: apps/snmptrapd.c michael@325: michael@325: # adjust package for not requiring --enable-shared for --with-perl-modules michael@325: # (because it technically working also with static libraries on most platforms) michael@325: %{l_shtool} subst \ michael@325: -e 's/if test "x$enable_shared" != "xyes"; then/if false; then/g' \ michael@325: configure michael@325: michael@353: # remove incorrectly escaped shell construct quoting michael@353: %{l_shtool} subst \ michael@353: -e 's;x\$OSTYPE;x;' \ michael@353: -e 's;\(PERLPROG -e.*system\)([^)][^)]*;\1(echo;' \ michael@353: configure michael@353: michael@325: # adjust package to install Perl packages into RPM_BUILD_ROOT michael@325: %{l_shtool} subst \ michael@325: -e "s;perl Makefile.PL;perl Makefile.PL PERL=$perl FULLPERL=$perl PREFIX=${RPM_BUILD_ROOT}%{l_prefix} INSTALLDIRS=vendor;g" \ michael@325: -e 's/cd perl ; $(MAKE))/cd perl ; $(MAKE) pure_all)/g' \ michael@325: -e 's/cd perl ; $(MAKE) install/cd perl ; $(MAKE) pure_install/g' \ michael@325: Makefile.in michael@325: michael@325: %build michael@325: # disable search for db library michael@325: ( echo "ac_cv_lib_db1_dbopen=no" michael@325: echo "ac_cv_lib_db_dbopen=no" michael@325: echo "ac_cv_lib_rpmdb_db_create=yes" michael@325: echo "ac_cv_lib_db_3_0_db_create=no" michael@325: ) >config.cache michael@325: michael@325: # determine additional MIBs to include michael@325: mibs="" michael@325: %if "%{with_mib_host}" == "yes" michael@325: mibs="$mibs host" michael@325: %endif michael@325: %if "%{with_mib_smux}" == "yes" michael@325: mibs="$mibs smux" michael@325: %endif michael@325: %if "%{with_mib_sendmail}" == "yes" michael@325: mibs="$mibs mibII/mta_sendmail" michael@325: %endif michael@325: michael@325: # use correct libraries for platform michael@325: case "%{l_platform -t}" in michael@325: *-hpux* ) loclibs="-lnm" ;; michael@325: esac michael@325: michael@325: # configure package michael@327: CONFIG_SHELL=%{l_bash} \ michael@325: ./configure \ michael@325: --cache-file=./config.cache \ michael@325: --with-cc="%{l_cc}" \ michael@325: --with-cflags="%{l_cflags -O} %{l_cppflags}" \ michael@325: --with-ldflags="%{l_ldflags} %{l_fsl_ldflags}" \ michael@325: --with-libs="%{l_fsl_libs} $loclibs" \ michael@325: --prefix=%{l_prefix} \ michael@325: --with-logfile=/dev/null \ michael@325: --with-persistent-directory=%{l_prefix}/var/snmp \ michael@325: --with-openssl=%{l_prefix} \ michael@325: --enable-silent-libtool \ michael@325: %if "%{with_shared}" == "no" michael@325: --disable-shared \ michael@325: %endif michael@325: %if "%{with_mib_host}" == "yes" || "%{with_mib_smux}" == "yes" || "%{with_mib_sendmail}" == "yes" michael@325: --with-mib-modules="$mibs" \ michael@325: %endif michael@325: %if "%{with_mib_tables}" == "no" michael@325: --with-out-mib-modules="mibII/tcpTable mibII/udpTable" \ michael@325: %endif michael@325: %if "%{with_perl}" == "yes" michael@325: --with-perl-modules \ michael@325: --enable-embedded-perl \ michael@325: %else michael@325: --without-perl-modules \ michael@325: --disable-embedded-perl \ michael@325: %endif michael@325: --with-defaults michael@325: michael@325: # build package michael@636: %{l_make} %{l_mflags -O} touchit michael@636: %{l_make} %{l_mflags -O} michael@325: michael@325: %install michael@325: # install package michael@325: %{l_shtool} subst -v \ michael@325: -e "s;^\\(prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \ michael@325: -e "s;^\\(exec_prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \ michael@325: -e "s;^\\(persistentdir.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/var/snmp;g" \ michael@325: `find . -type f -name Makefile -print` michael@325: %{l_make} %{l_mflags} install michael@325: michael@325: # create additional directories michael@325: %{l_shtool} mkdir -f -p -m 755 \ michael@325: $RPM_BUILD_ROOT%{l_prefix}/var/snmp \ michael@325: $RPM_BUILD_ROOT%{l_prefix}/var/snmp \ michael@325: $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \ michael@325: $RPM_BUILD_ROOT%{l_prefix}/etc/snmp michael@325: michael@325: # install default configuration michael@325: %{l_shtool} install -c -m 644 \ michael@325: %{SOURCE snmpd.conf} %{SOURCE snmptrapd.conf} \ michael@325: $RPM_BUILD_ROOT%{l_prefix}/etc/snmp/ michael@325: michael@325: # strip down installation michael@325: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform michael@325: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ipf-mod.pl michael@325: ln $RPM_BUILD_ROOT%{l_prefix}/bin/snmptrap \ michael@325: $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform michael@325: strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true michael@325: strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true michael@325: %if "%{with_perl}" == "yes" michael@325: find ${RPM_BUILD_ROOT}${l_prefix} -name .packlist -print | xargs rm -f michael@325: %endif michael@325: michael@325: # install run-command script michael@325: %{l_shtool} mkdir -f -p -m 755 \ michael@325: $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d michael@325: %{l_shtool} install -c -m 755 %{l_value -s -a} \ michael@325: %{SOURCE rc.snmp} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ michael@325: michael@325: # install OSSP fsl configuration michael@325: %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl michael@325: %{l_shtool} install -c -m 644 %{l_value -s -a} \ michael@325: %{SOURCE fsl.snmp} \ michael@325: $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/ michael@325: michael@325: # determine installation files michael@325: %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ michael@325: %{l_files_std} \ michael@325: '%config %{l_prefix}/etc/fsl/fsl.snmp' \ michael@325: '%config %{l_prefix}/etc/snmp/*.conf' michael@325: michael@325: %files -f files michael@325: michael@325: %clean michael@325: michael@325: %post michael@325: # after upgrade, restart service michael@325: [ $1 -eq 2 ] || exit 0 michael@325: eval `%{l_rc} snmp status 2>/dev/null` michael@325: [ ".$snmp_active" = .yes ] && %{l_rc} snmp restart michael@325: exit 0 michael@325: michael@325: %preun michael@325: # before erase, stop service and remove log files michael@325: [ $1 -eq 0 ] || exit 0 michael@325: %{l_rc} snmp stop 2>/dev/null michael@325: rm -f $RPM_INSTALL_PREFIX/var/snmp/* michael@325: exit 0 michael@325: