tor.spec.in 13 KB

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