snmp/snmp.spec

Fri, 25 Mar 2011 20:06:11 +0100

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

Import package vendor original specs for necessary manipulations.

     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:      20110104
    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 BuildPreReq:  OpenPKG, openpkg >= 20100101, gcc
    56 PreReq:       OpenPKG, openpkg >= 20100101
    57 BuildPreReq:  openssl
    58 PreReq:       openssl
    59 %if "%{with_fsl}" == "yes"
    60 BuildPreReq:  fsl
    61 PreReq:       fsl
    62 %endif
    63 %if "%{with_perl}" == "yes"
    64 BuildPreReq:  perl
    65 PreReq:       perl
    66 %endif
    68 %description
    69     This is a toolkit relating to the Simple Network Management Protocol
    70     (SNMP), including an extensible agent, an SNMP library, tools to
    71     request or set information from SNMP agents, tools to generate and
    72     handle SNMP traps, a version of the unix 'netstat' command using
    73     SNMP, etc.
    75 %track
    76     prog snmp = {
    77         version   = %{version}
    78         url       = http://sourceforge.net/projects/net-snmp/files/
    79         regex     = net-snmp-(\d+\.\d+\.\d+[a-z]?)\.tar\.gz
    80     }
    82 %prep
    83     #   unpack and patch package
    84     %setup -q -n net-snmp-%{version}
    85     %patch -p0
    87     #   provide a default PID file location
    88     %{l_shtool} subst %{l_value -s -a} \
    89         agent/snmpd.c \
    90         apps/snmptrapd.c
    92     #   adjust package for RPM support in Host MIB
    93     #   (because OpenPKG RPM is a little bit different)
    94     %{l_shtool} subst \
    95         -e 's;/usr/include/rpm;%{l_prefix}/include/rpm;g' \
    96         -e 's;-lpopt\([^a-z]\);-lrpmpopt\1;g' \
    97         -e 's;db-3\.1;rpmdb;g' \
    98         -e 's;-lz\([^a-z]\);-lrpz\1;g' \
    99         -e 's;-lrpm\([^a-z]\);-lrpm -lrpmio\1;g' \
   100         -e 's;-lrpmio\([^a-z]\);-lrpmio -lrpmpopt -lrpmbz2 -lrpmz\1;g' \
   101         configure
   103     #   adjust package for not requiring --enable-shared for --with-perl-modules
   104     #   (because it technically working also with static libraries on most platforms)
   105     %{l_shtool} subst \
   106         -e 's/if test "x$enable_shared" != "xyes"; then/if false; then/g' \
   107         configure
   109     #   adjust package to install Perl packages into RPM_BUILD_ROOT
   110     %{l_shtool} subst \
   111         -e "s;perl Makefile.PL;perl Makefile.PL PERL=$perl FULLPERL=$perl PREFIX=${RPM_BUILD_ROOT}%{l_prefix} INSTALLDIRS=vendor;g" \
   112         -e 's/cd perl ; $(MAKE))/cd perl ; $(MAKE) pure_all)/g' \
   113         -e 's/cd perl ; $(MAKE) install/cd perl ; $(MAKE) pure_install/g' \
   114         Makefile.in
   116 %build
   117     #   disable search for db library
   118     ( echo "ac_cv_lib_db1_dbopen=no"
   119       echo "ac_cv_lib_db_dbopen=no"
   120       echo "ac_cv_lib_rpmdb_db_create=yes"
   121       echo "ac_cv_lib_db_3_0_db_create=no"
   122     ) >config.cache
   124     #   determine additional MIBs to include
   125     mibs=""
   126 %if "%{with_mib_host}" == "yes"
   127     mibs="$mibs host"
   128 %endif
   129 %if "%{with_mib_smux}" == "yes"
   130     mibs="$mibs smux"
   131 %endif
   132 %if "%{with_mib_sendmail}" == "yes"
   133     mibs="$mibs mibII/mta_sendmail"
   134 %endif
   136     #   use correct libraries for platform
   137     case "%{l_platform -t}" in
   138         *-hpux* ) loclibs="-lnm" ;;
   139     esac
   141     #   configure package
   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
   177     #   install package
   178     %{l_shtool} subst -v \
   179         -e "s;^\\(prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
   180         -e "s;^\\(exec_prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
   181         -e "s;^\\(persistentdir.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/var/snmp;g" \
   182         `find . -type f -name Makefile -print`
   183     %{l_make} %{l_mflags} install
   185     #   create additional directories
   186     %{l_shtool} mkdir -f -p -m 755 \
   187         $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
   188         $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
   189         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
   190         $RPM_BUILD_ROOT%{l_prefix}/etc/snmp
   192     #   install default configuration
   193     %{l_shtool} install -c -m 644 \
   194         %{SOURCE snmpd.conf} %{SOURCE snmptrapd.conf} \
   195         $RPM_BUILD_ROOT%{l_prefix}/etc/snmp/
   197     #   strip down installation
   198     rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
   199     rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ipf-mod.pl
   200     ln  $RPM_BUILD_ROOT%{l_prefix}/bin/snmptrap \
   201         $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
   202     strip $RPM_BUILD_ROOT%{l_prefix}/bin/*  >/dev/null 2>&1 || true
   203     strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
   204 %if "%{with_perl}" == "yes"
   205     find ${RPM_BUILD_ROOT}${l_prefix} -name .packlist -print | xargs rm -f
   206 %endif
   208     #   install run-command script
   209     %{l_shtool} mkdir -f -p -m 755 \
   210         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
   211     %{l_shtool} install -c -m 755 %{l_value -s -a} \
   212         %{SOURCE rc.snmp} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
   214     #   install OSSP fsl configuration
   215     %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
   216     %{l_shtool} install -c -m 644 %{l_value -s -a} \
   217         %{SOURCE fsl.snmp} \
   218         $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
   220     #   determine installation files
   221     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
   222         %{l_files_std} \
   223         '%config %{l_prefix}/etc/fsl/fsl.snmp' \
   224         '%config %{l_prefix}/etc/snmp/*.conf'
   226 %files -f files
   228 %clean
   230 %post
   231     #   after upgrade, restart service
   232     [ $1 -eq 2 ] || exit 0
   233     eval `%{l_rc} snmp status 2>/dev/null`
   234     [ ".$snmp_active" = .yes ] && %{l_rc} snmp restart
   235     exit 0
   237 %preun
   238     #   before erase, stop service and remove log files
   239     [ $1 -eq 0 ] || exit 0
   240     %{l_rc} snmp stop 2>/dev/null
   241     rm -f $RPM_INSTALL_PREFIX/var/snmp/*
   242     exit 0

mercurial