2010-05-11 15:01:37 +02:00
|
|
|
#!/bin/sh
|
2010-05-13 00:38:27 +02:00
|
|
|
#
|
2010-05-11 15:01:37 +02:00
|
|
|
# Slackware build script for tor
|
2010-05-13 00:38:27 +02:00
|
|
|
#
|
2011-01-30 15:54:16 +01:00
|
|
|
# Copyright 2011-2012 Marco Bonetti <sid77@slackware.it>
|
2010-05-13 00:38:27 +02:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use of this script, with or without modification, is
|
|
|
|
# permitted provided that the following conditions are met:
|
|
|
|
#
|
|
|
|
# 1. Redistributions of this script must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''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 AUTHOR 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.
|
2010-05-11 15:01:37 +02:00
|
|
|
|
|
|
|
PRGNAM=tor
|
2011-03-09 17:17:43 +01:00
|
|
|
VERSION=0.2.1.30
|
2010-05-11 15:01:37 +02:00
|
|
|
BUILD=${BUILD:-1}
|
|
|
|
TAG=${TAG:-_SBo}
|
2010-05-11 22:25:49 +02:00
|
|
|
|
2010-05-12 17:44:17 +02:00
|
|
|
# Select tor's default user/group
|
|
|
|
TOR_USER=${TOR_USER:-tor}
|
|
|
|
TOR_UID=${TOR_UID:-220}
|
|
|
|
TOR_GROUP=${TOR_GROUP:-tor}
|
|
|
|
TOR_GID=${TOR_GID:-220}
|
|
|
|
|
2010-06-04 07:14:17 +02:00
|
|
|
# Automatically determine the architecture we're building on:
|
|
|
|
if [ -z "$ARCH" ]; then
|
|
|
|
case "$( uname -m )" in
|
|
|
|
i?86) ARCH=i486 ;;
|
|
|
|
arm*) ARCH=arm ;;
|
|
|
|
# Unless $ARCH is already set, use uname -m for all other archs:
|
|
|
|
*) ARCH=$( uname -m ) ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2010-05-11 15:01:37 +02:00
|
|
|
CWD=$(pwd)
|
|
|
|
TMP=${TMP:-/tmp/SBo}
|
|
|
|
PKG=$TMP/package-$PRGNAM
|
|
|
|
OUTPUT=${OUTPUT:-/tmp}
|
|
|
|
|
|
|
|
if [ "$ARCH" = "i486" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
|
2010-05-12 17:44:17 +02:00
|
|
|
LIBDIRSUFFIX=""
|
2010-05-11 15:01:37 +02:00
|
|
|
elif [ "$ARCH" = "i686" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
|
2010-05-12 17:44:17 +02:00
|
|
|
LIBDIRSUFFIX=""
|
2010-05-11 22:25:49 +02:00
|
|
|
elif [ "$ARCH" = "x86_64" ]; then
|
|
|
|
SLKCFLAGS="-O2 -fPIC"
|
2010-05-12 17:44:17 +02:00
|
|
|
LIBDIRSUFFIX="64"
|
2010-06-04 07:14:17 +02:00
|
|
|
else
|
|
|
|
SLKCFLAGS="-O2"
|
|
|
|
LIBDIRSUFFIX=""
|
2010-05-12 17:44:17 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
bailout() {
|
|
|
|
echo " You must have a $TOR_USER user and $TOR_GROUP group to run this script. "
|
|
|
|
echo " Something like this should suffice for most systems: "
|
|
|
|
echo " # groupadd -g $TOR_GID $TOR_GROUP "
|
|
|
|
echo " # useradd -u $TOR_UID -g $TOR_GID -c \"The Onion Router\" -d /dev/null -s /bin/false $TOR_USER "
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Bail if user and/or group isn't valid on your system
|
|
|
|
# uid=220 is suggested to avoid conflicts with other SBo packages,
|
|
|
|
# but it's your call: http://slackbuilds.org/uid_gid.txt
|
|
|
|
if ! grep -q "^$TOR_USER:" /etc/passwd; then
|
|
|
|
bailout
|
|
|
|
elif ! grep -q "^$TOR_GROUP:" /etc/group; then
|
|
|
|
bailout
|
2010-05-11 15:01:37 +02:00
|
|
|
fi
|
|
|
|
|
2010-05-12 17:44:17 +02:00
|
|
|
set -eu
|
|
|
|
|
2010-05-11 15:01:37 +02:00
|
|
|
rm -rf $PKG
|
|
|
|
mkdir -p $TMP $PKG $OUTPUT
|
2010-05-11 22:25:49 +02:00
|
|
|
cd $TMP
|
2010-05-11 15:01:37 +02:00
|
|
|
rm -rf $PRGNAM-$VERSION
|
2010-05-11 22:25:49 +02:00
|
|
|
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
|
|
|
|
cd $PRGNAM-$VERSION
|
2010-05-11 15:01:37 +02:00
|
|
|
chown -R root:root .
|
|
|
|
chmod -R u+w,go+r-w,a-s .
|
|
|
|
|
|
|
|
CFLAGS="$SLKCFLAGS" \
|
|
|
|
./configure \
|
|
|
|
--prefix=/usr \
|
|
|
|
--sysconfdir=/etc \
|
|
|
|
--localstatedir=/var \
|
2010-05-12 17:44:17 +02:00
|
|
|
--mandir=/usr/man \
|
|
|
|
--libdir=/usr/lib${LIBDIRSUFFIX} \
|
|
|
|
--with-tor-user=$TOR_USER \
|
2010-05-13 00:38:27 +02:00
|
|
|
--with-tor-group=$TOR_GROUP \
|
|
|
|
--build=$ARCH-slackware-linux
|
2010-05-11 15:01:37 +02:00
|
|
|
|
2010-05-11 22:25:49 +02:00
|
|
|
make
|
|
|
|
make install-strip DESTDIR=$PKG
|
2010-05-11 15:01:37 +02:00
|
|
|
|
2010-05-12 17:44:17 +02:00
|
|
|
# Create/install stuff that makes tor work (better)
|
|
|
|
mkdir -p $PKG/var/{run,log,lib}/tor
|
|
|
|
chown $TOR_USER:$TOR_GROUP $PKG/var/{run,log,lib}/tor
|
|
|
|
chmod 0700 $PKG/var/lib/tor
|
|
|
|
install -D -m 0755 $CWD/rc.tor $PKG/etc/rc.d/rc.tor.new
|
|
|
|
install -D -m 0755 contrib/torctl $PKG/usr/bin/torctl
|
2010-06-16 15:33:16 +02:00
|
|
|
install -D -m 0644 $CWD/logrotate.tor $PKG/etc/logrotate.d/tor.new
|
2010-05-12 17:44:17 +02:00
|
|
|
mv $PKG/etc/tor/torrc.sample $PKG/etc/tor/torrc.new
|
|
|
|
mv $PKG/etc/tor/tor-tsocks.conf $PKG/etc/tor/tor-tsocks.conf.new
|
|
|
|
|
2010-06-16 15:33:16 +02:00
|
|
|
find $PKG/usr/man -type f -exec gzip -9 {} \;
|
|
|
|
for i in $(find $PKG/usr/man -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done
|
2010-05-11 15:01:37 +02:00
|
|
|
|
2010-05-11 22:25:49 +02:00
|
|
|
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/spec
|
|
|
|
cp -a AUTHORS ChangeLog INSTALL LICENSE README ReleaseNotes \
|
|
|
|
$PKG/usr/doc/$PRGNAM-$VERSION
|
2010-05-11 15:01:37 +02:00
|
|
|
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
|
2010-06-16 15:33:16 +02:00
|
|
|
cat $CWD/README.SLACKWARE > $PKG/usr/doc/$PRGNAM-$VERSION/README.SLACKWARE
|
2010-05-11 15:01:37 +02:00
|
|
|
|
2010-05-13 00:38:27 +02:00
|
|
|
mkdir -p $PKG/install
|
2010-05-11 15:01:37 +02:00
|
|
|
cat $CWD/slack-desc > $PKG/install/slack-desc
|
|
|
|
cat $CWD/doinst.sh > $PKG/install/doinst.sh
|
|
|
|
|
|
|
|
cd $PKG
|
2010-05-13 00:38:27 +02:00
|
|
|
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
|