Make tor-resolve accept x.y.exit addresses again
[tor.git] / tor.spec.in
blob9f46707d6823255172d00e62db89c10e94d964f5
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 0
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.
29 # We do this as follows:
30 # - If the version number has no "pre", "cvs", or "rc", we let it pass.
31 # - Otherwise, we mangle it heavily:
32 # * To make 0.0.Xpre come after 0.0.{X-1}* but before 0.0.X, we prepend
33 # 0.0.{X-1}.99 to the version.
34 # * We replace pre with .pre. and rc with .rc.
35 # * We replace -cvs with .cvs, and lack of -cvs with .release.
37 # Note that this scheme will break if we ever use 0 as a last digit for a
38 # Tor version: so don't do that.
40 %define is_dev_version %(echo %{native_version} | grep 'cvs\\|pre\\|rc' > /dev/null && echo 1 || echo 0)
42 %if %{is_dev_version}
44 # The 0.0.X.pre.1.cvs part.
45 %define safe_native_version %(echo %{native_version} | sed -e 's/-cvs/.cvs/' -e 's/pre/.pre./' -e 's/rc/.rc./' -e 's/\\([0-9]\\)$/\\1.release/')
46 # The 0.0.X part -- the version we are leading up to.
47 %define stub_version %(echo %{native_version} | sed -e 's/-cvs//' -e 's/pre.*//' -e 's/rc.*//')
48 # The 0.0 part
49 %define stub_start %(echo %{stub_version} | sed -e 's/\\.[0-9]*$//')
50 # The X part.
51 %define stub_last %(echo %{stub_version} | sed -e 's/.*\\.\\([0-9]*\\)$/\\1/')
52 # The {X-1} part.
53 %define stub_newlast %(expr %{stub_last} - 1)
54 # The actual version: 0.0.{X-1}.99.0.0.X.pre.1.cvs
55 %define version %{stub_start}.%{stub_newlast}.99.%{safe_native_version}
57 %else
58 %define version %{native_version}
59 %endif
61 ## Release and OS identification song and dance
63 # This identifies the lineage of the spec file. This file is the
64 # standard one that comes with Tor; various distributions may
65 # have their own ideas about the right ways to do things.
66 %define pkgspec tor
68 # This spec is intended to build and install on multiple distributions.
69 # Detect the distribution we're building on.
71 %define is_rh %(test -e /etc/redhat-release && echo 1 || echo 0)
72 %define is_fc %(test -e /etc/fedora-release && echo 1 || echo 0)
73 %define is_mdk %(test -e /etc/mandrake-release && echo 1 || echo 0)
74 %define is_suse %(test -e /etc/SuSE-release && echo 1 || echo 0)
76 %if %{is_fc}
77 %define ostag %(sed -e 's/^.*release /fc/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/fedora-release)
78 %else
79 %if %{is_rh}
80 %define ostag %(sed -e 's/^.*release /rh/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/redhat-release)
81 %endif
82 %endif
84 # These are probably wrong... just placeholders should we actually
85 # end up supporting these distributions
87 %if %{is_mdk}
88 %define ostag mdk
89 %endif
91 %if %{is_suse}
92 %define ostag suse
93 %endif
95 # Using the build date ensures that every build really does get
96 # a different release number.
97 %define blddate %(date -u +"%Y%m%d%H%M")
99 # ... and here it is.
100 %define release %{pkgspec}.%{specver}.%{ostag}.%{blddate}
102 ## General-purpose macros
104 # Some systems don't have some macros. If a macro doesn't seem
105 # to exist on your system, add it here...
107 %if %{!?__make:1}%{?__make:0}
108 %define __make make
109 %endif
111 %if %{!?make:1}%{?make:0}
112 %define make %{__make}
113 %endif
115 %if %{!?_localstatedir:1}%{?_localstatedir:0}
116 %define _localstatedir @LOCALSTATEDIR@
117 %endif
119 ## Package information
121 Name: tor
122 Version: %{version}
123 Release: %{release}
125 Summary: Anonymizing overlay network for TCP (The onion router)
126 URL: http://freehaven.net/%{name}/
127 Group: System Environment/Daemons
129 License: BSD-like
130 Vendor: R. Dingledine <arma@seul.org>
131 Packager: Nick Mathewson <nickm@seul.org>
133 Requires: openssl >= 0.9.6
134 BuildRequires: openssl-devel >= 0.9.6, rpm-build >= 4.0
135 Requires(pre): shadow-utils, /usr/bin/id, /bin/date, /bin/sh
136 Requires(pre): %{_sbindir}/useradd, %{_sbindir}/groupadd
138 Source0: http://freehaven.net/%{name}/dist/%{name}-%{native_version}.tar.gz
140 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
142 %description
143 Tor is a connection-based low-latency anonymous communication system.
145 This package provides the "tor" program, which serves as both a client and
146 a relay node. Scripts will automatically create a "%{runuser}" user and
147 group, and set tor up to run as a daemon when the system is rebooted.
149 Clients connect to their local Tor servers using the SOCKS5
150 protocol. The local server chooses a path through a set of relays, in
151 which each relay knows its predecessor and successor, but no
152 others. Traffic flowing down the circuit is unwrapped by a symmetric
153 key at each relay, which reveals the downstream node.
155 Warnings: Tor does no protocol cleaning. That means there is a danger
156 that application protocols and associated programs can be induced to
157 reveal information about the initiator. Tor depends on Privoxy and
158 similar protocol cleaners to solve this problem. This is alpha code,
159 and is even more likely than released code to have anonymity-spoiling
160 bugs. The present network is very small -- this further reduces the
161 strength of the anonymity provided. Tor is not presently suitable
162 for high-stakes anonymity.
164 %prep
165 %setup -q -n %{name}-%{native_version}
167 # Patch the startup script to use the right user and group IDs. Force
168 # the use of /bin/sh as the shell for the "tor" account.
169 ed -s contrib/tor.sh.in << '/EOF/' > /dev/null
170 ,s/^TORUSER=$/TORUSER=%{runuser}/
171 ,s/^TORGROUP=$/TORGROUP=%{runuser}/
172 ,s:/bin/su:/bin/su -s /bin/sh:
174 # Save and exit ed
177 /EOF/
179 %build
180 %configure
181 %make
183 %install
184 %makeinstall
186 # Install init script.
187 %__mkdir_p ${RPM_BUILD_ROOT}%{_initrddir}
188 %__install -p -m 755 contrib/tor.sh ${RPM_BUILD_ROOT}%{_initrddir}/%{name}
190 # Set up config file; "sample" file implements a basic user node.
191 %__install -p -m 644 ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/torrc.sample ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/torrc
193 # Create a logrotate file. This should really be a source file,
194 # but hey...
195 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d
196 %__cat > ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name} << /EOF/
197 %{_localstatedir}/log/%{name} {
198 missingok
199 notifempty
200 sharedscripts
202 /EOF/
204 # Directories that don't have any preinstalled files
205 %__mkdir_p -m 700 ${RPM_BUILD_ROOT}%{_localstatedir}/lib/%{name}
206 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/run/%{name}
207 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}
209 %clean
210 [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
212 # These scripts are probably wrong for Mandrake or SuSe. They're certainly
213 # wrong for Debian, but what are you doing using RPM on Debian?
214 %pre
215 [ -f %{_initrddir}/%{name} ] && /sbin/service %{name} stop
216 if [ ! -n "`/usr/bin/id -g %{runuser} 2>/dev/null`" ]; then
217 # One would like to default the GID, but doing that properly would
218 # require thought.
219 %{_sbindir}/groupadd %{runuser} 2> /dev/null
221 if [ ! -n "`/usr/bin/id -u %{runuser} 2>/dev/null`" ]; then
222 # One would also like to default the UID, but doing that properly would
223 # also require thought.
224 if [ -x /sbin/nologin ]; then
225 %{_sbindir}/useradd -r -g %{runuser} -d / -s /sbin/nologin %{runuser} 2> /dev/null
226 else
227 %{_sbindir}/useradd -r -g %{runuser} -d / -s /bin/false %{runuser} 2> /dev/null
230 exit 0
232 %post
233 /sbin/chkconfig --add %{name}
234 exit 0
236 %preun
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 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}/torify
251 %{_bindir}/tor-resolve
252 %config %{_initrddir}/%{name}
253 %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/logrotate.d/%{name}
254 %dir %attr(0750,root,%{runuser}) %{_sysconfdir}/%{name}/
255 %config(noreplace) %attr(0640,root,%{runuser}) %{_sysconfdir}/%{name}/*
256 %attr(0700,%{runuser},%{runuser}) %dir %{_localstatedir}/lib/%{name}
257 %attr(0750,%{runuser},%{runuser}) %dir %{_localstatedir}/run/%{name}
258 %attr(0750,%{runuser},%{runuser}) %dir %{_localstatedir}/log/%{name}
260 %changelog
261 * Tue Nov 5 2004 John Bashinski <jbash@velvet.com>
262 - Add skeletal support for multiple distributions
263 - Even more ridiculous level of macro-ization
264 - Modify version numbers so RPM can determine when it has a newer version
265 - Return to including distribution name in package release number
266 - Sharply trim description
267 - Change user/group name from "tor" to "tordmn"; "tor" is a common
268 given name (reported by Marius Hjelle)
269 - Change group to "System Environment/Daemons" (suggested by Marius Hjelle)
270 - Create logrotate file (suggested by Marius Hjelle)
271 - Make Tor run as a user proxy by default (suggested by Marius Hjelle)
272 - Autogenerate spec file from GNU autotools data, substituting version
273 and whatnot
274 - Be perhaps excessively paranoid with config file and directory modes
275 - Remove auto-start and auto-stop at installation time; there's some kind
276 of weird race going on, and it's arguably a bad thing anyway.
278 * Mon Jun 06 2004 Nick Mathewson <nickm@freehaven.net> 0.0.7-0.std.0.1.rc2
279 - Make spec file more happy with fc2 packaging
281 * Sat Jan 17 2004 John Bashinski <jbash@velvet.com>
282 - Basic spec file; tested with Red Hat 9.