squid.spec 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. ##
  2. ## squid.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2011 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 1
  26. %define V_rev 13
  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: 20110702
  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_ecap no
  47. %option with_esi no
  48. # list of sources
  49. Source0: http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/squid-%{V_maj}.%{V_min}.%{V_rev}.tar.gz
  50. Source1: rc.squid
  51. Source2: fsl.squid
  52. Patch0: squid.patch
  53. # build information
  54. BuildPreReq: OpenPKG, openpkg >= 20100101, gcc, gcc::with_cxx = yes, perl
  55. PreReq: OpenPKG, openpkg >= 20100101
  56. BuildPreReq: db, db::with_compat = yes
  57. PreReq: db, db::with_compat = yes
  58. %if "%{with_fsl}" == "yes"
  59. BuildPreReq: fsl
  60. PreReq: fsl
  61. %endif
  62. %if "%{with_ssl}" == "yes"
  63. BuildPreReq: openssl
  64. PreReq: openssl
  65. %endif
  66. %if "%{with_ntlm}" == "yes"
  67. PreReq: samba
  68. %endif
  69. %if "%{with_ecap}" == "yes"
  70. PreReq: libecap
  71. BuildPreReq: libecap
  72. %endif
  73. %description
  74. Squid is a full-featured Web proxy which supports proxying and
  75. caching of HTTP, FTP, and other URL's; proxying for SSL cache
  76. hierarchies; supporting ICP, HTCP, and CARP; supports Cache Digests
  77. transparent caching, etc.
  78. %track
  79. prog squid = {
  80. version = %{V_maj}.%{V_min}.%{V_rev}
  81. url = http://www.squid-cache.org/Versions/v%{V_maj}/%{V_maj}.%{V_min}/
  82. regex = squid-(%{V_maj}\.\d+(?:\.\d+)+)\.tar\.gz
  83. }
  84. %prep
  85. %setup -q -n squid-%{V_maj}.%{V_min}.%{V_rev}
  86. %patch -p0
  87. %if "%{with_ntlm}" == "yes"
  88. %{l_shtool} subst \
  89. -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;' \
  90. -e 's;wbinfo;%{l_prefix}/bin/wbinfo;' \
  91. helpers/external_acl/wbinfo_group/wbinfo_group.pl
  92. %endif
  93. find . -name "*.orig" -print | xargs rm -f
  94. %build
  95. # configure package
  96. %{l_shtool} subst \
  97. -e 's;/cgi-bin/;/openpkg-cgi/;' \
  98. tools/cachemgr.cc
  99. CC="%{l_cc}" \
  100. CFLAGS="%{l_cflags -O} -pthread" \
  101. CPPFLAGS="%{l_cppflags}" \
  102. LDFLAGS="%{l_fsl_ldflags} -pthread" \
  103. %if "%{with_ecap}" == "yes"
  104. LIBS="-lecap %{l_fsl_libs}" \
  105. %else
  106. LIBS="%{l_fsl_libs}" \
  107. %endif
  108. ./configure \
  109. --prefix=%{l_prefix} \
  110. --sysconfdir=%{l_prefix}/etc/squid \
  111. --libexecdir=%{l_prefix}/libexec/squid \
  112. --mandir=%{l_prefix}/man \
  113. --localstatedir=%{l_prefix}/var/squid \
  114. --datadir=%{l_prefix}/share/squid \
  115. %if "%{with_ssl}" == "yes"
  116. --enable-ssl \
  117. --with-openssl=%{l_prefix} \
  118. %endif
  119. %if "%{with_snmp}" == "yes"
  120. --enable-snmp \
  121. %endif
  122. %if "%{with_ntlm}" == "yes"
  123. --enable-auth="ntlm basic digest" \
  124. --enable-external-acl-helpers="wbinfo_group" \
  125. %else
  126. --enable-auth="basic digest" \
  127. %endif
  128. %if "%{with_largefile}" == "yes"
  129. --with-large-files \
  130. %endif
  131. %if "%{with_icap}" == "yes"
  132. --enable-icap-client \
  133. %endif
  134. %if "%{with_ecap}" == "yes"
  135. --enable-ecap \
  136. %endif
  137. %if "%{with_esi}" == "yes"
  138. --enable-esi \
  139. %endif
  140. --enable-basic-auth-helpers="NCSA" \
  141. --enable-digest-auth-helpers="password" \
  142. --enable-default-err-language=English \
  143. --enable-err-languages=English \
  144. --enable-storeio="ufs diskd" \
  145. --enable-removal-policies="lru heap" \
  146. --enable-cache-digests \
  147. --enable-forw-via-db \
  148. --enable-useragent-log \
  149. --enable-delay-pools \
  150. --enable-x-accelerator-vary \
  151. --enable-http-violations \
  152. --disable-strict-error-checking
  153. # build package
  154. %{l_make} %{l_mflags}
  155. %install
  156. # pregenerate some (not automatically created) installation directories
  157. %{l_shtool} mkdir -f -p -m 755 \
  158. $RPM_BUILD_ROOT%{l_prefix}/cgi \
  159. $RPM_BUILD_ROOT%{l_prefix}/etc/squid \
  160. $RPM_BUILD_ROOT%{l_prefix}/var/squid/logs \
  161. $RPM_BUILD_ROOT%{l_prefix}/var/squid/cache
  162. # install package
  163. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  164. # strip down installation
  165. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/Run*
  166. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/RunCache
  167. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/squid/*.default
  168. %if "%{with_snmp}" != "yes"
  169. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/squid/mib.txt
  170. %endif
  171. # move cache manager CGI to correct location
  172. mv $RPM_BUILD_ROOT%{l_prefix}/libexec/squid/cachemgr.cgi \
  173. $RPM_BUILD_ROOT%{l_prefix}/cgi/cachemgr.cgi
  174. # post-adjust default configuration
  175. %{l_shtool} subst \
  176. -e 's;^# \(cache_mgr\).*;\1 %{l_musr};' \
  177. -e 's;^# \(cache_effective_user\).*;\1 %{l_rusr};' \
  178. -e 's;^# \(cache_effective_group\).*;\1 %{l_rgrp};' \
  179. -e 's;^# \(http_port\).*;\1 127.0.0.1:3128;' \
  180. $RPM_BUILD_ROOT%{l_prefix}/etc/squid/squid.conf
  181. # install run-command script
  182. %{l_shtool} mkdir -f -p -m 755 \
  183. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  184. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  185. %{SOURCE rc.squid} \
  186. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  187. # install OSSP fsl configuration
  188. %{l_shtool} mkdir -f -p -m 755 \
  189. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  190. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  191. %{SOURCE fsl.squid} \
  192. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  193. # strip executables
  194. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  195. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  196. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/squid/* >/dev/null 2>&1 || true
  197. # determine installation files
  198. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  199. %{l_files_std} \
  200. '%config %{l_prefix}/etc/squid/squid.conf' \
  201. '%config %{l_prefix}/etc/fsl/fsl.squid' \
  202. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/squid/*'
  203. %files -f files
  204. %clean
  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