snmp/snmp.spec

Fri, 25 Mar 2011 20:08:38 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 25 Mar 2011 20:08:38 +0100
changeset 326
efe7dfa57059
parent 325
6601d28cfe52
child 327
02bcb113e039
permissions
-rw-r--r--

Backport RPM boilerplate logic required by legacy OpenPKG scripts.

     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.6.1
    35 Release:      20110106
    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/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 RPM support in Host MIB
    97     #   (because OpenPKG RPM is a little bit different)
    98     %{l_shtool} subst \
    99         -e 's;/usr/include/rpm;%{l_prefix}/include/rpm;g' \
   100         -e 's;-lpopt\([^a-z]\);-lrpmpopt\1;g' \
   101         -e 's;db-3\.1;rpmdb;g' \
   102         -e 's;-lz\([^a-z]\);-lrpz\1;g' \
   103         -e 's;-lrpm\([^a-z]\);-lrpm -lrpmio\1;g' \
   104         -e 's;-lrpmio\([^a-z]\);-lrpmio -lrpmpopt -lrpmbz2 -lrpmz\1;g' \
   105         configure
   107     #   adjust package for not requiring --enable-shared for --with-perl-modules
   108     #   (because it technically working also with static libraries on most platforms)
   109     %{l_shtool} subst \
   110         -e 's/if test "x$enable_shared" != "xyes"; then/if false; then/g' \
   111         configure
   113     #   adjust package to install Perl packages into RPM_BUILD_ROOT
   114     %{l_shtool} subst \
   115         -e "s;perl Makefile.PL;perl Makefile.PL PERL=$perl FULLPERL=$perl PREFIX=${RPM_BUILD_ROOT}%{l_prefix} INSTALLDIRS=vendor;g" \
   116         -e 's/cd perl ; $(MAKE))/cd perl ; $(MAKE) pure_all)/g' \
   117         -e 's/cd perl ; $(MAKE) install/cd perl ; $(MAKE) pure_install/g' \
   118         Makefile.in
   120 %build
   121     #   disable search for db library
   122     ( echo "ac_cv_lib_db1_dbopen=no"
   123       echo "ac_cv_lib_db_dbopen=no"
   124       echo "ac_cv_lib_rpmdb_db_create=yes"
   125       echo "ac_cv_lib_db_3_0_db_create=no"
   126     ) >config.cache
   128     #   determine additional MIBs to include
   129     mibs=""
   130 %if "%{with_mib_host}" == "yes"
   131     mibs="$mibs host"
   132 %endif
   133 %if "%{with_mib_smux}" == "yes"
   134     mibs="$mibs smux"
   135 %endif
   136 %if "%{with_mib_sendmail}" == "yes"
   137     mibs="$mibs mibII/mta_sendmail"
   138 %endif
   140     #   use correct libraries for platform
   141     case "%{l_platform -t}" in
   142         *-hpux* ) loclibs="-lnm" ;;
   143     esac
   145     #   configure package
   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