| 1 |
## NOTE: tor.spec is autogenerated from tor.spec.in . Edit the latter, |
|---|
| 2 |
## not the former. |
|---|
| 3 |
|
|---|
| 4 |
## Things that need to be edited frequently |
|---|
| 5 |
# |
|---|
| 6 |
# This should be incremented whenever the spec file changes, but |
|---|
| 7 |
# can drop back to zero at a new Tor version |
|---|
| 8 |
|
|---|
| 9 |
%define specver 0 |
|---|
| 10 |
|
|---|
| 11 |
## Things users may want to change |
|---|
| 12 |
# |
|---|
| 13 |
# User (and group) name under which the Tor daemon runs. |
|---|
| 14 |
|
|---|
| 15 |
%define toruser @TORUSER@ |
|---|
| 16 |
%define torgroup @TORGROUP@ |
|---|
| 17 |
|
|---|
| 18 |
## Target a specific arch and OS |
|---|
| 19 |
# |
|---|
| 20 |
# default is i386 linux |
|---|
| 21 |
%define target gnu |
|---|
| 22 |
%define target_cpu i386 |
|---|
| 23 |
%define target_os linux |
|---|
| 24 |
|
|---|
| 25 |
## Override any system rpm macros |
|---|
| 26 |
# |
|---|
| 27 |
%define _arch %{target_cpu} |
|---|
| 28 |
%define _build_arch %{target_cpu} |
|---|
| 29 |
%define _vendor %{target_os} |
|---|
| 30 |
%define _host %{target_cpu}-pc-%{target_os}-%{target} |
|---|
| 31 |
%define _host_cpu %{target_cpu} |
|---|
| 32 |
%define _host_vendor %{target_os} |
|---|
| 33 |
%define optflags -march=%{target_cpu} -mtune=%{target_cpu} -O2 |
|---|
| 34 |
|
|---|
| 35 |
## Version song and dance |
|---|
| 36 |
# |
|---|
| 37 |
# This should be the Tor version number, as it appears on the tarball, |
|---|
| 38 |
# including any "pre<x>" or "rc<y>" suffix. This gets massaged to |
|---|
| 39 |
# create the RPM version number, in a way that depends on the Tor |
|---|
| 40 |
# numbering scheme. |
|---|
| 41 |
%define native_version @VERSION@ |
|---|
| 42 |
|
|---|
| 43 |
%define version %(echo %{native_version} | sed -e 's/-/./g') |
|---|
| 44 |
|
|---|
| 45 |
## Define output filename |
|---|
| 46 |
# |
|---|
| 47 |
# This creates filenames based upon the value of target_cpu defined above |
|---|
| 48 |
%define _build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%{target_cpu}.rpm |
|---|
| 49 |
|
|---|
| 50 |
## Release and OS identification song and dance |
|---|
| 51 |
# |
|---|
| 52 |
# This identifies the lineage of the spec file. This file is the |
|---|
| 53 |
# standard one that comes with Tor; various distributions may |
|---|
| 54 |
# have their own ideas about the right ways to do things. |
|---|
| 55 |
%define pkgspec tor |
|---|
| 56 |
|
|---|
| 57 |
# This spec is intended to build and install on multiple distributions |
|---|
| 58 |
# (someday). Detect the distribution we're building on. |
|---|
| 59 |
|
|---|
| 60 |
%define is_rh %(test -e /etc/redhat-release && echo 1 || echo 0) |
|---|
| 61 |
%define is_fc %(test -e /etc/fedora-release && echo 1 || echo 0) |
|---|
| 62 |
%define is_mdk %(test -e /etc/mandrake-release && echo 1 || echo 0) |
|---|
| 63 |
%define is_suse %(test -e /etc/SuSE-release && echo 1 || echo 0) |
|---|
| 64 |
|
|---|
| 65 |
%if %{is_fc} |
|---|
| 66 |
%define ostag %(sed -e 's/^.*release /fc/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/fedora-release) |
|---|
| 67 |
%else |
|---|
| 68 |
%if %{is_rh} |
|---|
| 69 |
%define ostag %(sed -e 's/^.*release /rh/' -e 's/ .*$//' -e 's/\\./_/g' < /etc/redhat-release) |
|---|
| 70 |
%endif |
|---|
| 71 |
%endif |
|---|
| 72 |
|
|---|
| 73 |
# These are probably wrong... just placeholders should we actually |
|---|
| 74 |
# end up supporting these distributions |
|---|
| 75 |
|
|---|
| 76 |
%if %{is_mdk} |
|---|
| 77 |
%define ostag mdk |
|---|
| 78 |
%endif |
|---|
| 79 |
|
|---|
| 80 |
%if %{is_suse} |
|---|
| 81 |
%define ostag suse |
|---|
| 82 |
%endif |
|---|
| 83 |
|
|---|
| 84 |
# Using the build date ensures that every build really does get |
|---|
| 85 |
# a different release number. We use this trick for CVS versions. |
|---|
| 86 |
# For release versions, we don't want or need it. |
|---|
| 87 |
%define is_cvs_version %(echo %{native_version} | grep 'cvs' > /dev/null && echo 1 || echo 0) |
|---|
| 88 |
|
|---|
| 89 |
%if %{is_cvs_version} |
|---|
| 90 |
%define blddate %(date -u +"%Y%m%d%H%M") |
|---|
| 91 |
%define release %{pkgspec}.%{specver}.%{ostag}.%{blddate} |
|---|
| 92 |
%else |
|---|
| 93 |
%define release %{pkgspec}.%{specver}.%{ostag} |
|---|
| 94 |
%endif |
|---|
| 95 |
|
|---|
| 96 |
## General-purpose macros |
|---|
| 97 |
# |
|---|
| 98 |
# Some systems don't have some macros. If a macro doesn't seem |
|---|
| 99 |
# to exist on your system, add it here... |
|---|
| 100 |
|
|---|
| 101 |
%if %{!?__make:1}%{?__make:0} |
|---|
| 102 |
%define __make make |
|---|
| 103 |
%endif |
|---|
| 104 |
|
|---|
| 105 |
%if %{!?make:1}%{?make:0} |
|---|
| 106 |
%define make %{__make} |
|---|
| 107 |
%endif |
|---|
| 108 |
|
|---|
| 109 |
%if %{!?_localstatedir:1}%{?_localstatedir:0} |
|---|
| 110 |
%define _localstatedir @LOCALSTATEDIR@ |
|---|
| 111 |
%endif |
|---|
| 112 |
|
|---|
| 113 |
## Package information |
|---|
| 114 |
# |
|---|
| 115 |
Name: tor |
|---|
| 116 |
Version: %{version} |
|---|
| 117 |
Release: %{release} |
|---|
| 118 |
|
|---|
| 119 |
Summary: Anonymizing overlay network for TCP (The onion router) |
|---|
| 120 |
URL: http://tor.eff.org/ |
|---|
| 121 |
Group: System Environment/Daemons |
|---|
| 122 |
|
|---|
| 123 |
License: BSD-like |
|---|
| 124 |
Vendor: R. Dingledine <arma@seul.org> |
|---|
| 125 |
Packager: Nick Mathewson <nickm@seul.org> |
|---|
| 126 |
|
|---|
| 127 |
%if %{is_suse} |
|---|
| 128 |
Requires: openssl >= 0.9.6 |
|---|
| 129 |
BuildRequires: openssl-devel >= 0.9.6, rpm >= 4.0, zlib-devel |
|---|
| 130 |
%else |
|---|
| 131 |
Requires: openssl >= 0.9.6, libevent >= 1.1a |
|---|
| 132 |
BuildRequires: openssl-devel >= 0.9.6, libevent-devel >= 1.1a |
|---|
| 133 |
%endif |
|---|
| 134 |
%if %{is_fc} |
|---|
| 135 |
BuildRequires: rpm-build >= 4.0 |
|---|
| 136 |
%endif |
|---|
| 137 |
Requires(pre): /usr/bin/id, /bin/date, /bin/sh |
|---|
| 138 |
Requires(pre): %{_sbindir}/useradd, %{_sbindir}/groupadd |
|---|
| 139 |
|
|---|
| 140 |
Source0: http://tor.eff.org/dist/%{name}-%{native_version}.tar.gz |
|---|
| 141 |
|
|---|
| 142 |
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root |
|---|
| 143 |
|
|---|
| 144 |
%description |
|---|
| 145 |
Tor is a connection-based low-latency anonymous communication system. |
|---|
| 146 |
|
|---|
| 147 |
This package provides the "tor" program, which serves as both a client and |
|---|
| 148 |
a relay node. Scripts will automatically create a "%{toruser}" user and |
|---|
| 149 |
a "%{torgroup}" group, and set tor up to run as a daemon when the system |
|---|
| 150 |
is rebooted. |
|---|
| 151 |
|
|---|
| 152 |
Applications connect to the local Tor proxy using the SOCKS |
|---|
| 153 |
protocol. The local proxy chooses a path through a set of relays, in |
|---|
| 154 |
which each relay knows its predecessor and successor, but no |
|---|
| 155 |
others. Traffic flowing down the circuit is unwrapped by a symmetric |
|---|
| 156 |
key at each relay, which reveals the downstream relay. |
|---|
| 157 |
|
|---|
| 158 |
Warnings: Tor does no protocol cleaning. That means there is a danger |
|---|
| 159 |
that application protocols and associated programs can be induced to |
|---|
| 160 |
reveal information about the initiator. Tor depends on Privoxy and |
|---|
| 161 |
similar protocol cleaners to solve this problem. This is alpha code, |
|---|
| 162 |
and is even more likely than released code to have anonymity-spoiling |
|---|
| 163 |
bugs. The present network is very small -- this further reduces the |
|---|
| 164 |
strength of the anonymity provided. Tor is not presently suitable |
|---|
| 165 |
for high-stakes anonymity. |
|---|
| 166 |
|
|---|
| 167 |
%prep |
|---|
| 168 |
%setup -q -n %{name}-%{native_version} |
|---|
| 169 |
|
|---|
| 170 |
%build |
|---|
| 171 |
%if %{is_suse} |
|---|
| 172 |
%configure --with-tor-user=%{toruser} --with-tor-group=%{torgroup} \ |
|---|
| 173 |
--build=%{_host} --host=%{_host} --target=%{_host} \ |
|---|
| 174 |
--enable-static --disable-shared |
|---|
| 175 |
%else |
|---|
| 176 |
%configure --with-tor-user=%{toruser} --with-tor-group=%{torgroup} \ |
|---|
| 177 |
--build=%{_host} --host=%{_host} --target=%{_host} |
|---|
| 178 |
%endif |
|---|
| 179 |
%make |
|---|
| 180 |
|
|---|
| 181 |
%install |
|---|
| 182 |
%makeinstall |
|---|
| 183 |
|
|---|
| 184 |
# Install init script and control script |
|---|
| 185 |
%__mkdir_p ${RPM_BUILD_ROOT}%{_initrddir} |
|---|
| 186 |
%if %{is_suse} |
|---|
| 187 |
%__install -p -m 755 contrib/suse/tor.sh ${RPM_BUILD_ROOT}%{_initrddir}/%{name} |
|---|
| 188 |
%else |
|---|
| 189 |
%__install -p -m 755 contrib/tor.sh ${RPM_BUILD_ROOT}%{_initrddir}/%{name} |
|---|
| 190 |
%endif |
|---|
| 191 |
%__install -p -m 755 contrib/torctl ${RPM_BUILD_ROOT}%{_bindir} |
|---|
| 192 |
|
|---|
| 193 |
# Set up config file; "sample" file implements a basic user node. |
|---|
| 194 |
%__install -p -m 644 ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/torrc.sample ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/torrc |
|---|
| 195 |
|
|---|
| 196 |
# Install the logrotate control file. |
|---|
| 197 |
%__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d |
|---|
| 198 |
%__install -p -m 644 contrib/tor.logrotate ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name} |
|---|
| 199 |
|
|---|
| 200 |
# Directories that don't have any preinstalled files |
|---|
| 201 |
%__mkdir_p -m 700 ${RPM_BUILD_ROOT}%{_localstatedir}/lib/%{name} |
|---|
| 202 |
%__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/run/%{name} |
|---|
| 203 |
%__mkdir_p -m 755 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name} |
|---|
| 204 |
|
|---|
| 205 |
%clean |
|---|
| 206 |
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} |
|---|
| 207 |
|
|---|
| 208 |
# These scripts are probably wrong for Mandrake or SuSE. They're certainly |
|---|
| 209 |
# wrong for Debian, but what are you doing using RPM on Debian? |
|---|
| 210 |
|
|---|
| 211 |
%pre |
|---|
| 212 |
|
|---|
| 213 |
# If tor is already installed and running (whether installed by RPM |
|---|
| 214 |
# or not), then kill it, but remember that it was running. |
|---|
| 215 |
%__rm -f /tmp/${name}-was-running-%{version}-%{release} |
|---|
| 216 |
if [ -f %{_initrddir}/%{name} ] && /sbin/service %{name} status ; then |
|---|
| 217 |
/sbin/service %{name} stop |
|---|
| 218 |
touch /tmp/${name}-was-running-%{version}-%{release} |
|---|
| 219 |
fi |
|---|
| 220 |
|
|---|
| 221 |
# |
|---|
| 222 |
# Create a user and group if need be |
|---|
| 223 |
# |
|---|
| 224 |
if [ ! -n "`/usr/bin/id -g %{torgroup} 2>/dev/null`" ]; then |
|---|
| 225 |
# One would like to default the GID, but doing that properly would |
|---|
| 226 |
# require thought. |
|---|
| 227 |
%{_sbindir}/groupadd %{torgroup} 2> /dev/null |
|---|
| 228 |
fi |
|---|
| 229 |
if [ ! -n "`/usr/bin/id -u %{toruser} 2>/dev/null`" ]; then |
|---|
| 230 |
# One would also like to default the UID, but doing that properly would |
|---|
| 231 |
# also require thought. |
|---|
| 232 |
if [ -x %{_sbindir}/nologin ]; then |
|---|
| 233 |
%{_sbindir}/useradd -r -g %{torgroup} -d% {_localstatedir}/lib/%{name} -s %{_sbindir}/nologin %{toruser} 2> /dev/null |
|---|
| 234 |
else |
|---|
| 235 |
%{_sbindir}/useradd -r -g %{torgroup} -d %{_localstatedir}/lib/%{name} -s /bin/false %{toruser} 2> /dev/null |
|---|
| 236 |
fi |
|---|
| 237 |
fi |
|---|
| 238 |
exit 0 |
|---|
| 239 |
|
|---|
| 240 |
%post |
|---|
| 241 |
|
|---|
| 242 |
# If this is a new installation, use chkconfig to put tor in the |
|---|
| 243 |
# default set of runlevels. If it's an upgrade, leave the existing |
|---|
| 244 |
# configuration alone. |
|---|
| 245 |
if [ $1 -eq 1 ]; then |
|---|
| 246 |
/sbin/chkconfig --add %{name} |
|---|
| 247 |
/sbin/chkconfig %{name} on |
|---|
| 248 |
fi |
|---|
| 249 |
|
|---|
| 250 |
# Older tor RPMS used a different username for the tor daemon. |
|---|
| 251 |
# Make sure the runtime data have the right ownership. |
|---|
| 252 |
%__chown -R %{toruser}.%{torgroup} %{_localstatedir}/{lib,log,run}/%{name} |
|---|
| 253 |
|
|---|
| 254 |
if [ -f /tmp/${name}-was-running-%{version}-%{release} ]; then |
|---|
| 255 |
/sbin/service %{name} start |
|---|
| 256 |
%__rm -f /tmp/${name}-was-running-%{version}-%{release} |
|---|
| 257 |
fi |
|---|
| 258 |
exit 0 |
|---|
| 259 |
|
|---|
| 260 |
%preun |
|---|
| 261 |
|
|---|
| 262 |
# If no instances of tor will be installed when we're done, make |
|---|
| 263 |
# sure that it gets killed. We *don't* want to kill it or delete |
|---|
| 264 |
# any of its data on uninstall if it's being upgraded to a new |
|---|
| 265 |
# version, because the new version will actually already have |
|---|
| 266 |
# been installed and started before the uninstall script for |
|---|
| 267 |
# the old version is run, and we'd end up hosing it. |
|---|
| 268 |
if [ $1 -le 0 ]; then |
|---|
| 269 |
if [ -f %{_initrddir}/%{name} ] && /sbin/service %{name} status ; then |
|---|
| 270 |
/sbin/service %{name} stop |
|---|
| 271 |
fi |
|---|
| 272 |
%/sbin/chkconfig --del %{name} |
|---|
| 273 |
%__rm -f ${_localstatedir}/lib/%{name}/cached-directory |
|---|
| 274 |
%__rm -f ${_localstatedir}/lib/%{name}/bw_accounting |
|---|
| 275 |
%__rm -f ${_localstatedir}/lib/%{name}/control_auth_cookie |
|---|
| 276 |
%__rm -f ${_localstatedir}/lib/%{name}/router.desc |
|---|
| 277 |
%__rm -f ${_localstatedir}/lib/%{name}/fingerprint |
|---|
| 278 |
fi |
|---|
| 279 |
exit 0 |
|---|
| 280 |
|
|---|
| 281 |
%files |
|---|
| 282 |
%defattr(-,root,root) |
|---|
| 283 |
%doc AUTHORS INSTALL LICENSE README ChangeLog doc/HACKING doc/TODO |
|---|
| 284 |
%{_mandir}/man*/* |
|---|
| 285 |
%{_bindir}/tor |
|---|
| 286 |
%{_bindir}/torctl |
|---|
| 287 |
%{_bindir}/torify |
|---|
| 288 |
%{_bindir}/tor-resolve |
|---|
| 289 |
%config %{_initrddir}/%{name} |
|---|
| 290 |
%config(noreplace) %attr(0644,root,root) %{_sysconfdir}/logrotate.d/%{name} |
|---|
| 291 |
%dir %attr(0755,root,%{torgroup}) %{_sysconfdir}/%{name}/ |
|---|
| 292 |
%config(noreplace) %attr(0644,root,%{torgroup}) %{_sysconfdir}/%{name}/* |
|---|
| 293 |
%attr(0700,%{toruser},%{torgroup}) %dir %{_localstatedir}/lib/%{name} |
|---|
| 294 |
%attr(0750,%{toruser},%{torgroup}) %dir %{_localstatedir}/run/%{name} |
|---|
| 295 |
%attr(0750,%{toruser},%{torgroup}) %dir %{_localstatedir}/log/%{name} |
|---|
| 296 |
|
|---|
| 297 |
%changelog |
|---|
| 298 |
|
|---|
| 299 |
* Fri May 26 2006 Andrew Lewman <phobos@interloper.org> |
|---|
| 300 |
- Add in a few "SUSEisms" to make dist-rpm actually work on suse |
|---|
| 301 |
- Turn Tor "on" via chkconfig |
|---|
| 302 |
- Update -mcpu to -mtune to make GCC happy |
|---|
| 303 |
- see OR-CVS for details |
|---|
| 304 |
|
|---|
| 305 |
* Tue Mar 28 2006 Andrew Lewman <phobos@interloper.org> |
|---|
| 306 |
- converted to build the specified target cpu and arch |
|---|
| 307 |
- override related rpm macros to build correctly |
|---|
| 308 |
- see OR-CVS for details |
|---|
| 309 |
|
|---|
| 310 |
* Mon Jan 17 2005 John Bashinski <jbash@velvet.com> |
|---|
| 311 |
- Take runtime user and group names from configure system. Default |
|---|
| 312 |
user/group names are now "_tor"; blame Roger... |
|---|
| 313 |
- Make logrotate control file a separate file in the source distribution, |
|---|
| 314 |
rather than creating it from the spec file. |
|---|
| 315 |
- Properly handle the order in which RPM executes scriptlets on upgrade. |
|---|
| 316 |
The old code would kill the daemon on upgrade. |
|---|
| 317 |
- Start the tor daemon after installation if and only if it was |
|---|
| 318 |
running before installation. Preserve runlevel setup on upgrade. |
|---|
| 319 |
- Package the torctl script; the init script is now a wrapper around it. |
|---|
| 320 |
|
|---|
| 321 |
* Tue Nov 5 2004 John Bashinski <jbash@velvet.com> |
|---|
| 322 |
- Add skeletal support for multiple distributions |
|---|
| 323 |
- Even more ridiculous level of macro-ization |
|---|
| 324 |
- Modify version numbers so RPM can determine when it has a newer version |
|---|
| 325 |
- Return to including distribution name in package release number |
|---|
| 326 |
- Sharply trim description |
|---|
| 327 |
- Change user/group name from "tor" to "tordmn"; "tor" is a common |
|---|
| 328 |
given name (reported by Marius Hjelle) |
|---|
| 329 |
- Change group to "System Environment/Daemons" (suggested by Marius Hjelle) |
|---|
| 330 |
- Create logrotate file (suggested by Marius Hjelle) |
|---|
| 331 |
- Make Tor run as a user proxy by default (suggested by Marius Hjelle) |
|---|
| 332 |
- Autogenerate spec file from GNU autotools data, substituting version |
|---|
| 333 |
and whatnot |
|---|
| 334 |
- Be perhaps excessively paranoid with config file and directory modes |
|---|
| 335 |
- Remove auto-start and auto-stop at installation time; there's some kind |
|---|
| 336 |
of weird race going on, and it's arguably a bad thing anyway. |
|---|
| 337 |
|
|---|
| 338 |
* Mon Jun 06 2004 Nick Mathewson <nickm@freehaven.net> 0.0.7-0.std.0.1.rc2 |
|---|
| 339 |
- Make spec file more happy with fc2 packaging |
|---|
| 340 |
|
|---|
| 341 |
* Sat Jan 17 2004 John Bashinski <jbash@velvet.com> |
|---|
| 342 |
- Basic spec file; tested with Red Hat 9. |
|---|