squid.spec 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. ##
  2. ## squid.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2008 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 8
  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: 20080904
  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. # build package
  140. %{l_make} %{l_mflags}
  141. %install
  142. rm -rf $RPM_BUILD_ROOT
  143. # pregenerate some (not automatically created) installation directories
  144. %{l_shtool} mkdir -f -p -m 755 \
  145. $RPM_BUILD_ROOT%{l_prefix}/cgi \
  146. $RPM_BUILD_ROOT%{l_prefix}/etc/squid \
  147. $RPM_BUILD_ROOT%{l_prefix}/var/squid/logs \
  148. $RPM_BUILD_ROOT%{l_prefix}/var/squid/cache
  149. # install package
  150. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  151. # strip down installation
  152. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/Run*
  153. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/RunCache
  154. rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/squid/*.default
  155. %if "%{with_snmp}" != "yes"
  156. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/squid/mib.txt
  157. %endif
  158. # move cache manager CGI to correct location
  159. mv $RPM_BUILD_ROOT%{l_prefix}/libexec/squid/cachemgr.cgi \
  160. $RPM_BUILD_ROOT%{l_prefix}/cgi/cachemgr.cgi
  161. # post-adjust default configuration
  162. %{l_shtool} subst \
  163. -e 's;^# \(cache_mgr\).*;\1 %{l_musr};' \
  164. -e 's;^# \(cache_effective_user\).*;\1 %{l_rusr};' \
  165. -e 's;^# \(cache_effective_group\).*;\1 %{l_rgrp};' \
  166. -e 's;^# \(http_port\).*;\1 127.0.0.1:3128;' \
  167. $RPM_BUILD_ROOT%{l_prefix}/etc/squid/squid.conf
  168. # install run-command script
  169. %{l_shtool} mkdir -f -p -m 755 \
  170. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  171. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  172. %{SOURCE rc.squid} \
  173. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  174. # install OSSP fsl configuration
  175. %{l_shtool} mkdir -f -p -m 755 \
  176. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  177. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  178. %{SOURCE fsl.squid} \
  179. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  180. # strip executables
  181. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  182. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  183. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/squid/* >/dev/null 2>&1 || true
  184. # determine installation files
  185. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  186. %{l_files_std} \
  187. '%config %{l_prefix}/etc/squid/squid.conf' \
  188. '%config %{l_prefix}/etc/fsl/fsl.squid' \
  189. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/squid/*'
  190. %files -f files
  191. %clean
  192. rm -rf $RPM_BUILD_ROOT
  193. %post
  194. if [ $1 -eq 1 ]; then
  195. # initialize cache directory structure
  196. $RPM_INSTALL_PREFIX/sbin/squid -z >/dev/null 2>&1
  197. fi
  198. # after upgrade, restart service
  199. [ $1 -eq 2 ] || exit 0
  200. eval `%{l_rc} squid status 2>/dev/null`
  201. [ ".$squid_active" = .yes ] && %{l_rc} squid restart
  202. exit 0
  203. %preun
  204. # before erase, stop service and remove log files
  205. [ $1 -eq 0 ] || exit 0
  206. %{l_rc} squid stop 2>/dev/null
  207. rm -rf $RPM_INSTALL_PREFIX/var/squid/cache/[0-9ABCDEF][0-9ABCDEF] >/dev/null 2>&1 || true
  208. rm -rf $RPM_INSTALL_PREFIX/var/squid/logs/* >/dev/null 2>&1 || true
  209. exit 0