tor.spec.in 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. ## NOTE: tor.spec is autogenerated from tor.spec.in . Edit the latter,
  2. ## not the former.
  3. ## Things that need to be edited frequently
  4. #
  5. # This should be incremented whenever the spec file changes, but
  6. # can drop back to zero at a new Tor version
  7. %define specver 0
  8. ## Things users may want to change
  9. #
  10. # User (and group) name under which the Tor daemon runs
  11. %define runuser tordmn
  12. ## Version song and dance
  13. #
  14. # This should be the Tor version number, as it appears on the tarball,
  15. # including any "pre<x>" or "rc<y>" suffix. This gets massaged to
  16. # create the RPM version number, in a way that depends on the Tor
  17. # numbering scheme.
  18. %define native_version @VERSION@
  19. # Massage the version so that pre-releases will be treated as earlier
  20. # than release candidates which will be treated as earlier than released
  21. # versions.
  22. #
  23. # We do this as follows:
  24. # - If the version number has no "pre", "cvs", or "rc", we let it pass.
  25. # - Otherwise, we mangle it heavily:
  26. # * To make 0.0.Xpre come after 0.0.{X-1}* but before 0.0.X, we prepend
  27. # 0.0.{X-1}.99 to the version.
  28. # * We replace pre with .pre. and rc with .rc.
  29. # * We replace -cvs with .cvs, and lack of -cvs with .release.
  30. #
  31. # Note that this scheme will break if we ever use 0 as a last digit for a
  32. # Tor version: so don't do that.
  33. %define is_dev_version %(echo %{native_version} | grep 'cvs\\|pre\\|rc' > /dev/null && echo 1 || echo 0)
  34. %if %{is_dev_version}
  35. # The 0.0.X.pre.1.cvs part.
  36. %define safe_native_version %(echo %{native_version} | sed -e 's/-cvs/.cvs/' -e 's/pre/.pre./' -e 's/rc/.rc./' -e 's/\\([0-9]\\)$/\\1.release/')
  37. # The 0.0.X part -- the version we are leading up to.
  38. %define stub_version %(echo %{native_version} | sed -e 's/-cvs//' -e 's/pre.*//' -e 's/rc.*//')
  39. # The 0.0 part
  40. %define stub_start %(echo %{stub_version} | sed -e 's/\\.[0-9]*$//')
  41. # The X part.
  42. %define stub_last %(echo %{stub_version} | sed -e 's/.*\\.\\([0-9]*\\)$/\\1/')
  43. # The {X-1} part.
  44. %define stub_newlast %(expr %{stub_last} - 1)
  45. # The actual version: 0.0.{X-1}.99.0.0.X.pre.1.cvs
  46. %define version %{stub_start}.%{stub_newlast}.99.%{safe_native_version}
  47. %else
  48. %define version %{native_version}
  49. %endif
  50. ## Release and OS identification song and dance
  51. #
  52. # This identifies the lineage of the spec file. This file is the
  53. # standard one that comes with Tor; various distributions may
  54. # have their own ideas about the right ways to do things.
  55. %define pkgspec tor
  56. # This spec is intended to build and install on multiple distributions.
  57. # Detect the distribution we're building on.
  58. %define is_rh %(test -e /etc/redhat-release && echo 1 || echo 0)
  59. %define is_fc %(test -e /etc/fedora-release && echo 1 || echo 0)
  60. %define is_mdk %(test -e /etc/mandrake-release && echo 1 || echo 0)
  61. %define is_suse %(test -e /etc/SuSE-release && echo 1 || echo 0)
  62. %if %{is_fc}
  63. %define ostag %(sed -e 's/^.*release /fc/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/fedora-release)
  64. %else
  65. %if %{is_rh}
  66. %define ostag %(sed -e 's/^.*release /rh/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/redhat-release)
  67. %endif
  68. %endif
  69. # These are probably wrong... just placeholders should we actually
  70. # end up supporting these distributions
  71. %if %{is_mdk}
  72. %define ostag mdk
  73. %endif
  74. %if %{is_suse}
  75. %define ostag suse
  76. %endif
  77. # Using the build date ensures that every build really does get
  78. # a different release number.
  79. %define blddate %(date -u +"%Y%m%d%H%M")
  80. # ... and here it is.
  81. %define release %{pkgspec}.%{specver}.%{ostag}.%{blddate}
  82. ## General-purpose macros
  83. #
  84. # Some systems don't have some macros. If a macro doesn't seem
  85. # to exist on your system, add it here...
  86. %if %{!?__make:1}%{?__make:0}
  87. %define __make make
  88. %endif
  89. %if %{!?make:1}%{?make:0}
  90. %define make %{__make}
  91. %endif
  92. %if %{!?_localstatedir:1}%{?_localstatedir:0}
  93. %define _localstatedir @LOCALSTATEDIR@
  94. %endif
  95. ## Package information
  96. #
  97. Name: tor
  98. Version: %{version}
  99. Release: %{release}
  100. Summary: Anonymizing overlay network for TCP (The onion router)
  101. URL: http://freehaven.net/%{name}/
  102. Group: System Environment/Daemons
  103. License: BSD-like
  104. Vendor: R. Dingledine <arma@seul.org>
  105. Packager: Nick Mathewson <nickm@seul.org>
  106. Requires: openssl >= 0.9.6
  107. BuildRequires: openssl-devel >= 0.9.6, rpm-build >= 4.0
  108. Requires(pre): shadow-utils, /usr/bin/id, /bin/date, /bin/sh
  109. Requires(pre): %{_sbindir}/useradd, %{_sbindir}/groupadd
  110. Source0: http://freehaven.net/%{name}/dist/%{name}-%{native_version}.tar.gz
  111. BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
  112. %description
  113. Tor is a connection-based low-latency anonymous communication system.
  114. This package provides the "tor" program, which serves as both a client and
  115. a relay node. Scripts will automatically create a "%{runuser}" user and
  116. group, and set tor up to run as a daemon when the system is rebooted.
  117. Clients connect to their local Tor servers using the SOCKS5
  118. protocol. The local server chooses a path through a set of relays, in
  119. which each relay knows its predecessor and successor, but no
  120. others. Traffic flowing down the circuit is unwrapped by a symmetric
  121. key at each relay, which reveals the downstream node.
  122. Warnings: Tor does no protocol cleaning. That means there is a danger
  123. that application protocols and associated programs can be induced to
  124. reveal information about the initiator. Tor depends on Privoxy and
  125. similar protocol cleaners to solve this problem. This is alpha code,
  126. and is even more likely than released code to have anonymity-spoiling
  127. bugs. The present network is very small -- this further reduces the
  128. strength of the anonymity provided. Tor is not presently suitable
  129. for high-stakes anonymity.
  130. %prep
  131. %setup -q -n %{name}-%{native_version}
  132. # Patch the startup script to use the right user and group IDs. Force
  133. # the use of /bin/sh as the shell for the "tor" account.
  134. ed -s contrib/tor.sh.in << '/EOF/' > /dev/null
  135. ,s/^TORUSER=$/TORUSER=%{runuser}/
  136. ,s/^TORGROUP=$/TORGROUP=%{runuser}/
  137. ,s:/bin/su:/bin/su -s /bin/sh:
  138. #
  139. # Save and exit ed
  140. w
  141. q
  142. /EOF/
  143. %build
  144. %configure
  145. %make
  146. %install
  147. %makeinstall
  148. # Install init script.
  149. %__mkdir_p ${RPM_BUILD_ROOT}%{_initrddir}
  150. %__install -p -m 755 contrib/tor.sh ${RPM_BUILD_ROOT}%{_initrddir}/%{name}
  151. # Set up config file; "sample" file implements a basic user node.
  152. %__install -p -m 644 ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/torrc.sample ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/torrc
  153. # Create a logrotate file. This should really be a source file,
  154. # but hey...
  155. %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d
  156. %__cat > ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name} << /EOF/
  157. %{_localstatedir}/log/%{name} {
  158. missingok
  159. notifempty
  160. sharedscripts
  161. }
  162. /EOF/
  163. # Directories that don't have any preinstalled files
  164. %__mkdir_p -m 700 ${RPM_BUILD_ROOT}%{_localstatedir}/lib/%{name}
  165. %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/run/%{name}
  166. %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}
  167. %clean
  168. [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
  169. # These scripts are probably wrong for Mandrake or SuSe. They're certainly
  170. # wrong for Debian, but what are you doing using RPM on Debian?
  171. %pre
  172. [ -f %{_initrddir}/%{name} ] && /sbin/service %{name} stop
  173. if [ ! -n "`/usr/bin/id -g %{runuser} 2>/dev/null`" ]; then
  174. # One would like to default the GID, but doing that properly would
  175. # require thought.
  176. %{_sbindir}/groupadd %{runuser} 2> /dev/null
  177. fi
  178. if [ ! -n "`/usr/bin/id -u %{runuser} 2>/dev/null`" ]; then
  179. # One would also like to default the UID, but doing that properly would
  180. # also require thought.
  181. if [ -x /sbin/nologin ]; then
  182. %{_sbindir}/useradd -r -g %{runuser} -d / -s /sbin/nologin %{runuser} 2> /dev/null
  183. else
  184. %{_sbindir}/useradd -r -g %{runuser} -d / -s /bin/false %{runuser} 2> /dev/null
  185. fi
  186. fi
  187. exit 0
  188. %post
  189. /sbin/chkconfig --add %{name}
  190. exit 0
  191. %preun
  192. /sbin/chkconfig --del %{name}
  193. %__rm -f ${_localstatedir}/lib/%{name}/cached-directory
  194. %__rm -f ${_localstatedir}/lib/%{name}/bw_accounting
  195. %__rm -f ${_localstatedir}/lib/%{name}/control_auth_cookie
  196. %__rm -f ${_localstatedir}/lib/%{name}/router.desc
  197. %__rm -f ${_localstatedir}/lib/%{name}/fingerprint
  198. exit 0
  199. %files
  200. %defattr(-,root,root)
  201. %doc AUTHORS INSTALL LICENSE README ChangeLog doc/HACKING doc/TODO doc/FAQ
  202. %{_mandir}/man*/*
  203. %{_bindir}/tor
  204. %{_bindir}/torify
  205. %{_bindir}/tor-resolve
  206. %config %{_initrddir}/%{name}
  207. %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/logrotate.d/%{name}
  208. %dir %attr(0750,root,%{runuser}) %{_sysconfdir}/%{name}/
  209. %config(noreplace) %attr(0640,root,%{runuser}) %{_sysconfdir}/%{name}/*
  210. %attr(0700,%{runuser},%{runuser}) %dir %{_localstatedir}/lib/%{name}
  211. %attr(0750,%{runuser},%{runuser}) %dir %{_localstatedir}/run/%{name}
  212. %attr(0750,%{runuser},%{runuser}) %dir %{_localstatedir}/log/%{name}
  213. %changelog
  214. * Tue Nov 5 2004 John Bashinski <jbash@velvet.com>
  215. - Add skeletal support for multiple distributions
  216. - Even more ridiculous level of macro-ization
  217. - Modify version numbers so RPM can determine when it has a newer version
  218. - Return to including distribution name in package release number
  219. - Sharply trim description
  220. - Change user/group name from "tor" to "tordmn"; "tor" is a common
  221. given name (reported by Marius Hjelle)
  222. - Change group to "System Environment/Daemons" (suggested by Marius Hjelle)
  223. - Create logrotate file (suggested by Marius Hjelle)
  224. - Make Tor run as a user proxy by default (suggested by Marius Hjelle)
  225. - Autogenerate spec file from GNU autotools data, substituting version
  226. and whatnot
  227. - Be perhaps excessively paranoid with config file and directory modes
  228. - Remove auto-start and auto-stop at installation time; there's some kind
  229. of weird race going on, and it's arguably a bad thing anyway.
  230. * Mon Jun 06 2004 Nick Mathewson <nickm@freehaven.net> 0.0.7-0.std.0.1.rc2
  231. - Make spec file more happy with fc2 packaging
  232. * Sat Jan 17 2004 John Bashinski <jbash@velvet.com>
  233. - Basic spec file; tested with Red Hat 9.