snmp/snmp.spec

Wed, 08 Feb 2012 20:07:00 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 08 Feb 2012 20:07:00 +0200
changeset 588
300d43423c2e
parent 384
590d931d793c
child 589
6db023bc5512
permissions
-rw-r--r--

Update version, adapt patch, correct PID writing, correct build on newer
FreeBSD releases, and most importantly introduce new patch to try to
avoid segfault caused by multiple network interfaces with the same (or
no) address. This is common when configuring bridges and tunnels.

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

mercurial