squid.spec 7.6 KB

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