squid.spec 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. ##
  2. ## squid.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2006 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2006 Ralf S. Engelschall <http://engelschall.com/>
  5. ##
  6. ## Permission to use, copy, modify, and distribute this software for
  7. ## any purpose with or without fee is hereby granted, provided that
  8. ## the above copyright notice and this permission notice appear in all
  9. ## copies.
  10. ##
  11. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. ## SUCH DAMAGE.
  23. ##
  24. # package version
  25. %define V_maj 2
  26. %define V_min 6
  27. %define V_rev 5
  28. # package information
  29. Name: squid
  30. Summary: World Wide Web Proxy Server
  31. URL: http://www.squid-cache.org/
  32. Vendor: The Squid Project
  33. Packager: OpenPKG Foundation e.V.
  34. Distribution: OpenPKG Community
  35. Class: BASE
  36. Group: Web
  37. License: GPL
  38. Version: %{V_maj}.%{V_min}.%{V_rev}
  39. Release: 20061103
  40. # package options
  41. %option with_fsl yes
  42. %option with_ssl no
  43. %option with_snmp no
  44. %option with_ntlm no
  45. # list of sources
  46. Source0: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}.tar.gz
  47. Source1: rc.squid
  48. Source2: fsl.squid
  49. # build information
  50. Prefix: %{l_prefix}
  51. BuildRoot: %{l_buildroot}
  52. BuildPreReq: OpenPKG, openpkg >= 20060823, gcc, perl
  53. PreReq: OpenPKG, openpkg >= 20060823
  54. %if "%{with_fsl}" == "yes"
  55. BuildPreReq: fsl >= 1.3.0
  56. PreReq: fsl >= 1.3.0
  57. %endif
  58. %if "%{with_ssl}" == "yes"
  59. BuildPreReq: openssl
  60. PreReq: openssl
  61. %endif
  62. %if "%{with_ntlm}" == "yes"
  63. PreReq: samba
  64. %endif
  65. AutoReq: no
  66. AutoReqProv: no
  67. %description
  68. Squid is a full-featured Web proxy which supports proxying and
  69. caching of HTTP, FTP, and other URL's; proxying for SSL cache
  70. hierarchies; supporting ICP, HTCP, and CARP; supports Cache Digests
  71. transparent caching, etc.
  72. %track
  73. prog squid = {
  74. version = %{V_maj}.%{V_min}.STABLE%{V_rev}
  75. url = http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/
  76. regex = squid-(%{V_maj}\.\d+\.STABLE\d+)\.tar\.gz
  77. }
  78. %prep
  79. %setup -q -n squid-%{V_maj}.%{V_min}.STABLE%{V_rev}
  80. %if "%{with_ntlm}" == "yes"
  81. %{l_shtool} subst \
  82. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;' \
  83. -e 's;wbinfo;%{l_prefix}/bin/wbinfo;' \
  84. helpers/external_acl/wbinfo_group/wbinfo_group.pl
  85. %endif
  86. find . -name "*.orig" -print | xargs rm -f
  87. %build
  88. # configure package
  89. %{l_shtool} subst \
  90. -e 's;/cgi-bin/;/openpkg-cgi/;' \
  91. tools/cachemgr.c
  92. CC="%{l_cc}" \
  93. CFLAGS="%{l_cflags -O}" \
  94. CPPFLAGS="%{l_cppflags}" \
  95. LDFLAGS="%{l_fsl_ldflags}" \
  96. LIBS="%{l_fsl_libs}" \
  97. ./configure \
  98. --prefix=%{l_prefix} \
  99. --sysconfdir=%{l_prefix}/etc/squid \
  100. --libexecdir=%{l_prefix}/libexec/squid \
  101. --localstatedir=%{l_prefix}/var/squid \
  102. --datadir=%{l_prefix}/share/squid \
  103. %if "%{with_ssl}" == "yes"
  104. --enable-ssl \
  105. --with-openssl=%{l_prefix} \
  106. %endif
  107. %if "%{with_snmp}" == "yes"
  108. --enable-snmp \
  109. %endif
  110. %if "%{with_ntlm}" == "yes"
  111. --enable-auth="ntlm basic digest" \
  112. --enable-external-acl-helpers="wbinfo_group" \
  113. %else
  114. --enable-auth="basic digest" \
  115. %endif
  116. --enable-basic-auth-helpers="NCSA" \
  117. --enable-digest-auth-helpers="password" \
  118. --enable-default-err-language=English \
  119. --enable-err-languages=English \
  120. --enable-storeio="ufs diskd null" \
  121. --enable-removal-policies="lru heap" \
  122. --enable-cache-digests \
  123. --enable-forw-via-db \
  124. --enable-useragent-log \
  125. --enable-delay-pools \
  126. --enable-x-accelerator-vary \
  127. --enable-follow-x-forwarded-for
  128. # build package
  129. %{l_make} %{l_mflags}
  130. %install
  131. rm -rf $RPM_BUILD_ROOT
  132. # pregenerate some (not automatically created) installation directories
  133. %{l_shtool} mkdir -f -p -m 755 \
  134. $RPM_BUILD_ROOT%{l_prefix}/cgi \
  135. $RPM_BUILD_ROOT%{l_prefix}/etc/squid \
  136. $RPM_BUILD_ROOT%{l_prefix}/var/squid/logs \
  137. $RPM_BUILD_ROOT%{l_prefix}/var/squid/cache
  138. # install package
  139. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  140. # strip down installation
  141. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/Run*
  142. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/RunCache
  143. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/squid/*.default
  144. %if "%{with_snmp}" != "yes"
  145. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/squid/mib.txt
  146. %endif
  147. # move cache manager CGI to correct location
  148. mv $RPM_BUILD_ROOT%{l_prefix}/libexec/squid/cachemgr.cgi \
  149. $RPM_BUILD_ROOT%{l_prefix}/cgi/cachemgr.cgi
  150. # post-adjust default configuration
  151. %{l_shtool} subst \
  152. -e 's;^# \(cache_mgr\).*;\1 %{l_musr};' \
  153. -e 's;^# \(cache_effective_user\).*;\1 %{l_rusr};' \
  154. -e 's;^# \(cache_effective_group\).*;\1 %{l_rgrp};' \
  155. -e 's;^# \(http_port\).*;\1 127.0.0.1:3128;' \
  156. $RPM_BUILD_ROOT%{l_prefix}/etc/squid/squid.conf
  157. # install run-command script
  158. %{l_shtool} mkdir -f -p -m 755 \
  159. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  160. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  161. %{SOURCE rc.squid} \
  162. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  163. # install OSSP fsl configuration
  164. %{l_shtool} mkdir -f -p -m 755 \
  165. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  166. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  167. %{SOURCE fsl.squid} \
  168. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  169. # strip executables
  170. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  171. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  172. # determine installation files
  173. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  174. %{l_files_std} \
  175. '%config %{l_prefix}/etc/squid/squid.conf' \
  176. '%not %dir %{l_prefix}/etc/fsl' \
  177. '%config %{l_prefix}/etc/fsl/fsl.squid' \
  178. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/squid/*'
  179. %files -f files
  180. %clean
  181. rm -rf $RPM_BUILD_ROOT
  182. %post
  183. if [ $1 -eq 1 ]; then
  184. # initialize cache directory structure
  185. $RPM_INSTALL_PREFIX/sbin/squid -z >/dev/null 2>&1
  186. fi
  187. # after upgrade, restart service
  188. [ $1 -eq 2 ] || exit 0
  189. eval `%{l_rc} squid status 2>/dev/null`
  190. [ ".$squid_active" = .yes ] && %{l_rc} squid restart
  191. exit 0
  192. %preun
  193. # before erase, stop service and remove log files
  194. [ $1 -eq 0 ] || exit 0
  195. %{l_rc} squid stop 2>/dev/null
  196. rm -rf $RPM_INSTALL_PREFIX/var/squid/cache/[0-9ABCDEF][0-9ABCDEF] >/dev/null 2>&1 || true
  197. rm -rf $RPM_INSTALL_PREFIX/var/squid/logs/* >/dev/null 2>&1 || true
  198. exit 0