squid.spec 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. ##
  2. ## squid.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 version
  26. %define V_maj 2
  27. %define V_min 5
  28. %define V_rev 6
  29. # package information
  30. Name: squid
  31. Summary: World Wide Web Proxy Server
  32. URL: http://www.squid-cache.org/
  33. Vendor: The Squid Project
  34. Packager: The OpenPKG Project
  35. Distribution: OpenPKG
  36. Class: BASE
  37. Group: Web
  38. License: GPL
  39. Version: %{V_maj}.%{V_min}.%{V_rev}
  40. Release: 20040829
  41. # package options
  42. %option with_fsl yes
  43. %option with_ssl no
  44. %option with_snmp no
  45. %option with_ntlm no
  46. %option with_icap no
  47. # list of sources
  48. Source0: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}.tar.gz
  49. Source1: rc.squid
  50. Source2: fsl.squid
  51. Patch0: ftp://ftp.openpkg.org/sources/CPY/squid/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-icap.patch
  52. Patch1: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-heap_segfault.patch
  53. Patch2: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-errorpage_quote.patch
  54. Patch3: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-ntlmtruncated.patch
  55. Patch4: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-client_db_gc.patch
  56. Patch5: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-active_requests_delaypool.patch
  57. Patch6: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-basic_auth_caseinsensitive.patch
  58. Patch7: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-ufs_create_error.patch
  59. Patch8: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-HEAD.patch
  60. Patch9: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-partial_hit_is_miss.patch
  61. Patch10: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-request_header_max_size.patch
  62. Patch11: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-concurrent_dns_lookups.patch
  63. Patch12: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-ldap_helpers.patch
  64. Patch13: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-ufs_no_valid_dir.patch
  65. Patch14: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-digest_crash.patch
  66. Patch15: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-ntlm_fetch_string.patch
  67. Patch16: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/bugs/squid-%{V_maj}.%{V_min}.STABLE%{V_rev}-ntlm_noreuse_leak.patch
  68. # build information
  69. Prefix: %{l_prefix}
  70. BuildRoot: %{l_buildroot}
  71. BuildPreReq: OpenPKG, openpkg >= 20040130, gcc, perl
  72. PreReq: OpenPKG, openpkg >= 20040130
  73. %if "%{with_fsl}" == "yes"
  74. BuildPreReq: fsl >= 1.3.0
  75. PreReq: fsl >= 1.3.0
  76. %endif
  77. %if "%{with_ssl}" == "yes"
  78. BuildPreReq: openssl
  79. PreReq: openssl
  80. %endif
  81. %if "%{with_ntlm}" == "yes"
  82. PreReq: samba
  83. %endif
  84. AutoReq: no
  85. AutoReqProv: no
  86. %description
  87. Squid is a full-featured Web proxy which supports proxying and
  88. caching of HTTP, FTP, and other URL's; proxying for SSL cache
  89. hierarchies; supporting ICP, HTCP, and CARP; supports Cache Digests
  90. transparent caching, etc.
  91. %track
  92. prog squid = {
  93. version = %{V_maj}.%{V_min}.STABLE%{V_rev}
  94. url = http://www.squid-cache.org/Versions/v2/2.5/
  95. regex = squid-(2\.\d+\.STABLE\d+)\.tar\.gz
  96. }
  97. %prep
  98. %setup -q -n squid-%{V_maj}.%{V_min}.STABLE%{V_rev}
  99. %patch -p1 -P 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  100. %if "%{with_icap}" == "yes"
  101. %patch -p0 -P 0
  102. find . -name "*.orig" -print | xargs rm -f
  103. %endif
  104. %if "%{with_ntlm}" == "yes"
  105. %{l_shtool} subst \
  106. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;' \
  107. -e 's;wbinfo;%{l_prefix}/bin/wbinfo;' \
  108. helpers/external_acl/wbinfo_group/wbinfo_group.pl
  109. %endif
  110. %build
  111. # configure package
  112. %{l_shtool} subst \
  113. -e 's;/cgi-bin/;/openpkg-cgi/;' \
  114. src/cachemgr.c
  115. CC="%{l_cc}" \
  116. CFLAGS="%{l_cflags -O}" \
  117. CPPFLAGS="%{l_cppflags}" \
  118. LDFLAGS="%{l_fsl_ldflags}" \
  119. LIBS="%{l_fsl_libs}" \
  120. ./configure \
  121. --prefix=%{l_prefix} \
  122. --sysconfdir=%{l_prefix}/etc/squid \
  123. --libexecdir=%{l_prefix}/libexec/squid \
  124. --localstatedir=%{l_prefix}/var/squid \
  125. --datadir=%{l_prefix}/share/squid \
  126. %if "%{with_ssl}" == "yes"
  127. --enable-ssl \
  128. --with-openssl=%{l_prefix} \
  129. %endif
  130. %if "%{with_snmp}" == "yes"
  131. --enable-snmp \
  132. %endif
  133. %if "%{with_icap}" == "yes"
  134. --enable-icap-support \
  135. %endif
  136. %if "%{with_ntlm}" == "yes"
  137. --enable-auth="ntlm basic digest" \
  138. --enable-external-acl-helpers="wbinfo_group" \
  139. %else
  140. --enable-auth="basic digest" \
  141. %endif
  142. --enable-default-err-language=English \
  143. --enable-err-languages=English \
  144. --enable-storeio="ufs diskd null" \
  145. --enable-removal-policies="lru heap" \
  146. --enable-cache-digests \
  147. --enable-forw-via-db \
  148. --enable-useragent-log \
  149. --enable-delay-pools
  150. # build package
  151. %{l_make} %{l_mflags}
  152. %install
  153. rm -rf $RPM_BUILD_ROOT
  154. # pregenerate some (not automatically created) installation directories
  155. %{l_shtool} mkdir -f -p -m 755 \
  156. $RPM_BUILD_ROOT%{l_prefix}/cgi \
  157. $RPM_BUILD_ROOT%{l_prefix}/etc/squid \
  158. $RPM_BUILD_ROOT%{l_prefix}/var/squid/logs \
  159. $RPM_BUILD_ROOT%{l_prefix}/var/squid/cache
  160. # install package
  161. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  162. # strip down installation
  163. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/Run*
  164. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/RunCache
  165. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/squid/*.default
  166. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/squid/*.orig
  167. %if "%{with_snmp}" != "yes"
  168. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/squid/mib.txt
  169. %endif
  170. # move cache manager CGI to correct location
  171. mv $RPM_BUILD_ROOT%{l_prefix}/libexec/squid/cachemgr.cgi \
  172. $RPM_BUILD_ROOT%{l_prefix}/cgi/cachemgr.cgi
  173. # post-adjust default configuration
  174. %{l_shtool} subst \
  175. -e 's;^# \(cache_mgr\).*;\1 %{l_musr};' \
  176. -e 's;^# \(cache_effective_user\).*;\1 %{l_rusr};' \
  177. -e 's;^# \(cache_effective_group\).*;\1 %{l_rgrp};' \
  178. -e 's;^# \(http_port\).*;\1 127.0.0.1:3128;' \
  179. $RPM_BUILD_ROOT%{l_prefix}/etc/squid/squid.conf
  180. # install run-command script
  181. %{l_shtool} mkdir -f -p -m 755 \
  182. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  183. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  184. %{SOURCE rc.squid} \
  185. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  186. # install OSSP fsl configuration
  187. %{l_shtool} mkdir -f -p -m 755 \
  188. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  189. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  190. %{SOURCE fsl.squid} \
  191. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  192. # strip executables
  193. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  194. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  195. # determine installation files
  196. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  197. %{l_files_std} \
  198. '%config %{l_prefix}/etc/squid/squid.conf' \
  199. '%not %dir %{l_prefix}/etc/fsl' \
  200. '%config %{l_prefix}/etc/fsl/fsl.squid' \
  201. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/squid/*'
  202. %files -f files
  203. %clean
  204. rm -rf $RPM_BUILD_ROOT
  205. %post
  206. if [ $1 -eq 1 ]; then
  207. # initialize cache directory structure
  208. $RPM_INSTALL_PREFIX/sbin/squid -z >/dev/null 2>&1
  209. fi
  210. # after upgrade, restart service
  211. [ $1 -eq 2 ] || exit 0
  212. eval `%{l_rc} squid status 2>/dev/null`
  213. [ ".$squid_active" = .yes ] && %{l_rc} squid restart
  214. exit 0
  215. %preun
  216. # before erase, stop service and remove log files
  217. [ $1 -eq 0 ] || exit 0
  218. %{l_rc} squid stop 2>/dev/null
  219. rm -rf $RPM_INSTALL_PREFIX/var/squid/cache/[0-9ABCDEF][0-9ABCDEF] >/dev/null 2>&1 || true
  220. rm -rf $RPM_INSTALL_PREFIX/var/squid/logs/* >/dev/null 2>&1 || true
  221. exit 0