From: <dts...@us...> - 2003-06-04 18:15:11
|
Update of /cvsroot/phpwebsite-comm/scripts/proj-admin In directory sc8-pr-cvs1:/tmp/cvs-serv22172 Added Files: cvsrelease Log Message: Initial add --- NEW FILE: cvsrelease --- #!/bin/sh # cvsrelease script for phpwebsite-comm project # Bastardized from cvsutils' cvsrelease script # $Id: cvsrelease,v 1.1 2003/06/04 18:15:07 dtseiler Exp $ # # Automates the process of tagging, exporting and packaging a release from CVS. # Steve Purcell <stephen_purcell at yahoo dot com> # AUTHOR='Steve Purcell <stephen_purcell at yahoo dot com>' VERSION=`echo '$Revision: 1.1 $'|cut -d' ' -f2` PROJECT='Visit http://cvsutils.sourceforge.net/ for updates and information' progname=`basename $0` function usage() { cat <<EOF 1>&2 Creates appropriately named .tar.gz and .zip files containing the files in the current \$CVSROOT for release 'release-tag' of the CVS module 'cvsmodule'. usage: $progname [options] -t release-tag -r release-number type cvsmodule options: -t The CVS tag name -r The release number, e.g. 1.2 -b branch Make the release in the branch with the given name (not allowed unless -T is also set) -z Make a '.zip'. release file as well as the usual '.tar.gz' file -T Also create the CVS tag (use with caution) -f flavour Name the release files cvsmodule-flavour-releasenum.tar.gz etc. -x script Execute script inside exported module directory before Packaging -h Show this help page -V Show version information The following example would create a CVS tag '0-3' for the module 'test', and package that module into both a 'tar.gz' archive and a 'zip' archive containing a top-level directory 'test-0.3'. % $progname -Tz -t 0-3 -r 0.3 module test If you are releasing a theme, use "theme" instead of "module", followed by your theme name as it is in the phpwebsite-comm cvs. If a script is specified using the '-x' option, it will be executed in the root directory of the exported module before the release file is created. This option can be used to remove unwanted portions of a release, or to pre-compile binaries for inclusion in the release file. The release tag and number are exported to the script as \$RELEASETAG and \$RELEASENUM respectively. Often that script will be used in conjunction with the '-f' option. EOF } function showversion() { echo "$progname version $VERSION, by $AUTHOR" echo "$PROJECT" } function message() { echo "$progname: $1" 1>&2 } function error_exit() { message "error: $1" 1>&2 tidyup exit 1 } function tidyup() { if [ -n "$tempdir" -a -d "$tempdir" ]; then rm -r $tempdir fi } ## Begin option parsing while getopts t:r:zThx:f:Vb: opt; do case "$opt" in t) releasetag="$OPTARG" ;; r) releasenum="$OPTARG" ;; b) frombranch="$OPTARG" ;; z) makezip=1 ;; T) maketag=1 ;; f) flavour="$OPTARG" ;; x) releasescript="$OPTARG" ;; V) showversion; exit 0 ;; h) usage; exit 0 ;; *) usage; exit 2 ;; esac done shift $(($OPTIND - 1)) ## Check values of options type=$1 module=$2 if [ -z "$type" -o -z "$module" -o -z "$releasetag" -o -z "$releasenum" ]; then message "mandatory option(s) missing" usage exit 2 fi if [ -n "$frombranch" -a -z "$maketag" ]; then message "option -b cannot be used without -T" usage exit 2 fi ## Prepare a directory in which to work orig_dir=$PWD tempdir=/tmp/$progname.$$ mkdir $tempdir || error_exit "couldn't create $tempdir" cd $tempdir #message "CVS root is $CVSROOT" ## Create the CVS tag if it was requested if [ "$maketag" ]; then if [ -n "$frombranch" ]; then branch=$frombranch else branch=HEAD fi cvs -d:ext:dts...@cv...:/cvsroot/phpwebsite-comm co -r $branch ${type}s || \ error_exit "error checking out from CVS" cd phpwebsite-comm/${type}s cvs tag $releasetag || \ error_exit "error setting tag '$releasetag'" cd ../../ rm -rf phpwebsite-comm fi ## Choose a name for the top level directory releasedir=$type-$module-$releasenum ## Export the files to package message "exporting from CVS" cvs -d:pserver:ano...@cv...:/cvsroot/phpwebsite-comm export -r$releasetag -d $releasedir ${type}s/$module || \ error_exit "error exporting code from CVS" ## Choose a name for the generated archive files if [ -n "$flavour" ]; then archive_base=$orig_dir/$type-$module-$flavour-$releasenum else archive_base=$orig_dir/$type-$module-$releasenum fi if [ -n "$releasescript" ]; then message "running release script '$releasescript' in $releasedir" (cd $releasedir && \ RELEASETAG=$releasetag RELEASENUM=$releasenum $releasescript) || \ error_exit "error running release script; aborting." fi ## Add version to VERSION file #echo $releasenum > $releasedir/php/lib/VERSION ## Create a '.tar.gz' tarball=$archive_base.tar.gz message "creating release tarball: $tarball" tar cfz $tarball $type-$module-$releasenum || \ error_exit "couldn't create $tarball" ## Upload to sourceforge ncftpput -u anonymous -p do...@se... upload.sourceforge.net /incoming $tarball ## And a '.zip' too if it was requested if [ "$makezip" ]; then zipfile=$archive_base.zip message "creating release zipfile: $zipfile" zip -qr $zipfile $type-$module-$releasenum || \ error_exit "couldn't create $zipfile" ## Upload to sourceforge ncftpput -u anonymous -p do...@se... upload.sourceforge.net /incoming $zipfile fi ## finish up cd $orig_dir tidyup message "done" exit 0 |