snmp.spec 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. # package information
  26. Name: snmp
  27. Summary: Simple Network Management Protocol (SNMP) Toolkit
  28. URL: http://www.net-snmp.org/
  29. Vendor: University of California Davis
  30. Packager: The OpenPKG Project
  31. Distribution: OpenPKG
  32. Class: BASE
  33. Group: Network
  34. License: BSD
  35. Version: 5.1.1
  36. Release: 20040810
  37. # package options
  38. %option with_fsl yes
  39. %option with_perl no
  40. %option with_mib_host no
  41. %option with_mib_smux no
  42. # version 5.1.1 mib modules tcpTable and udpTable are not yet complete
  43. # (they only build on BSD when patched and fail completely on NetBSD)
  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: snmpd.conf
  49. Source3: fsl.snmp
  50. Patch0: snmp.patch
  51. # build information
  52. Prefix: %{l_prefix}
  53. BuildRoot: %{l_buildroot}
  54. BuildPreReq: OpenPKG, openpkg >= 20040130, gcc
  55. PreReq: OpenPKG, openpkg >= 20040130
  56. BuildPreReq: openssl
  57. PreReq: openssl
  58. %if "%{with_fsl}" == "yes"
  59. BuildPreReq: fsl >= 1.2.0
  60. PreReq: fsl >= 1.2.0
  61. %endif
  62. %if "%{with_perl}" == "yes"
  63. BuildPreReq: perl
  64. PreReq: perl
  65. %endif
  66. AutoReq: no
  67. AutoReqProv: no
  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.
  74. %track
  75. prog snmp = {
  76. comment = "rse: 5.1: contains network structure fiddling which breaks under FreeBSD4"
  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. # adjust package for RPM support in Host MIB
  86. # (because OpenPKG RPM is a little bit different)
  87. %{l_shtool} subst \
  88. -e 's;/usr/include/rpm;%{l_prefix}/include/rpm;g' \
  89. -e 's;-lpopt\([^a-z]\);-lrpmpopt\1;g' \
  90. -e 's;db-3\.1;rpmdb;g' \
  91. -e 's;-lz\([^a-z]\);-lrpz\1;g' \
  92. -e 's;-lrpm\([^a-z]\);-lrpm -lrpmio\1;g' \
  93. -e 's;-lrpmio\([^a-z]\);-lrpmio -lrpmpopt -lrpmbz2 -lrpmz\1;g' \
  94. configure
  95. %{l_shtool} subst \
  96. -e 's;@OPENPKG_RPMRC@;"%{l_prefix}/etc/openpkg/rpmrc";' \
  97. agent/mibgroup/host/hr_swinst.c
  98. # adjust package for not requiring --enable-shared for --with-perl-modules
  99. # (because it technically working also with static libraries on most platforms)
  100. %{l_shtool} subst \
  101. -e 's/if test "x$enable_shared" != "xyes"; then/if false; then/g' \
  102. configure
  103. # adjust package to install Perl packages into RPM_BUILD_ROOT
  104. %{l_shtool} subst \
  105. -e "s;perl Makefile.PL;perl Makefile.PL PERL=$perl FULLPERL=$perl PREFIX=${RPM_BUILD_ROOT}%{l_prefix} INSTALLDIRS=vendor;g" \
  106. -e 's/cd perl ; $(MAKE))/cd perl ; $(MAKE) pure_all)/g' \
  107. -e 's/cd perl ; $(MAKE) install/cd perl ; $(MAKE) pure_install/g' \
  108. Makefile.in
  109. %build
  110. # disable search for db library
  111. ( echo "ac_cv_lib_db1_dbopen=no"
  112. echo "ac_cv_lib_db_dbopen=no"
  113. echo "ac_cv_lib_rpmdb_db_create=yes"
  114. echo "ac_cv_lib_db_3_0_db_create=no"
  115. ) >config.cache
  116. # determine additional MIBs to include
  117. mibs=""
  118. %if "%{with_mib_host}" == "yes"
  119. mibs="$mibs host"
  120. %endif
  121. %if "%{with_mib_smux}" == "yes"
  122. mibs="$mibs smux"
  123. %endif
  124. # use correct libraries for platform
  125. case "%{l_platform -t}" in
  126. *-hpux* ) loclibs="-lnm" ;;
  127. esac
  128. # configure package
  129. ./configure \
  130. --cache-file=./config.cache \
  131. --with-cc="%{l_cc}" \
  132. --with-cflags="%{l_cflags -O} %{l_cppflags}" \
  133. --with-ldflags="%{l_ldflags} %{l_fsl_ldflags}" \
  134. --with-libs="%{l_fsl_libs} $loclibs" \
  135. --prefix=%{l_prefix} \
  136. --with-persistent-directory=%{l_prefix}/var/snmp \
  137. --with-openssl=%{l_prefix} \
  138. --enable-silent-libtool \
  139. --disable-shared \
  140. %if "%{with_mib_host}" == "yes" || "%{with_mib_smux}" == "yes"
  141. --with-mib-modules="$mibs" \
  142. %endif
  143. %if "%{with_mib_tables}" == "no"
  144. --with-out-mib-modules="mibII/tcpTable mibII/udpTable" \
  145. %endif
  146. %if "%{with_perl}" == "yes"
  147. --with-perl-modules \
  148. --enable-embedded-perl \
  149. %endif
  150. --with-defaults
  151. # build package
  152. %{l_make} %{l_mflags} touchit
  153. %{l_make} %{l_mflags}
  154. %install
  155. rm -rf $RPM_BUILD_ROOT
  156. # install package
  157. %{l_shtool} subst -v \
  158. -e "s;^\\(prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
  159. -e "s;^\\(exec_prefix.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix};g" \
  160. -e "s;^\\(persistentdir.*=\\).*;\\1 $RPM_BUILD_ROOT%{l_prefix}/var/snmp;g" \
  161. `find . -type f -name Makefile -print`
  162. %{l_make} %{l_mflags} install
  163. # create additional directories
  164. %{l_shtool} mkdir -f -p -m 755 \
  165. $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
  166. $RPM_BUILD_ROOT%{l_prefix}/var/snmp \
  167. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  168. $RPM_BUILD_ROOT%{l_prefix}/etc/snmp
  169. # install default configuration
  170. %{l_shtool} install -c -m 644 \
  171. %{SOURCE snmpd.conf} \
  172. $RPM_BUILD_ROOT%{l_prefix}/etc/snmp/
  173. # strip down installation
  174. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
  175. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ipf-mod.pl
  176. ln $RPM_BUILD_ROOT%{l_prefix}/bin/snmptrap \
  177. $RPM_BUILD_ROOT%{l_prefix}/bin/snmpinform
  178. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  179. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  180. %if "%{with_perl}" == "yes"
  181. find ${RPM_BUILD_ROOT}${l_prefix} -name .packlist -print | xargs rm -f
  182. %endif
  183. # install run-command script
  184. %{l_shtool} mkdir -f -p -m 755 \
  185. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  186. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  187. %{SOURCE rc.snmp} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  188. # install OSSP fsl configuration
  189. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  190. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  191. %{SOURCE fsl.snmp} \
  192. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  193. # determine installation files
  194. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  195. %{l_files_std} \
  196. '%not %dir %{l_prefix}/etc/fsl' \
  197. '%config %{l_prefix}/etc/fsl/fsl.snmp' \
  198. '%config %{l_prefix}/etc/snmp/*.conf'
  199. %files -f files
  200. %clean
  201. rm -rf $RPM_BUILD_ROOT