tor.spec.in 10 KB

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