fix the assumption that uninitialized variables are 0
[tor.git] / tor.spec.in
blob7c7b4a63a318da5b6dd4679fba0ae640760093e4
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
61 # Using the build date ensures that every build really does get
62 # a different release number. We use this trick for CVS versions.
63 # For release versions, we don't want or need it.
64 %define is_cvs_version %(echo %{native_version} | grep 'cvs' > /dev/null && echo 1 || echo 0)
66 %if %{is_cvs_version}
67 %define blddate %(date -u +"%Y%m%d%H%M")
68 %define release %{pkgspec}.%{specver}.%{ostag}.%{blddate}
69 %else
70 %define release %{pkgspec}.%{specver}.%{ostag}
71 %endif
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://tor.eff.org/
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://tor.eff.org/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 Applications connect to the local Tor proxy using the SOCKS
121 protocol. The local proxy 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 relay.
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}/*log {
169 daily
170 rotate 5
171 compress
172 delaycompress
173 missingok
174 notifempty
175 sharedscripts
176 postrotate
177 /etc/rc.d/init.d/tor reload > /dev/null
178 endscript
180 /EOF/
182 # Directories that don't have any preinstalled files
183 %__mkdir_p -m 700 ${RPM_BUILD_ROOT}%{_localstatedir}/lib/%{name}
184 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/run/%{name}
185 %__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}
187 %clean
188 [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
190 # These scripts are probably wrong for Mandrake or SuSe. They're certainly
191 # wrong for Debian, but what are you doing using RPM on Debian?
192 %pre
193 [ -f %{_initrddir}/%{name} ] && /sbin/service %{name} stop
194 if [ ! -n "`/usr/bin/id -g %{runuser} 2>/dev/null`" ]; then
195 # One would like to default the GID, but doing that properly would
196 # require thought.
197 %{_sbindir}/groupadd %{runuser} 2> /dev/null
199 if [ ! -n "`/usr/bin/id -u %{runuser} 2>/dev/null`" ]; then
200 # One would also like to default the UID, but doing that properly would
201 # also require thought.
202 if [ -x /sbin/nologin ]; then
203 if [ -x /sbin/nologin ]; then
204 %{_sbindir}/useradd -r -g %{runuser} -d %{localstatedir}/lib/%{name} -s /sbin/nologin %{runuser} 2> /dev/null
205 else
206 %{_sbindir}/useradd -r -g %{runuser} -d %{localstatedir}/lib/%{name} -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.