tor.spec 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. %define rellevel 1
  2. %define relbase std.%{rellevel}
  3. %define rhrel %([ -f /etc/redhat-release ] && (sed -e 's/^Red Hat Linux release //' -e 's/ .*$//' -e 's/\\./_/g' -e 's/^.*$/.rh&/' < /etc/redhat-release))
  4. %define blddate %(date -u +"%Y%m%d%H%M")
  5. %define release %{relbase}%{rhrel}.%{blddate}
  6. %define initdir /etc/rc.d/init.d
  7. Summary: tor: The Onion Router; patent-free Onion Routing
  8. Name: tor
  9. Version: 0.0.2pre20
  10. Vendor: R. Dingledine <arma@seul.org>
  11. Release: %{release}
  12. License: BSD-like
  13. Group: Applications/Internet
  14. URL: http://freehaven.net/tor
  15. Source0: http://freehaven.net/tor/dist/tor-0.0.2pre19.tar.gz
  16. Requires(pre): shadow-utils, /usr/bin/id, /bin/date, /bin/sh
  17. Requires(pre): %{_sbindir}/useradd, %{_sbindir}/groupadd
  18. BuildRoot: %{_tmppath}/%{name}-%{version}-%{relbase}-root
  19. %description
  20. tor is a system which attempts to conceal the sources of TCP connections
  21. by relaying those connections through multiple independently administered
  22. forwarding nodes; it is a "cascaded mix" system. Among older systems,
  23. tor is most similar to Onion Routing. The basic concept of tor is also
  24. similar to that of the Zero Knowledge Freedom system or the Java Anonymous
  25. Proxy. The "onions" used in tor are similar in concept to the reply blocks
  26. used with type I "cypherpunks" anonymous remailers. Feeding phrases
  27. from this paragraph into search engines should give you more background
  28. information than you really want.
  29. This package provides the "tor" program, which serves as both a client
  30. and a relay node. Scripts will automatically create a "tor" user and
  31. group, set tor up to run as a daemon, and automatically start it at
  32. installation time.
  33. %prep
  34. %setup -q
  35. # Patch the startup script to use the right user and group IDs, store
  36. # the PID in a subdirectory of /var/run (so tor doesn't have to start
  37. # as root) and add in a control line for chkconfig. This (BSD? Debian?)
  38. # script will work, but doesn't use all the weird Red Hat macros to make
  39. # the boot sequence look pretty.
  40. ed -s tor.sh.in << '/EOF/' > /dev/null
  41. # Change the PID file location
  42. ,s/^TORPID=\(.*\)\/run\/tor.pid/TORPID=\1\/run\/tor\/tor.pid/
  43. #
  44. # Set user to "tor" before starting tor
  45. ,s/^\([ ]*\)\(\$TORBIN.*\)$/\1\/bin\/su -s \/bin\/sh -c "\2" tor/
  46. #
  47. # Add user and group to command line. Suspenders and belt.
  48. ,s/^TORARGS="\(.*\)"/TORARGS="\1 --user tor --group tor"/
  49. #
  50. # Add control lines for chkconfig
  51. 1a
  52. # chkconfig: 2345 90 10
  53. # description: Onion router
  54. .
  55. #
  56. # Save and exit ed
  57. w
  58. q
  59. /EOF/
  60. %build
  61. %configure
  62. %__make
  63. %install
  64. %makeinstall
  65. # Install init script.
  66. %__mkdir_p ${RPM_BUILD_ROOT}%{initdir}
  67. %__install -m 755 tor.sh ${RPM_BUILD_ROOT}%{initdir}/tor
  68. # Directories that don't have any preinstalled files
  69. %__mkdir_p -m 700 ${RPM_BUILD_ROOT}/var/lib/tor
  70. %__mkdir_p -m 755 ${RPM_BUILD_ROOT}/var/run/tor
  71. %__mkdir_p -m 755 ${RPM_BUILD_ROOT}/var/log/tor
  72. %clean
  73. [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
  74. %pre
  75. [ -f %{initdir}/tor ] && /sbin/service tor stop
  76. if [ ! -n "`/usr/bin/id -g tor 2>/dev/null`" ]; then
  77. # One would like to default the GID, but doing that properly would
  78. # require thought.
  79. %{_sbindir}/groupadd tor 2> /dev/null
  80. fi
  81. if [ ! -n "`/usr/bin/id -u tor 2>/dev/null`" ]; then
  82. # One would also like to default the UID, but doing that properly would
  83. # also require thought.
  84. if [ -x /sbin/nologin ]; then
  85. %{_sbindir}/useradd -g tor -d / -s /sbin/nologin tor 2> /dev/null
  86. else
  87. %{_sbindir}/useradd -g tor -d / -s /bin/false tor 2> /dev/null
  88. fi
  89. fi
  90. %post
  91. /sbin/chkconfig --add tor
  92. /sbin/service tor start
  93. %preun
  94. /sbin/service tor stop
  95. /sbin/chkconfig --del tor
  96. %files
  97. %defattr(-,root,root)
  98. %doc AUTHORS INSTALL LICENSE README
  99. %{_mandir}/man*/*
  100. %{_bindir}/tor
  101. %{initdir}/tor
  102. %dir %{_sysconfdir}/tor/
  103. %config(noreplace) %{_sysconfdir}/tor/torrc
  104. %config(noreplace) %{_sysconfdir}/tor/dirservers
  105. %attr(-,tor,tor) %dir /var/lib/tor
  106. %attr(-,tor,tor) %dir /var/run/tor
  107. %attr(-,tor,tor) %dir /var/log/tor
  108. %changelog
  109. * Sat Jan 17 2004 John Bashinski <jbash@velvet.com>
  110. - Basic spec file; tested with Red Hat 9.