snmp/snmp.spec

Thu, 15 Sep 2011 11:03:52 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Sep 2011 11:03:52 +0200
changeset 353
198005e4aad2
parent 327
02bcb113e039
child 384
590d931d793c
permissions
-rw-r--r--

Update to new version of vendor software.

     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:      20110914
    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
    54 #   build information
    55 Prefix:       %{l_prefix}
    56 BuildRoot:    %{l_buildroot}
    57 BuildPreReq:  OpenPKG, openpkg >= 20060823, gcc
    58 PreReq:       OpenPKG, openpkg >= 20060823
    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
    69 AutoReq:      no
    70 AutoReqProv:  no
    72 %description
    73     This is a toolkit relating to the Simple Network Management Protocol
    74     (SNMP), including an extensible agent, an SNMP library, tools to
    75     request or set information from SNMP agents, tools to generate and
    76     handle SNMP traps, a version of the unix 'netstat' command using
    77     SNMP, etc.
    79 %track
    80     prog snmp = {
    81         version   = %{version}
    82         url       = http://sourceforge.net/projects/net-snmp/files/
    83         regex     = net-snmp-(\d+\.\d+\.\d+[a-z]?)\.tar\.gz
    84     }
    86 %prep
    87     #   unpack and patch package
    88     %setup -q -n net-snmp-%{version}
    89     %patch -p0
    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} touchit
   173     %{l_make} %{l_mflags}
   175 %install
   176     rm -rf $RPM_BUILD_ROOT
   178     #   install package
   179     %{l_shtool} subst -v \
   180         -e "s;^\\(prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
   181         -e "s;^\\(exec_prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
   182         -e "s;^\\(persistentdir.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/var/snmp;g" \
   183         `find . -type f -name Makefile -print`
   184     %{l_make} %{l_mflags} install
   186     #   create additional directories
   187     %{l_shtool} mkdir -f -p -m 755 \
   188         $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
   189         $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
   190         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
   191         $RPM_BUILD_ROOT%{l_prefix}/etc/snmp
   193     #   install default configuration
   194     %{l_shtool} install -c -m 644 \
   195         %{SOURCE snmpd.conf} %{SOURCE snmptrapd.conf} \
   196         $RPM_BUILD_ROOT%{l_prefix}/etc/snmp/
   198     #   strip down installation
   199     rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
   200     rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ipf-mod.pl
   201     ln  $RPM_BUILD_ROOT%{l_prefix}/bin/snmptrap \
   202         $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
   203     strip $RPM_BUILD_ROOT%{l_prefix}/bin/*  >/dev/null 2>&1 || true
   204     strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
   205 %if "%{with_perl}" == "yes"
   206     find ${RPM_BUILD_ROOT}${l_prefix} -name .packlist -print | xargs rm -f
   207 %endif
   209     #   install run-command script
   210     %{l_shtool} mkdir -f -p -m 755 \
   211         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
   212     %{l_shtool} install -c -m 755 %{l_value -s -a} \
   213         %{SOURCE rc.snmp} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
   215     #   install OSSP fsl configuration
   216     %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
   217     %{l_shtool} install -c -m 644 %{l_value -s -a} \
   218         %{SOURCE fsl.snmp} \
   219         $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
   221     #   determine installation files
   222     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
   223         %{l_files_std} \
   224         '%config %{l_prefix}/etc/fsl/fsl.snmp' \
   225         '%config %{l_prefix}/etc/snmp/*.conf'
   227 %files -f files
   229 %clean
   230     rm -rf $RPM_BUILD_ROOT
   232 %post
   233     #   after upgrade, restart service
   234     [ $1 -eq 2 ] || exit 0
   235     eval `%{l_rc} snmp status 2>/dev/null`
   236     [ ".$snmp_active" = .yes ] && %{l_rc} snmp restart
   237     exit 0
   239 %preun
   240     #   before erase, stop service and remove log files
   241     [ $1 -eq 0 ] || exit 0
   242     %{l_rc} snmp stop 2>/dev/null
   243     rm -f $RPM_INSTALL_PREFIX/var/snmp/*
   244     exit 0

mercurial