#!/bin/sh ## $Id: export-tarball 8916 2005-11-23 18:09:55Z korpela $ # Create a tarball from CVS or SVN export. # example usage: # CVSROOT=/usr/local/warez/cvsroot \ # CHECKOUT='cvs export -r HEAD boinc' \ # DIR='boinc' \ # FILENAME_TGZ="boinc-cvs-TODAY.tar.gz" \ # FILENAME_ZIP="boinc-cvs-TODAY.zip" \ # DESTINATION="/disks/milkyway/a/users/anderson/boinc/doc/source/nightly/" \ # /disks/philmor/a/users/quarl/bin/export-tarball # CHECKOUT='svn export http://svn.quarl.org/repos/coursesurvey/trunk/coursesurvey' \ # DIR=coursesurvey \ # FILENAME_TGZ="coursesurvey-rSVNREVISION.tar.gz" \ # FILENAME_ZIP="coursesurvey-rSVNREVISION.zip" \ # DESTINATION="ftp://upload.sourceforge.net/incoming" \ # /home/quarl/bin/export-tarball # Note: requires GNU tar (if you want to use other tar need to separate gzip # step) die() { echo "ERROR in $0 on `hostname`:" echo "$1" [ "$2" ] && cat "$2" exit 1 } reqeval() { test -n "$VERBOSE" && echo "Executing: $1" eval "$1" || die "error executing: $1" } reqeval_log() { test -n "$VERBOSE" && echo "Executing: $1" eval "$1" > $2 2>&1 || die "error executing: $1" $2 } upload() { if echo "$DESTINATION" | grep '^ftp://' >/dev/null ; then ftp_upload "$1" else file_upload "$1" fi } file_upload() { test -n "$VERBOSE" && echo "Putting $1 in $DESTINATION" reqeval "mv $1 $DESTINATION" } ftp_upload() { SERVER=`echo "$DESTINATION" | sed 's,^ftp://,,' | sed 's,/.*,,'` DIRECTORY=`echo "$DESTINATION" | sed 's,^ftp://[^/]*',,` test -n "$VERBOSE" && echo "Uploading $1 to ftp site $SERVER $DIRECTORY" reqeval "ncftpput $SERVER $DIRECTORY $1" } if [ -z "$USER" ]; then USER=$LOGNAME fi if ttyo 2>/dev/null ; then VERBOSE=1 fi test -n "$CHECKOUT" || die "No CHECKOUT specified" test -n "$DIR" || die "No DIR specified" test -n "$FILENAME_TBZ" || die "No FILENAME_TBZ specified" test -n "$DESTINATION" || die "No DESTINATION specified" TMPDIR=/tmp/export-tarball reqeval "rm -rf $TMPDIR" reqeval "mkdir -p $TMPDIR" reqeval "cd $TMPDIR" reqeval_log "$CHECKOUT" checkout.log reqeval "mv $DIR_CO $DIR" reqeval "sed '/#define\ BOINC_PRERELEASE\ 1/ c\//#define\ BOINC_PRERELEASE\ 0' -i $DIR/version.h.in" test -d "$DIR" || die "No DIR $DIR after CHECKOUT" #TODAY=`date +%Y-%m-%d` # SVNREVISION=`svnlastchangedversion "$DIR" 2>/dev/null` #FILENAME_TGZ=`echo "$FILENAME_TGZ" | sed "s/TODAY/$TODAY/"` # FILENAME_TGZ=`echo "$FILENAME_TGZ" | sed "s/SVNREVISION/$SVNREVISION/"` # FILENAME_ZIP=`echo "$FILENAME_ZIP" | sed "s/SVNREVISION/$SVNREVISION/"` test -n "$FILENAME_TBZ" && reqeval_log "tar cjvf $FILENAME_TBZ $DIR" tar.log upload $FILENAME_TBZ reqeval "rm -rf $TMPDIR"