fix punctuation in logs
[tor.git] / tor.spec.in
blobb452c9bb35b68e7b91f0f94677c39181c9c1e0b8
1 ## NOTE: tor.spec is autogenerated from tor.spec.in . Edit the latter,
2 ## not the former.
4 ## Things that need to be edited frequently
6 # This should be incremented whenever the spec file changes, but
7 # can drop back to zero at a new Tor version
9 %define specver 1
11 ## Things users may want to change
13 # User (and group) name under which the Tor daemon runs.
15 %define toruser @TORUSER@
16 %define torgroup @TORGROUP@
18 ## Version song and dance
20 # This should be the Tor version number, as it appears on the tarball,
21 # including any "pre<x>" or "rc<y>" suffix. This gets massaged to
22 # create the RPM version number, in a way that depends on the Tor
23 # numbering scheme.
24 %define native_version @VERSION@
26 %define version %(echo %{native_version} | sed -e 's/-/./g')
28 ## Define output filename
30 # This creates filenames based upon the value of target_cpu defined above
32 ## Release and OS identification song and dance
34 # This identifies the lineage of the spec file. This file is the
35 # standard one that comes with Tor; various distributions may
36 # have their own ideas about the right ways to do things.
37 %define pkgspec tor
39 # This spec is intended to build and install on multiple distributions
40 # (someday). Detect the distribution we're building on.
42 %define is_rh %(test -e /etc/redhat-release && echo 1 || echo 0)
43 %define is_fc %(test -e /etc/fedora-release && echo 1 || echo 0)
44 %define is_mdk %(test -e /etc/mandrake-release && echo 1 || echo 0)
45 %define is_suse %(test -e /etc/SuSE-release && echo 1 || echo 0)
46 %define is_rfl %(test -e /etc/redflag-release && echo 1 || echo 0)
48 %if %{is_fc}
49 %define ostag %(sed -e 's/^.*release /fc/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/fedora-release)
50 %endif
52 %if %{is_rh}
53 %define ostag %(sed -e 's/^.*release /rh/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/redhat-release)
54 %endif
56 %if %{is_mdk}
57 %define ostag mdk
58 %endif
60 %if %{is_suse}
61 %define ostag suse%(grep openSUSE /etc/SuSE-release | awk '{print $2}' | sed -e 's/\\./_/')
62 %endif
64 %if %{is_rfl}
65 %define ostag %(sed -e 's/^.*Desktop /redflag/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/redflag-release)
66 %endif
68 # Using the build date ensures that every build really does get
69 # a different release number. We use this trick for CVS versions.
70 # For release versions, we don't want or need it.
71 %define is_dev_version %(echo %{native_version} | grep 'dev' > /dev/null && echo 1 || echo 0)
73 %if %{is_dev_version}
74 %define blddate %(date -u +"%Y%m%d%H%M")
75 %define release %{pkgspec}.%{specver}.%{ostag}.%{blddate}
76 %else
77 %define release %{pkgspec}.%{specver}.%{ostag}
78 %endif
80 ## General-purpose macros
82 # Some systems don't have some macros. If a macro doesn't seem
83 # to exist on your system, add it here...
85 %if %{!?__make:1}%{?__make:0}
86 %define __make make
87 %endif
89 %if %{!?make:1}%{?make:0}
90 %define make %{__make}
91 %endif
93 %if %{!?_localstatedir:1}%{?_localstatedir:0}
94 %define _localstatedir @LOCALSTATEDIR@
95 %endif
97 ## Package information
99 Name: tor
100 Version: %{version}
101 Release: %{release}
103 Summary: Anonymizing overlay network for TCP (The onion router)
104 URL: https://www.torproject.org/
105 Group: System Environment/Daemons
107 License: 3-clause BSD
108 Vendor: The Tor Project (https://torproject.org)
109 Packager: Erinn Clark <erinn@torproject.org>
111 Requires: openssl >= 0.9.7, libevent >= 1.4.13
112 BuildRequires: openssl-devel >= 0.9.7, libevent-devel >= 1.4.13, asciidoc
114 # Fedora 16 and RHEL 5 have following conflicting packages according to rpm search
115 %if %{is_rh}
116 Conflicts: tor-core, tor-lsb, tor-upstart
117 %endif
119 Requires(pre): /usr/bin/id, /bin/date, /bin/sh
120 Requires(pre): %{_sbindir}/useradd, %{_sbindir}/groupadd
122 Source0: https://www.torproject.org/dist/%{name}-%{native_version}.tar.gz
124 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
126 %description
127 Tor is a connection-based low-latency anonymous communication system.
129 This package provides the "tor" program, which serves as both a client and
130 a relay node. Scripts will automatically create a "%{toruser}" user and
131 a "%{torgroup}" group, and set tor up to run as a daemon when the system
132 is rebooted.
134 Applications connect to the local Tor proxy using the SOCKS
135 protocol. The tor client chooses a path through a set of relays, in
136 which each relay knows its predecessor and successor, but no
137 others. Traffic flowing down the circuit is unwrapped by a symmetric
138 key at each relay, which reveals the downstream relay.
140 Warnings: Tor does no protocol cleaning. That means there is a danger
141 that application protocols and associated programs can be induced to
142 reveal information about the initiator. Tor depends on Privoxy or
143 similar protocol cleaners to solve this problem. This is alpha code,
144 and is even more likely than released code to have anonymity-spoiling
145 bugs. The present network is small -- this further reduces the
146 strength of the anonymity provided. Tor is not presently suitable
147 for high-stakes anonymity.
149 %prep
150 %setup -q -n %{name}-%{native_version}
152 %build
153 %if %{is_suse}
154 %configure --with-tor-user=%{toruser} --with-tor-group=%{torgroup} --docdir=%{_docdir}/%{name}
155 %else
156 %configure --with-tor-user=%{toruser} --with-tor-group=%{torgroup}
157 %endif
158 %make
160 %install
161 %makeinstall
163 # Install init script and control script
164 %__mkdir_p ${RPM_BUILD_ROOT}%{_initrddir}
165 %if %{is_suse}
166 %__install -p -m 755 contrib/suse/tor.sh ${RPM_BUILD_ROOT}%{_initrddir}/%{name}
167 %else
168 %__install -p -m 755 contrib/tor.sh ${RPM_BUILD_ROOT}%{_initrddir}/%{name}
169 %endif
170 %__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
175 # Install the logrotate control file.
176 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d
177 %__install -p -m 644 contrib/tor.logrotate ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name}
179 # Directories that don't have any preinstalled files
180 %__mkdir_p -m 700 ${RPM_BUILD_ROOT}%{_localstatedir}/lib/%{name}
181 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/run/%{name}
182 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}
183 %__mkdir_p -m 700 ${RPM_BUILD_ROOT}%{_localstatedir}/tmp/%{name}
185 %clean
186 [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
188 # These scripts are probably wrong for Mandrake or SuSE. They're certainly
189 # wrong for Debian, but what are you doing using RPM on Debian?
191 %pre
193 # If tor is already installed and running (whether installed by RPM
194 # or not), then kill it, but remember that it was running.
195 %__rm -f /%{_localstatedir}/tmp/${name}-was-running-%{version}-%{release}
196 if [ -f %{_initrddir}/%{name} ] && /sbin/service %{name} status ; then
197 /sbin/service %{name} stop
198 touch /%{_localstatedir}/tmp/${name}-was-running-%{version}-%{release}
202 # Create a user and group if need be
204 if [ ! -n "`/usr/bin/id -g %{torgroup} 2>/dev/null`" ]; then
205 # One would like to default the GID, but doing that properly would
206 # require thought.
207 %{_sbindir}/groupadd %{torgroup} 2> /dev/null
209 if [ ! -n "`/usr/bin/id -u %{toruser} 2>/dev/null`" ]; then
210 # One would also like to default the UID, but doing that properly would
211 # also require thought.
212 if [ -x %{_sbindir}/nologin ]; then
213 %{_sbindir}/useradd -r -g %{torgroup} -d %{_localstatedir}/lib/%{name} -s %{_sbindir}/nologin %{toruser} 2> /dev/null
214 else
215 %{_sbindir}/useradd -r -g %{torgroup} -d %{_localstatedir}/lib/%{name} -s /bin/false %{toruser} 2> /dev/null
218 exit 0
220 %post
222 # If this is a new installation, use chkconfig to put tor in the
223 # default set of runlevels. If it's an upgrade, leave the existing
224 # configuration alone.
225 if [ $1 -eq 1 ]; then
226 /sbin/chkconfig --add %{name}
227 /sbin/chkconfig %{name} on
230 # Older tor RPMS used a different username for the tor daemon.
231 # Make sure the runtime data have the right ownership.
232 %__chown -R %{toruser}.%{torgroup} %{_localstatedir}/{lib,log,run}/%{name}
234 if [ -f /%{_localstatedir}/tmp/${name}-was-running-%{version}-%{release} ]; then
235 /sbin/service %{name} start
236 %__rm -f /%{_localstatedir}/tmp/${name}-was-running-%{version}-%{release}
238 exit 0
240 %preun
242 # If no instances of tor will be installed when we're done, make
243 # sure that it gets killed. We *don't* want to kill it or delete
244 # any of its data on uninstall if it's being upgraded to a new
245 # version, because the new version will actually already have
246 # been installed and started before the uninstall script for
247 # the old version is run, and we'd end up hosing it.
248 if [ $1 -le 0 ]; then
249 if [ -f %{_initrddir}/%{name} ] && /sbin/service %{name} status ; then
250 /sbin/service %{name} stop
252 %/sbin/chkconfig --del %{name}
253 %__rm -f ${_localstatedir}/lib/%{name}/cached-directory
254 %__rm -f ${_localstatedir}/lib/%{name}/bw_accounting
255 %__rm -f ${_localstatedir}/lib/%{name}/control_auth_cookie
256 %__rm -f ${_localstatedir}/lib/%{name}/router.desc
257 %__rm -f ${_localstatedir}/lib/%{name}/fingerprint
259 exit 0
261 %files
262 %defattr(-,root,root)
263 %if %{is_suse}
264 %doc INSTALL LICENSE README ChangeLog doc/HACKING doc/TODO doc/*html
265 %endif
266 %doc INSTALL LICENSE README ChangeLog doc/HACKING doc/TODO
267 %{_mandir}/man*/*
268 %{_bindir}/tor
269 %{_bindir}/torctl
270 %{_bindir}/torify
271 %{_bindir}/tor-resolve
272 %{_bindir}/tor-gencert
273 %if %{is_suse}
274 %else
275 %{_docdir}/*
276 %endif
277 %{_datadir}/tor/geoip
278 %config %{_initrddir}/%{name}
279 %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/logrotate.d/%{name}
280 %dir %attr(0755,root,%{torgroup}) %{_sysconfdir}/%{name}/
281 %config(noreplace) %attr(0644,root,%{torgroup}) %{_sysconfdir}/%{name}/*
282 %attr(0700,%{toruser},%{torgroup}) %dir %{_localstatedir}/lib/%{name}
283 %attr(0750,%{toruser},%{torgroup}) %dir %{_localstatedir}/run/%{name}
284 %attr(0750,%{toruser},%{torgroup}) %dir %{_localstatedir}/log/%{name}
286 %changelog
287 * Thu Jun 21 2012 Ondrej Mikle <ondrej.mikle@gmail.com>
288 - fixed to work with both rpmbuild and mock on RHEL/Fedora
289 - removed unnecessary files from rpm such as .git repo
290 - fixed build dependencies and package conflicts
291 - fixed creating _tor user on Fedora 17 (ancient typo)
292 - added/updated build instructions for RPM creation
293 - confirmed to build and run on EL5, EL6, Fedora 16/17, OpenSuse 12.1
295 * Fri Aug 20 2010 Erinn Clark <erinn@torproject.org>
296 - add conflicts for Fedora packages
297 - add logic for SuSE since it requires special doc handling
299 * Mon Feb 22 2010 Erinn Clark <erinn@torproject.org>
300 - remove AUTHORS from %doc line since it no longer exists upstream
301 - switch maintainers
303 * Fri May 01 2009 Andrew Lewman <andrew@torproject.org>
304 - clean up distro detection and remove dead comment blocks
306 * Sun Feb 22 2009 Andrew Lewman <andrew@torproject.org>
307 - update the description, vendor, and packager
309 * Thu Sep 11 2008 Andrew Lewman <phobos@rootme.org>
310 - See r16867
311 - http://archives.seul.org/or/cvs/Sep-2008/msg00156.html
313 * Tue Feb 27 2007 Andrew Lewman <phobos@rootme.org>
314 - Fix a potential race condition in how we determine the running state of tor. Found by Stefan Nordhausen.
315 - see OR-CVS for details
317 * Fri May 26 2006 Andrew Lewman <phobos@rootme.org>
318 - Add in a few "SUSEisms" to make dist-rpm actually work on suse
319 - Turn Tor "on" via chkconfig
320 - Update -mcpu to -mtune to make GCC happy
321 - see OR-CVS for details
323 * Tue Mar 28 2006 Andrew Lewman <phobos@rootme.org>
324 - converted to build the specified target cpu and arch
325 - override related rpm macros to build correctly
326 - see OR-CVS for details
328 * Mon Jan 17 2005 John Bashinski <jbash@velvet.com>
329 - Take runtime user and group names from configure system. Default
330 user/group names are now "_tor"; blame Roger...
331 - Make logrotate control file a separate file in the source distribution,
332 rather than creating it from the spec file.
333 - Properly handle the order in which RPM executes scriptlets on upgrade.
334 The old code would kill the daemon on upgrade.
335 - Start the tor daemon after installation if and only if it was
336 running before installation. Preserve runlevel setup on upgrade.
337 - Package the torctl script; the init script is now a wrapper around it.
339 * Tue Nov 5 2004 John Bashinski <jbash@velvet.com>
340 - Add skeletal support for multiple distributions
341 - Even more ridiculous level of macro-ization
342 - Modify version numbers so RPM can determine when it has a newer version
343 - Return to including distribution name in package release number
344 - Sharply trim description
345 - Change user/group name from "tor" to "tordmn"; "tor" is a common
346 given name (reported by Marius Hjelle)
347 - Change group to "System Environment/Daemons" (suggested by Marius Hjelle)
348 - Create logrotate file (suggested by Marius Hjelle)
349 - Make Tor run as a user proxy by default (suggested by Marius Hjelle)
350 - Autogenerate spec file from GNU autotools data, substituting version
351 and whatnot
352 - Be perhaps excessively paranoid with config file and directory modes
353 - Remove auto-start and auto-stop at installation time; there's some kind
354 of weird race going on, and it's arguably a bad thing anyway.
356 * Mon Jun 06 2004 Nick Mathewson <nickm@freehaven.net> 0.0.7-0.std.0.1.rc2
357 - Make spec file more happy with fc2 packaging
359 * Sat Jan 17 2004 John Bashinski <jbash@velvet.com>
360 - Basic spec file; tested with Red Hat 9.