snmp.spec 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. ##
  2. ## snmp.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2008 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. ##
  23. # package information
  24. Name: snmp
  25. Summary: Simple Network Management Protocol (SNMP) Toolkit
  26. URL: http://www.net-snmp.org/
  27. Vendor: The NET-SNMP Project
  28. Packager: OpenPKG Foundation e.V.
  29. Distribution: OpenPKG Community
  30. Class: BASE
  31. Group: Network
  32. License: BSD
  33. Version: 5.4.1.1
  34. Release: 20080610
  35. # package options
  36. %option with_fsl yes
  37. %option with_perl no
  38. %option with_shared no
  39. %option with_mib_host no
  40. %option with_mib_smux no
  41. %option with_mib_tables no
  42. %option with_mib_sendmail no
  43. # list of sources
  44. Source0: http://switch.dl.sourceforge.net/net-snmp/net-snmp-%{version}.tar.gz
  45. Source1: rc.snmp
  46. Source2: fsl.snmp
  47. Source3: snmpd.conf
  48. Source4: snmptrapd.conf
  49. Patch0: snmp.patch
  50. # build information
  51. Prefix: %{l_prefix}
  52. BuildRoot: %{l_buildroot}
  53. BuildPreReq: OpenPKG, openpkg >= 20060823, gcc
  54. PreReq: OpenPKG, openpkg >= 20060823
  55. BuildPreReq: openssl
  56. PreReq: openssl
  57. %if "%{with_fsl}" == "yes"
  58. BuildPreReq: fsl
  59. PreReq: fsl
  60. %endif
  61. %if "%{with_perl}" == "yes"
  62. BuildPreReq: perl
  63. PreReq: perl
  64. %endif
  65. AutoReq: no
  66. AutoReqProv: no
  67. %description
  68. This is a toolkit relating to the Simple Network Management Protocol
  69. (SNMP), including an extensible agent, an SNMP library, tools to
  70. request or set information from SNMP agents, tools to generate and
  71. handle SNMP traps, a version of the unix 'netstat' command using
  72. SNMP, etc.
  73. %track
  74. prog snmp = {
  75. version = %{version}
  76. url = http://prdownloads.sourceforge.net/net-snmp/
  77. regex = net-snmp-(\d+\.\d+\.\d+[a-z]?)\.tar\.gz
  78. }
  79. %prep
  80. # unpack and patch package
  81. %setup -q -n net-snmp-%{version}
  82. %patch -p0
  83. # provide a default PID file location
  84. %{l_shtool} subst \
  85. -e 's;\(pid_file =\) NULL;\1 "%{l_prefix}/var/snmp/snmpd.pid";' \
  86. agent/snmpd.c
  87. %{l_shtool} subst \
  88. -e 's;\(pid_file =\) NULL;\1 "%{l_prefix}/var/snmp/snmptrapd.pid";' \
  89. apps/snmptrapd.c
  90. # adjust package for RPM support in Host MIB
  91. # (because OpenPKG RPM is a little bit different)
  92. %{l_shtool} subst \
  93. -e 's;/usr/include/rpm;%{l_prefix}/include/rpm;g' \
  94. -e 's;-lpopt\([^a-z]\);-lrpmpopt\1;g' \
  95. -e 's;db-3\.1;rpmdb;g' \
  96. -e 's;-lz\([^a-z]\);-lrpz\1;g' \
  97. -e 's;-lrpm\([^a-z]\);-lrpm -lrpmio\1;g' \
  98. -e 's;-lrpmio\([^a-z]\);-lrpmio -lrpmpopt -lrpmbz2 -lrpmz\1;g' \
  99. configure
  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
  105. # adjust package to install Perl packages into RPM_BUILD_ROOT
  106. %{l_shtool} subst \
  107. -e "s;perl Makefile.PL;perl Makefile.PL PERL=$perl FULLPERL=$perl PREFIX=${RPM_BUILD_ROOT}%{l_prefix} INSTALLDIRS=vendor;g" \
  108. -e 's/cd perl ; $(MAKE))/cd perl ; $(MAKE) pure_all)/g' \
  109. -e 's/cd perl ; $(MAKE) install/cd perl ; $(MAKE) pure_install/g' \
  110. Makefile.in
  111. %build
  112. # disable search for db library
  113. ( echo "ac_cv_lib_db1_dbopen=no"
  114. echo "ac_cv_lib_db_dbopen=no"
  115. echo "ac_cv_lib_rpmdb_db_create=yes"
  116. echo "ac_cv_lib_db_3_0_db_create=no"
  117. ) >config.cache
  118. # determine additional MIBs to include
  119. mibs=""
  120. %if "%{with_mib_host}" == "yes"
  121. mibs="$mibs host"
  122. %endif
  123. %if "%{with_mib_smux}" == "yes"
  124. mibs="$mibs smux"
  125. %endif
  126. %if "%{with_mib_sendmail}" == "yes"
  127. mibs="$mibs mibII/mta_sendmail"
  128. %endif
  129. # use correct libraries for platform
  130. case "%{l_platform -t}" in
  131. *-hpux* ) loclibs="-lnm" ;;
  132. esac
  133. # configure package
  134. ./configure \
  135. --cache-file=./config.cache \
  136. --with-cc="%{l_cc}" \
  137. --with-cflags="%{l_cflags -O} %{l_cppflags}" \
  138. --with-ldflags="%{l_ldflags} %{l_fsl_ldflags}" \
  139. --with-libs="%{l_fsl_libs} $loclibs" \
  140. --prefix=%{l_prefix} \
  141. --with-logfile=/dev/null \
  142. --with-persistent-directory=%{l_prefix}/var/snmp \
  143. --with-openssl=%{l_prefix} \
  144. --enable-silent-libtool \
  145. %if "%{with_shared}" == "no"
  146. --disable-shared \
  147. %endif
  148. %if "%{with_mib_host}" == "yes" || "%{with_mib_smux}" == "yes" || "%{with_mib_sendmail}" == "yes"
  149. --with-mib-modules="$mibs" \
  150. %endif
  151. %if "%{with_mib_tables}" == "no"
  152. --with-out-mib-modules="mibII/tcpTable mibII/udpTable" \
  153. %endif
  154. %if "%{with_perl}" == "yes"
  155. --with-perl-modules \
  156. --enable-embedded-perl \
  157. %else
  158. --without-perl-modules \
  159. --disable-embedded-perl \
  160. %endif
  161. --with-defaults
  162. # build package
  163. %{l_make} %{l_mflags} touchit
  164. %{l_make} %{l_mflags}
  165. %install
  166. rm -rf $RPM_BUILD_ROOT
  167. # install package
  168. %{l_shtool} subst -v \
  169. -e "s;^\\(prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
  170. -e "s;^\\(exec_prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
  171. -e "s;^\\(persistentdir.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/var/snmp;g" \
  172. `find . -type f -name Makefile -print`
  173. %{l_make} %{l_mflags} install
  174. # create additional directories
  175. %{l_shtool} mkdir -f -p -m 755 \
  176. $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
  177. $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
  178. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  179. $RPM_BUILD_ROOT%{l_prefix}/etc/snmp
  180. # install default configuration
  181. %{l_shtool} install -c -m 644 \
  182. %{SOURCE snmpd.conf} %{SOURCE snmptrapd.conf} \
  183. $RPM_BUILD_ROOT%{l_prefix}/etc/snmp/
  184. # strip down installation
  185. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
  186. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ipf-mod.pl
  187. ln $RPM_BUILD_ROOT%{l_prefix}/bin/snmptrap \
  188. $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
  189. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  190. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  191. %if "%{with_perl}" == "yes"
  192. find ${RPM_BUILD_ROOT}${l_prefix} -name .packlist -print | xargs rm -f
  193. %endif
  194. # install run-command script
  195. %{l_shtool} mkdir -f -p -m 755 \
  196. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  197. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  198. %{SOURCE rc.snmp} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  199. # install OSSP fsl configuration
  200. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  201. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  202. %{SOURCE fsl.snmp} \
  203. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  204. # determine installation files
  205. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  206. %{l_files_std} \
  207. '%config %{l_prefix}/etc/fsl/fsl.snmp' \
  208. '%config %{l_prefix}/etc/snmp/*.conf'
  209. %files -f files
  210. %clean
  211. rm -rf $RPM_BUILD_ROOT
  212. %post
  213. # after upgrade, restart service
  214. [ $1 -eq 2 ] || exit 0
  215. eval `%{l_rc} snmp status 2>/dev/null`
  216. [ ".$snmp_active" = .yes ] && %{l_rc} snmp restart
  217. exit 0
  218. %preun
  219. # before erase, stop service and remove log files
  220. [ $1 -eq 0 ] || exit 0
  221. %{l_rc} snmp stop 2>/dev/null
  222. rm -f $RPM_INSTALL_PREFIX/var/snmp/*
  223. exit 0