tor.spec.in 8.8 KB

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