#!/bin/sh :<<'########################################################################' Usage: make_redsocks.sh This script downloads and constructs the redsocks extension. ------------------------------------------------------------------------ Change-log: 2011-10-10 First version. ------------------------------------------------------------------------ This script was written in 2011 by vitex from forum.tinycorelinux.net. To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. See http://creativecommons.org/publicdomain/zero/1.0/ for a copy of the CC0 Public Domain Dedication under which this work is distributed. ######################################################################## # Specify the name of the extension. EXTENSION=redsocks # Specify the base portion of the extension. EXTENSION0=redsocks #----------------------------------------------------------------------- # Install the extensions needed to build this extension. tce-load -wi compiletc.tcz wget.tcz groff.tcz libevent.tcz libevent-dev.tcz #----------------------------------------------------------------------- # Specify the temporary directory that will contain the build components. TMP=/tmp/tcz # Specify the directory in which the squashfs files will be assembled. SQUASHFS=$TMP/squashfs # Specify the directory in which the submission package will be assembled. PACKAGE=$TMP/package #----------------------------------------------------------------------- # Specify the location containing the software distribution. #VERSION=TBD DOWNLOAD=https://github.com/darkk/redsocks/tarball/master #----------------------------------------------------------------------- # Download if necessary. tar tzf $TMP/$EXTENSION-master.tgz 1>/dev/null 2>&1 || wget --no-check-certificate -O- $DOWNLOAD >$TMP/$EXTENSION-master.tgz #----------------------------------------------------------------------- # Compute the name of the directory into which the software will be unpacked. DIRECTORY=$(tar tzf $TMP/$EXTENSION-master.tgz | head -1) DIRECTORY=$TMP/${DIRECTORY%%/} VERSION=${DIRECTORY##*$EXTENSION-} #----------------------------------------------------------------------- # Unpack the software. rm -fR $DIRECTORY tar xzf $TMP/$EXTENSION-master.tgz -C $TMP #----------------------------------------------------------------------- export CFLAGS="-march=i486 -mtune=i686 -Os -pipe" export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe" export LDFLAGS="-Wl,-O1" #----------------------------------------------------------------------- # Build the software. { cd $DIRECTORY ; make touch $TMP/TIMESTAMP } #----------------------------------------------------------------------- # Copy the installed files (those newer than $TMP/TIMESTAMP) from # /usr/local to $SQUASHFS/usr/local. ( cd / find usr/local -not -type d -newer $TMP/TIMESTAMP | grep -v /man/ | cpio -pvd $SQUASHFS ) #----------------------------------------------------------------------- # Install the executable. mkdir -p $SQUASHFS/usr/local/bin cp $DIRECTORY/$EXTENSION $SQUASHFS/usr/local/bin #----------------------------------------------------------------------- # Install the README and example configuration file. mkdir -p $SQUASHFS/usr/local/share/$EXTENSION { cd $SQUASHFS/usr/local/share/$EXTENSION for f in redsocks.conf.example README ; do cp $DIRECTORY/$f . done } #----------------------------------------------------------------------- # Create $EXTENSION.tcz.dep. echo libevent.tcz >$PACKAGE/$EXTENSION.tcz.dep #----------------------------------------------------------------------- # Create $EXTENSION.tcz.info. cat >$PACKAGE/$EXTENSION.tcz.info <