#!/bin/sh
#
# $Id: make_caudium_tar,v 1.4 2000/10/10 00:23:26 kiwi Exp $
#
# Env Variables
#

LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/local/X11/lib:/opt/mysql/lib/mysql:/opt/freeware/lib:/usr/dt/lib:/usr/openwin/lib:/opt/wapgw/lib:
PATH=/opt/proftpd/bin:/usr/local/bin:/bin:/usr/ccs/bin:/etc:/usr/etc:/usr/local/X11/bin:/opt/mysql/bin:/opt/freeware/bin:/usr/ucb:/usr/openwin/bin:/usr/local/etc:/usr/sbin:/usr/dt/bin:/sbin:/opt/ipf/bin:/opt/wapgw/bin:
MANPATH=/usr/local/man:/opt/freeware/man:/usr/man:/usr/local/X11/man:/opt/ipf/man
export LD_LIBRARY_PATH PATH MANPATH
PAGER=less
EDITOR=vi
CC=gcc
CXX=gcc
#
# We don't want to force ia32 to compile for sparc :-)
#CFLAGS="-msupersparc -O6"
#CXXFLAGS="-msupersparc -O6"
export PAGER EDITOR CC CFLAGS CXX CXXFLAGS
PS1='\u@\h:\w\$ '
export PS1
TEMPDIR=/tmp

# Make the Daily Package of Caudium webserver
#
DATE=`date '+%Y%m%d'`
CVSDIR=/opt/BUILD/cvs
CHROOTDIR=/tmp/caudium-1.0
BUILDIR=${CHROOTDIR}/tmp
SETUPCHROOT=/usr/local/sbin/setup_chroot
DIRTMP=/tmp/$0.$$
#
# Creating Directories..
#
mkdirhier ${BUILDIR}

#
# Update the CVS directory
#
cd ${CVSDIR}/caudium
cvs -Q -z3 update -Pd > /dev/null

#
# Copy the files to a temporary repository
#
cd ${CVSDIR}

#
mkdir $DIRTMP
tar -c -l -p -f - caudium | (cd $DIRTMP && tar -x -v -l -p -f -)
cd $DIRTMP
cd caudium
./autogen.sh
cd ..
tar -c -l -p -f $TEMPDIR/caudium-1.0.0.$DATE.tar caudium

#
# Try to find the packer we have
#
PACKERS="bzip2 gzip compress"
DIRS="/usr/bin /usr/local/bin"

#
# Try to find the packer we have
#
PACKERS="bzip2 gzip compress"
DIRS="/usr/bin /usr/local/bin"

for d in ${DIRS}; do
    for f in ${PACKERS}; do
	if test -x ${d}/${f}; then
	    PACKER=${f}
	    PACKER_DIR=${d}
	    break
	fi
    done
done

if test -z "$PACKER"; then
    echo Cannot find any compression utility. Aborting.
    exit 1
fi

case ${PACKER} in
    bzip2) PFLAGS=-9f ;;
    gzip) PFLAGS=-9nf ;;
    compress) PFLAGS= ;;
esac

${PACKER_DIR}/${PACKER} ${PFLAGS} ${TEMPDIR}/caudium-1.0.0.${DATE}.tar

cd /tmp
rm -rf $DIRTMP
