| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- #!/bin/sh
- #edit this to your homedir (no trailing slash)
- #add in 'cont' support for NOT using make clean.
- TCLDIR="/home/wheel/bryan"
- #### DO NOT EDIT BELOW THIS LINE #####
- # Awk out the version from source
- ver=`cat src/main.c 2>&1 | grep "char" | awk '/egg_version/ {print $4}' | sed -e 's/\"//g' | sed -e 's/\;//g'`
- numver=`cat src/main.c 2>&1 | grep "int" | awk '/egg_numver =/ {print $4}' | sed -e 's/\;//g'`
- if test -z "$ver"
- then
- ver="?.?.?"
- fi
- echo "*** wraith v${ver}/${numver} builder ***"
- echo ""
- debug=0
- all=0
- hub=0
- leaf=0
- #if test $# -lt 1; then
- if test -z "$1"; then
- echo "Usage: $0 -d all|leaf|hub pack.conf"
- echo " -d: Builds a debug package."
- echo ""
- exit 1
- elif [ $1 = "all" ]; then
- all=1
- elif [ $1 = "leaf" ]; then
- leaf=1
- elif [ $1 = "hub" ]; then
- hub=1
- elif [ $1 = "-d" ]; then
- debug=1
- test=" "
- if ! test $# -lt 2; then
- if [ $2 = "all" ]; then
- all=1
- elif [ $2 = "leaf" ]; then
- leaf=1
- elif [ $2 = "hub" ]; then
- hub=1
- else
- all=1
- pack=$2
- fi
- else
- all=1
- fi
- else
- all=1
- pack=$1
- fi
- d=""
- if [ $debug = "1" ]; then
- d="d"
- fi
- if ! test $pack
- then
- if [ $debug = "1" ]; then
- pack=$3
- else
- pack=$2
- fi
- fi
- if [ $all = "1" ]; then
- leaf=1
- hub=1
- fi
- if test $pack
- then
- packname=$pack
- else
- packname=default
- fi
- # Verify we got the config file
- origpack=$packname
- if ! test -f $packname; then
- packname=$packname.conf
- fi
- if ! test -f $packname; then
- echo "[!] Can't find pack configuration file $origpack"
- exit 1
- else
- echo "[*] Using pack configuration file: $packname"
- fi
- # Figure what bins we're making
- case `uname` in
- Linux) os=Linux;;
- FreeBSD) case `uname -r` in
- 5*) os=FreeBSD5;;
- 4*) os=FreeBSD4;;
- 3*) os=FreeBSD3;;
- esac;;
- OpenBSD) os=OpenBSD;;
- esac
- if test -z $os
- then
- echo "[!] Automated packaging disabled, `uname` isn't recognized"
- fi
- echo "[*] Building pack for $os"
- # Run ./configure, then verify it's ok
- echo "[*] Configuring..."
- umask 077 >/dev/null
- ./configure --disable-tcl-threads --with-tcllib=${TCLDIR}/lib/libtcl8.4.a --with-tclinc=${TCLDIR}/include/tcl.h > /dev/null 2>configure.temp
- #if test "`cat configure.temp`"
- #then
- # echo "Configure error'd"
- # cat configure.temp
- #
- # exit 1
- #fi
- #rm -f configure.temp
- # make clean, just in case
- echo "[*] Cleaning up old binaries..."
- make clean > /dev/null
- # Read the config
- echo -n "[*] Compiling with:"
- for cnf in `cat $packname | grep -v "^#"`
- do
- defines="$defines -DS_$cnf"
- echo -n "$cnf "
- done
- echo ""
- # Build utils and check we got the bins
- echo "[*] Building utils..."
- make utils CFLGS="$defines" > /dev/null
- if ! test -f stringfix
- then
- echo "[!] Util build failed"
- exit 1
- fi
- if [ $leaf = "1" ]; then
- # Build leaf and check
- echo "[*] Building ${d}leaf..."
- make ${d}leaf CFLGS="$defines" > /dev/null
- if ! test -f leaf
- then
- echo "[!] ${d}leaf build failed"
- exit 1
- fi
- fi
- if [ $hub = "1" ]; then
- # Build hub and check
- echo "[*] Building ${d}hub..."
- make ${d}hub CFLGS="$defines" > /dev/null
- if ! test -f hub
- then
- echo "[!] ${d}hub build failed"
- exit 1
- fi
- fi
- # Wrap it nicely up into an archive
- echo "[*] Packaging..."
- packname=`basename $packname .conf`
- if [ $all = "1" ]; then
- fls="leaf hub"
- elif [ $leaf = "1" ]; then
- fls="leaf"
- elif [ $hub = "1" ]; then
- fls="hub"
- fi
- for bin in $fls
- do
- mv -f $bin $bin.$os.$numver
- done
- tar -zcf $packname.$os.$numver.tgz *.$os.$numver
- rm -f *.$os.$numver
- echo "Binaries are now in '$packname.$os.$numver.tgz'."
- exit 0
|