04_fix_test can be backed out again, it was a backport from cvs to the package
[tor.git] / tor.spec.in
blob4eb0eea35d036cb91ea15343cd54a3ae85d99132
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 runuser tordmn
17 ## Version song and dance
19 # This should be the Tor version number, as it appears on the tarball,
20 # including any "pre<x>" or "rc<y>" suffix. This gets massaged to
21 # create the RPM version number, in a way that depends on the Tor
22 # numbering scheme.
23 %define native_version @VERSION@
25 # Massage the version so that pre-releases will be treated as earlier
26 # than release candidates which will be treated as earlier than released
27 # versions... while making as few confusing changes to the standard
28 # release naming as possible.
29 # XXXX009 Execept that handling cvs breaks this.
30 %define version %(echo %{native_version} | sed -e 's/-cvs/.cvs/' -e 's/pre/.pre./' -e 's/rc/.rc./' -e 's/([0-9])$/\1.release/')
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 # 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)
47 %if %{is_fc}
48 %define ostag %(sed -e 's/^.*release /fc/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/fedora-release)
49 %else
50 %if %{is_rh}
51 %define ostag %(sed -e 's/^.*release /rh/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/redhat-release)
52 %endif
53 %endif
55 # These are probably wrong... just placeholders should we actually
56 # end up supporting these distributions
58 %if %{is_mdk}
59 %define ostag mdk
60 %endif
62 %if %{is_suse}
63 %define ostag suse
64 %endif
66 # Using the build date ensures that every build really does get
67 # a different release number.
68 %define blddate %(date -u +"%Y%m%d%H%M")
70 # ... and here it is.
71 %define release %{pkgspec}.%{specver}.%{ostag}.%{blddate}
73 ## General-purpose macros
75 # Some systems don't have some macros. If a macro doesn't seem
76 # to exist on your system, add it here...
78 %if %{!?__make:1}%{?__make:0}
79 %define __make make
80 %endif
82 %if %{!?make:1}%{?make:0}
83 %define make %{__make}
84 %endif
86 %if %{!?_localstatedir:1}%{?_localstatedir:0}
87 %define _localstatedir @LOCALSTATEDIR@
88 %endif
90 ## Package information
92 Name: tor
93 Version: %{version}
94 Release: %{release}
96 Summary: Anonymizing overlay network for TCP (The onion router)
97 URL: http://freehaven.net/%{name}/
98 Group: System Environment/Daemons
100 License: BSD-like
101 Vendor: R. Dingledine <arma@seul.org>
102 Packager: Nick Mathewson <nickm@seul.org>
104 Requires: openssl >= 0.9.6
105 BuildRequires: openssl-devel >= 0.9.6, rpm-build >= 4.0
106 Requires(pre): shadow-utils, /usr/bin/id, /bin/date, /bin/sh
107 Requires(pre): %{_sbindir}/useradd, %{_sbindir}/groupadd
109 Source0: http://freehaven.net/%{name}/dist/%{name}-%{native_version}.tar.gz
111 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
113 %description
114 Tor is a connection-based low-latency anonymous communication system.
116 This package provides the "tor" program, which serves as both a client and
117 a relay node. Scripts will automatically create a "%{runuser}" user and
118 group, and set tor up to run as a daemon when the system is rebooted.
120 Clients connect to their local Tor servers using the SOCKS5
121 protocol. The local server chooses a path through a set of relays, in
122 which each relay knows its predecessor and successor, but no
123 others. Traffic flowing down the circuit is unwrapped by a symmetric
124 key at each relay, which reveals the downstream node.
126 Warnings: Tor does no protocol cleaning. That means there is a danger
127 that application protocols and associated programs can be induced to
128 reveal information about the initiator. Tor depends on Privoxy and
129 similar protocol cleaners to solve this problem. This is alpha code,
130 and is even more likely than released code to have anonymity-spoiling
131 bugs. The present network is very small -- this further reduces the
132 strength of the anonymity provided. Tor is not presently suitable
133 for high-stakes anonymity.
135 %prep
136 %setup -q -n %{name}-%{native_version}
138 # Patch the startup script to use the right user and group IDs. Force
139 # the use of /bin/sh as the shell for the "tor" account.
140 ed -s contrib/tor.sh.in << '/EOF/' > /dev/null
141 ,s/^TORUSER=$/TORUSER=%{runuser}/
142 ,s/^TORGROUP=$/TORGROUP=%{runuser}/
143 ,s:/bin/su:/bin/su -s /bin/sh:
145 # Save and exit ed
148 /EOF/
150 %build
151 %configure
152 %make
154 %install
155 %makeinstall
157 # Install init script.
158 %__mkdir_p ${RPM_BUILD_ROOT}%{_initrddir}
159 %__install -p -m 755 contrib/tor.sh ${RPM_BUILD_ROOT}%{_initrddir}/%{name}
161 # Set up config file; "sample" file implements a basic user node.
162 %__install -p -m 644 ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/torrc.sample ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/torrc
164 # Create a logrotate file. This should really be a source file,
165 # but hey...
166 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d
167 %__cat > ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name} << /EOF/
168 %{_localstatedir}/log/%{name} {
169 missingok
170 notifempty
171 sharedscripts
173 /EOF/
175 # Directories that don't have any preinstalled files
176 %__mkdir_p -m 700 ${RPM_BUILD_ROOT}%{_localstatedir}/lib/%{name}
177 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/run/%{name}
178 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}
180 %clean
181 [ "${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 [ -f %{_initrddir}/%{name} ] && /sbin/service %{name} stop
187 if [ ! -n "`/usr/bin/id -g %{runuser} 2>/dev/null`" ]; then
188 # One would like to default the GID, but doing that properly would
189 # require thought.
190 %{_sbindir}/groupadd %{runuser} 2> /dev/null
192 if [ ! -n "`/usr/bin/id -u %{runuser} 2>/dev/null`" ]; then
193 # One would also like to default the UID, but doing that properly would
194 # also require thought.
195 if [ -x /sbin/nologin ]; then
196 %{_sbindir}/useradd -r -g %{runuser} -d / -s /sbin/nologin %{runuser} 2> /dev/null
197 else
198 %{_sbindir}/useradd -r -g %{runuser} -d / -s /bin/false %{runuser} 2> /dev/null
201 exit 0
203 %post
204 /sbin/chkconfig --add %{name}
205 exit 0
207 %preun
208 /sbin/chkconfig --del %{name}
209 exit 0
211 %files
212 %defattr(-,root,root)
213 %doc AUTHORS INSTALL LICENSE README ChangeLog doc/HACKING doc/TODO doc/FAQ
214 %{_mandir}/man*/*
215 %{_bindir}/tor
216 %{_bindir}/torify
217 %{_bindir}/tor-resolve
218 %config %{_initrddir}/%{name}
219 %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/logrotate.d/%{name}
220 %dir %attr(0750,root,%{runuser}) %{_sysconfdir}/%{name}/
221 %config(noreplace) %attr(0640,root,%{runuser}) %{_sysconfdir}/%{name}/*
222 %attr(0700,%{runuser},%{runuser}) %dir %{_localstatedir}/lib/%{name}
223 %attr(0750,%{runuser},%{runuser}) %dir %{_localstatedir}/run/%{name}
224 %attr(0750,%{runuser},%{runuser}) %dir %{_localstatedir}/log/%{name}
226 %changelog
227 * Tue Nov 5 2004 John Bashinski <jbash@velvet.com>
228 - Add skeletal support for multiple distributions
229 - Even more ridiculous level of macro-ization
230 - Modify version numbers so RPM can determine when it has a newer version
231 - Return to including distribution name in package release number
232 - Sharply trim description
233 - Change user/group name from "tor" to "tordmn"; "tor" is a common
234 given name (reported by Marius Hjelle)
235 - Change group to "System Environment/Daemons" (suggested by Marius Hjelle)
236 - Create logrotate file (suggested by Marius Hjelle)
237 - Make Tor run as a user proxy by default (suggested by Marius Hjelle)
238 - Autogenerate spec file from GNU autotools data, substituting version
239 and whatnot
240 - Be perhaps excessively paranoid with config file and directory modes
241 - Remove auto-start and auto-stop at installation time; there's some kind
242 of weird race going on, and it's arguably a bad thing anyway.
244 * Mon Jun 06 2004 Nick Mathewson <nickm@freehaven.net> 0.0.7-0.std.0.1.rc2
245 - Make spec file more happy with fc2 packaging
247 * Sat Jan 17 2004 John Bashinski <jbash@velvet.com>
248 - Basic spec file; tested with Red Hat 9.