From 9d3cf1b4d1884d7f7e0ea39bc9fe8eae481647a2 Mon Sep 17 00:00:00 2001
From: Peter Palfrader <peter@palfrader.org>
Date: Tue, 13 Jan 2004 13:40:00 +0000
Subject: [PATCH] First go at a debian package

svn:r987
---
 debian/changelog     |  6 +++
 debian/compat        |  1 +
 debian/control       | 41 +++++++++++++++++++
 debian/copyright     | 40 +++++++++++++++++++
 debian/rules         | 94 ++++++++++++++++++++++++++++++++++++++++++++
 debian/tor.default   |  8 ++++
 debian/tor.dirs      |  4 ++
 debian/tor.docs      |  1 +
 debian/tor.init      | 55 ++++++++++++++++++++++++++
 debian/tor.logrotate | 11 ++++++
 debian/tor.postinst  | 54 +++++++++++++++++++++++++
 debian/tor.postrm    | 11 ++++++
 12 files changed, 326 insertions(+)
 create mode 100644 debian/changelog
 create mode 100644 debian/compat
 create mode 100644 debian/control
 create mode 100644 debian/copyright
 create mode 100755 debian/rules
 create mode 100644 debian/tor.default
 create mode 100644 debian/tor.dirs
 create mode 100644 debian/tor.docs
 create mode 100644 debian/tor.init
 create mode 100644 debian/tor.logrotate
 create mode 100644 debian/tor.postinst
 create mode 100644 debian/tor.postrm

diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000000..0448978187
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,6 @@
+tor (0.0.1+0.0.2pre19-1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- Peter Palfrader <weasel@debian.org>  Sat, 10 Jan 2004 11:20:06 +0100
+
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000000..b8626c4cff
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+4
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000000..a6b0ee5a75
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,41 @@
+Source: tor
+Section: comm
+Priority: optional
+Maintainer: Peter Palfrader <weasel@debian.org>
+Build-Depends: debhelper (>= 4.1.65), libssl-dev, dpatch
+Standards-Version: 3.6.1
+
+Package: tor
+Architecture: any
+Depends: ${shlibs:Depends}
+Recommends: privoxy, tsocks
+Suggests: mixmaster, mixminion, anon-proxy
+Description: anonymous communication system
+ Tor is a connection-based low-latency anonymous communication system which
+ addresses many flaws in the original onion routing design.
+ .
+ In brief, Onion Routing is a connection-oriented anonymizing communication
+ service. Users choose a source-routed path through a set of nodes, and
+ negotiate a "virtual circuit" through the network, in which each node
+ knows its predecessor and successor, but no others. Traffic flowing down
+ the circuit is unwrapped by a symmetric key at each node, which reveals
+ the downstream node.
+ .
+ Basically Tor provides a distributed network of servers ("onion
+ routers"). Users bounce their tcp streams (web traffic, ftp, ssh, etc)
+ around the routers, and recipients, observers, and even the routers
+ themselves have difficulty tracking the source of the stream.
+ .
+ Note that Tor does not protocol cleaning.  That means there is a danger that
+ application protocols and associated programs can be induced to reveal
+ information about the initiator.  Tor depends on Privoxy and similar protocol
+ cleaners to solve this problem.
+ .
+ Client applications can use the Tor network by connecting to the local
+ onion proxy.  If the application itself does not come with socks support
+ you can use a socks client such as tsocks.  Some web browsers like mozilla
+ and web proxies like privoxy come with socks support, you don't need an
+ extra socks client if you want to use Tor with them.
+ .
+ Remember that this is alpha code, and the network is very small -- Tor will
+ not provide anonymity currently.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000000..34f11556ff
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,40 @@
+This package was debianized by Peter Palfrader <weasel@debian.org> on
+Sat, 10 Jan 2004 11:20:06 +0100.
+
+It was downloaded from http://freehaven.net/tor/
+
+Upstream Authors: Roger Dingledine <arma@freehaven.net>
+                  Nick Mathewson <nickm@freehaven.net>
+                  Matej Pfajfar <badbytes@freehaven.net>
+
+
+Copyright (c) 2001-2004, Roger Dingledine
+Modifications for Debian: Copyright (C) 2004 Peter Palfrader <weasel@debian.org>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+
+    * Neither the names of the copyright owners nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000000..1bf6846f01
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,94 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+	CFLAGS += -O0
+else
+	CFLAGS += -O2
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+	INSTALL_PROGRAM += -s
+endif
+
+config.status: configure
+	dh_testdir
+	CFLAGS="$(CFLAGS)" ./configure \
+		--host=$(DEB_HOST_GNU_TYPE) \
+		--build=$(DEB_BUILD_GNU_TYPE) \
+		--prefix=/usr \
+		--mandir=\$${prefix}/share/man \
+		--infodir=\$${prefix}/share/info \
+		--localstatedir=/var \
+		--sysconfdir=/etc
+
+
+build: build-stamp
+
+build-stamp:  config.status
+	dh_testdir
+
+	$(MAKE)
+
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp
+
+	-$(MAKE) distclean
+
+	dh_clean
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+
+	$(MAKE) install DESTDIR=$(CURDIR)/debian/tor
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs ChangeLog
+	dh_installdocs
+	dh_installexamples
+#	dh_install
+#	dh_installdebconf
+	dh_installlogrotate
+#	dh_installemacsen
+#	dh_installmime
+	dh_installinit
+#	dh_installcron
+	dh_installman
+	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install 
diff --git a/debian/tor.default b/debian/tor.default
new file mode 100644
index 0000000000..af20de9d1a
--- /dev/null
+++ b/debian/tor.default
@@ -0,0 +1,8 @@
+# Defaults for tor initscript
+# sourced by /etc/init.d/tor
+# installed at /etc/default/tor by the maintainer scripts
+
+#
+# This is a POSIX shell fragment
+#
+RUN_DAEMON="yes"
diff --git a/debian/tor.dirs b/debian/tor.dirs
new file mode 100644
index 0000000000..57a1ac7faf
--- /dev/null
+++ b/debian/tor.dirs
@@ -0,0 +1,4 @@
+etc/tor
+var/lib/tor
+var/log/tor
+var/run/tor
diff --git a/debian/tor.docs b/debian/tor.docs
new file mode 100644
index 0000000000..e845566c06
--- /dev/null
+++ b/debian/tor.docs
@@ -0,0 +1 @@
+README
diff --git a/debian/tor.init b/debian/tor.init
new file mode 100644
index 0000000000..2a037ee5ae
--- /dev/null
+++ b/debian/tor.init
@@ -0,0 +1,55 @@
+#! /bin/sh
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/bin/tor
+NAME=tor
+DESC="tor daemon"
+TORLOG=/var/log/tor/log
+TORPID=/var/run/tor/tor.pid
+ARGS="--pidfile $TORPID --logfile $TORLOG --runasdaemon 1"
+
+test -x $DAEMON || exit 0
+
+# Include tor defaults if available
+if [ -f /etc/default/tor ] ; then
+	. /etc/default/tor
+fi
+
+set -e
+
+case "$1" in
+  start)
+	if [ "$RUN_DAEMON" != "yes" ]; then
+		echo "Not starting $DESC (Disabled in /etc/default/tor)."
+	else
+		echo -n "Starting $DESC: "
+		start-stop-daemon --start --quiet --oknodo \
+			--chuid debian-tor:debian-tor \
+			--pidfile $TORPID \
+			--exec $DAEMON -- $ARGS
+		echo "$NAME."
+	fi
+	;;
+  stop)
+	echo -n "Stopping $DESC: "
+	start-stop-daemon --stop --quiet --oknodo --pidfile $TORPID \
+		--exec $DAEMON
+	echo "$NAME."
+	;;
+  reload|force-reload)
+	echo "Reloading $DESC configuration."
+	start-stop-daemon --stop --signal 1 --oknodo --quiet --pidfile $TORPID \
+		--exec $DAEMON
+	;;
+  restart)
+	$0 stop
+	sleep 1
+	$0 start
+	;;
+  *)
+	echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
diff --git a/debian/tor.logrotate b/debian/tor.logrotate
new file mode 100644
index 0000000000..cd8f0de9c0
--- /dev/null
+++ b/debian/tor.logrotate
@@ -0,0 +1,11 @@
+/var/log/tor/log {
+	daily
+	rotate 5
+	compress
+	delaycompress
+	missingok
+	notifempty
+	postrotate
+		/etc/init.d/tor reload > /dev/null
+	endscript
+}
diff --git a/debian/tor.postinst b/debian/tor.postinst
new file mode 100644
index 0000000000..cd2e91beeb
--- /dev/null
+++ b/debian/tor.postinst
@@ -0,0 +1,54 @@
+#!/bin/sh -e
+
+# checking debian-tor account
+
+uid=`getent passwd debian-tor | cut -d ":" -f 3`
+home=`getent passwd debian-tor | cut -d ":" -f 6`
+
+# if there is the uid the account is there and we can do
+# the sanit(ar)y checks otherwise we can safely create it.
+
+if [ "$uid" ]; then
+    # guess??? the checks!!!
+    if [ $uid -ge 100 ] && [ $uid -le 999 ]; then
+    	echo "debian-tor uid check: ok"
+    else
+    	echo "ERROR: debian-tor account has a non-system uid!"
+	echo "Please check /usr/share/doc/tor/README.Debian on how to"
+	echo "correct this problem"
+	exit 1
+    fi
+    if [ "$home" = "/var/lib/tor" ]; then
+        echo "debian-tor homedir check: ok"
+    else
+	echo "ERROR: debian-tor account has an invalid home directory!"
+	echo "Please check /usr/share/doc/tor/README.Debian on how to"
+	echo "correct this problem"
+	exit 1
+    fi
+else
+    # what this might mean?? oh creating a system l^Huser!
+    adduser --quiet \
+            --system \
+            --disabled-password \
+            --home /var/lib/tor \
+	    --no-create-home \
+	    --shell /bin/bash \
+	    --group \
+    debian-tor
+fi
+
+# ch{owning,moding} things around
+# We will do nothing across upgrades.
+
+if [ "$2" = "" ]; then
+    for i in lib log run; do
+	chown -R debian-tor:debian-tor /var/$i/tor
+	chmod -R 700 /var/$i/tor
+	find /var/$i/tor -type f -exec chmod 600 '{}' ';'
+    done
+fi
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/tor.postrm b/debian/tor.postrm
new file mode 100644
index 0000000000..cb3707e27f
--- /dev/null
+++ b/debian/tor.postrm
@@ -0,0 +1,11 @@
+#!/bin/sh -e
+
+if [ "$1" = "purge" ]; then
+    # logs have to be removed according to policy.
+    rm -rf /var/log/tor/
+    rm -rf /var/lib/tor/
+fi
+
+#DEBHELPER#
+
+exit 0
-- 
GitLab