snmp.spec 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. ##
  2. ## snmp.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2004 The OpenPKG Project <http://www.openpkg.org/>
  4. ## Copyright (c) 2000-2004 Ralf S. Engelschall <rse@engelschall.com>
  5. ## Copyright (c) 2000-2004 Cable & Wireless <http://www.cw.com/>
  6. ##
  7. ## Permission to use, copy, modify, and distribute this software for
  8. ## any purpose with or without fee is hereby granted, provided that
  9. ## the above copyright notice and this permission notice appear in all
  10. ## copies.
  11. ##
  12. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. ## SUCH DAMAGE.
  24. ##
  25. # FIXME: ms: version 5.1.1 mib modules tcpTable and udpTable are not yet complete
  26. # FIXME: ms: (they only build on BSD when patched and fail completely on NetBSD)
  27. # package information
  28. Name: snmp
  29. Summary: Simple Network Management Protocol (SNMP) Toolkit
  30. URL: http://www.net-snmp.org/
  31. Vendor: University of California Davis
  32. Packager: The OpenPKG Project
  33. Distribution: OpenPKG
  34. Class: BASE
  35. Group: Network
  36. License: BSD
  37. Version: 5.1.2
  38. Release: 20041119
  39. # package options
  40. %option with_fsl yes
  41. %option with_perl no
  42. %option with_mib_host no
  43. %option with_mib_smux no
  44. %option with_mib_tables no
  45. # list of sources
  46. Source0: http://osdn.dl.sourceforge.net/net-snmp/net-snmp-%{version}.tar.gz
  47. Source1: rc.snmp
  48. Source2: fsl.snmp
  49. Source3: snmpd.conf
  50. Source4: snmptrapd.conf
  51. Patch0: snmp.patch
  52. # build information
  53. Prefix: %{l_prefix}
  54. BuildRoot: %{l_buildroot}
  55. BuildPreReq: OpenPKG, openpkg >= 20040130, gcc
  56. PreReq: OpenPKG, openpkg >= 20040130
  57. BuildPreReq: openssl
  58. PreReq: openssl
  59. %if "%{with_fsl}" == "yes"
  60. BuildPreReq: fsl >= 1.2.0
  61. PreReq: fsl >= 1.2.0
  62. %endif
  63. %if "%{with_perl}" == "yes"
  64. BuildPreReq: perl
  65. PreReq: perl
  66. %endif
  67. AutoReq: no
  68. AutoReqProv: no
  69. %description
  70. This is a toolkit relating to the Simple Network Management Protocol
  71. (SNMP), including an extensible agent, an SNMP library, tools to
  72. request or set information from SNMP agents, tools to generate and
  73. handle SNMP traps, a version of the unix 'netstat' command using
  74. SNMP, etc.
  75. %track
  76. prog snmp = {
  77. version = %{version}
  78. url = http://prdownloads.sourceforge.net/net-snmp/
  79. regex = net-snmp-(\d+\.\d+\.\d+[a-z]?)\.tar\.gz
  80. }
  81. %prep
  82. # unpack and patch package
  83. %setup -q -n net-snmp-%{version}
  84. %patch -p0
  85. # provide a default PID file location
  86. %{l_shtool} subst \
  87. -e 's;\(pid_file =\) NULL;\1 "%{l_prefix}/var/snmp/snmpd.pid";' \
  88. agent/snmpd.c
  89. %{l_shtool} subst \
  90. -e 's;\(pid_file =\) NULL;\1 "%{l_prefix}/var/snmp/snmptrapd.pid";' \
  91. 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
  102. # adjust package for not requiring --enable-shared for --with-perl-modules
  103. # (because it technically working also with static libraries on most platforms)
  104. %{l_shtool} subst \
  105. -e 's/if test "x$enable_shared" != "xyes"; then/if false; then/g' \
  106. configure
  107. # adjust package to install Perl packages into RPM_BUILD_ROOT
  108. %{l_shtool} subst \
  109. -e "s;perl Makefile.PL;perl Makefile.PL PERL=$perl FULLPERL=$perl PREFIX=${RPM_BUILD_ROOT}%{l_prefix} INSTALLDIRS=vendor;g" \
  110. -e 's/cd perl ; $(MAKE))/cd perl ; $(MAKE) pure_all)/g' \
  111. -e 's/cd perl ; $(MAKE) install/cd perl ; $(MAKE) pure_install/g' \
  112. Makefile.in
  113. %build
  114. # disable search for db library
  115. ( echo "ac_cv_lib_db1_dbopen=no"
  116. echo "ac_cv_lib_db_dbopen=no"
  117. echo "ac_cv_lib_rpmdb_db_create=yes"
  118. echo "ac_cv_lib_db_3_0_db_create=no"
  119. ) >config.cache
  120. # determine additional MIBs to include
  121. mibs=""
  122. %if "%{with_mib_host}" == "yes"
  123. mibs="$mibs host"
  124. %endif
  125. %if "%{with_mib_smux}" == "yes"
  126. mibs="$mibs smux"
  127. %endif
  128. # use correct libraries for platform
  129. case "%{l_platform -t}" in
  130. *-hpux* ) loclibs="-lnm" ;;
  131. esac
  132. # configure package
  133. ./configure \
  134. --cache-file=./config.cache \
  135. --with-cc="%{l_cc}" \
  136. --with-cflags="%{l_cflags -O} %{l_cppflags}" \
  137. --with-ldflags="%{l_ldflags} %{l_fsl_ldflags}" \
  138. --with-libs="%{l_fsl_libs} $loclibs" \
  139. --prefix=%{l_prefix} \
  140. --with-persistent-directory=%{l_prefix}/var/snmp \
  141. --with-openssl=%{l_prefix} \
  142. --enable-silent-libtool \
  143. --disable-shared \
  144. %if "%{with_mib_host}" == "yes" || "%{with_mib_smux}" == "yes"
  145. --with-mib-modules="$mibs" \
  146. %endif
  147. %if "%{with_mib_tables}" == "no"
  148. --with-out-mib-modules="mibII/tcpTable mibII/udpTable" \
  149. %endif
  150. %if "%{with_perl}" == "yes"
  151. --with-perl-modules \
  152. --enable-embedded-perl \
  153. %endif
  154. --with-defaults
  155. # build package
  156. %{l_make} %{l_mflags} touchit
  157. %{l_make} %{l_mflags}
  158. %install
  159. rm -rf $RPM_BUILD_ROOT
  160. # install package
  161. %{l_shtool} subst -v \
  162. -e "s;^\\(prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
  163. -e "s;^\\(exec_prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
  164. -e "s;^\\(persistentdir.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/var/snmp;g" \
  165. `find . -type f -name Makefile -print`
  166. %{l_make} %{l_mflags} install
  167. # create additional directories
  168. %{l_shtool} mkdir -f -p -m 755 \
  169. $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
  170. $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
  171. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  172. $RPM_BUILD_ROOT%{l_prefix}/etc/snmp
  173. # install default configuration
  174. %{l_shtool} install -c -m 644 \
  175. %{SOURCE snmpd.conf} %{SOURCE snmptrapd.conf} \
  176. $RPM_BUILD_ROOT%{l_prefix}/etc/snmp/
  177. # strip down installation
  178. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
  179. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ipf-mod.pl
  180. ln $RPM_BUILD_ROOT%{l_prefix}/bin/snmptrap \
  181. $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
  182. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  183. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  184. %if "%{with_perl}" == "yes"
  185. find ${RPM_BUILD_ROOT}${l_prefix} -name .packlist -print | xargs rm -f
  186. %endif
  187. # install run-command script
  188. %{l_shtool} mkdir -f -p -m 755 \
  189. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  190. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  191. %{SOURCE rc.snmp} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  192. # install OSSP fsl configuration
  193. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  194. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  195. %{SOURCE fsl.snmp} \
  196. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  197. # determine installation files
  198. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  199. %{l_files_std} \
  200. '%not %dir %{l_prefix}/etc/fsl' \
  201. '%config %{l_prefix}/etc/fsl/fsl.snmp' \
  202. '%config %{l_prefix}/etc/snmp/*.conf'
  203. %files -f files
  204. %clean
  205. rm -rf $RPM_BUILD_ROOT
  206. %post
  207. # after upgrade, restart service
  208. [ $1 -eq 2 ] || exit 0
  209. eval `%{l_rc} snmp status 2>/dev/null`
  210. [ ".$snmp_active" = .yes ] && %{l_rc} snmp restart
  211. exit 0
  212. %preun
  213. # before erase, stop service and remove log files
  214. [ $1 -eq 0 ] || exit 0
  215. %{l_rc} snmp stop 2>/dev/null
  216. rm -f $RPM_INSTALL_PREFIX/var/snmp/*
  217. exit 0