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