blob: ca07b0f3003f76762fb2e048f6f179884e05d3c8 [file] [log] [blame]
Dave Shieldb3df9cf2007-01-24 13:49:38 +00001#!/bin/sh
Robert Story3eb149e2002-08-01 18:51:44 +00002#
3# $Id$
4#
Dave Shieldb3df9cf2007-01-24 13:49:38 +00005CVS_RSH=ssh; export CVS_RSH
Robert Story3eb149e2002-08-01 18:51:44 +00006TAG=
Robert Storyd6e51b82002-09-30 18:58:42 +00007WO=0
Robert Story842c0882003-08-17 23:17:00 +00008DEST=
Robert Story3eb149e2002-08-01 18:51:44 +00009
Robert Story842c0882003-08-17 23:17:00 +000010if [ "x$1" = "x-u" ]; then
11 DEST=$2
12 shift 2
Robert Story8d20bc52006-10-18 14:45:18 +000013
14 # gnu tar (as of 1.15.1) is unable to create portable tar archives,
15 # especially if long file names (>100 char) are present.
16 # star is a better replacement.
17 if [ -x /usr/bin/star ]; then
18 TAR='/usr/bin/star -Hustar -not -pat="*/CVS/*" -c -f'
19 elif [ -x /bin/tar ]; then
20 TAR="/bin/tar --exclude=CVS -c -f"
Robert Storya3e57422007-05-15 15:55:31 +000021 echo "warning: star not available, using (less portable) tar..."
Robert Story8d20bc52006-10-18 14:45:18 +000022 else
23 echo "neither /usr/bin/star nor /bin/tar found."
24 exit
25 fi
Robert Story842c0882003-08-17 23:17:00 +000026fi
Robert Story31e44f62002-11-05 16:59:40 +000027
Robert Story3eb149e2002-08-01 18:51:44 +000028if [ $# -eq 0 ]; then
Robert Story842c0882003-08-17 23:17:00 +000029 DIR=$PWD
Robert Story3eb149e2002-08-01 18:51:44 +000030else
Robert Story31e44f62002-11-05 16:59:40 +000031 if [ $# -ne 1 ]; then
32 echo "usage: $0 <working directory>"
33 exit
34 fi
35 DIR=$1
Robert Story3eb149e2002-08-01 18:51:44 +000036fi
37
Robert Story842c0882003-08-17 23:17:00 +000038if [ -z ${DIR##*/} ];then
39 DIR=${DIR%/*}
40fi
41SUBD=${DIR##*/}
42PARENT=${DIR%*$SUBD}
43#echo "$DIR = $PARENT + $SUBD"
44
Robert Story3eb149e2002-08-01 18:51:44 +000045if [ ! -d $DIR ]; then
Robert Story31e44f62002-11-05 16:59:40 +000046 echo "no such directory '$DIR'"
47 exit
Robert Story3eb149e2002-08-01 18:51:44 +000048fi
49
50if [ ! -d $DIR/CVS ]; then
Robert Story31e44f62002-11-05 16:59:40 +000051 echo "'$DIR' has no CVS directory!"
52 exit
Robert Story3eb149e2002-08-01 18:51:44 +000053fi
54
55if [ ! -f $DIR/CVS/Repository ]; then
Robert Story31e44f62002-11-05 16:59:40 +000056 echo "'$DIR' has no CVS/Repository!"
57 exit
Robert Story3eb149e2002-08-01 18:51:44 +000058fi
59
60if [ ! -f $DIR/CVS/Root ]; then
Robert Story31e44f62002-11-05 16:59:40 +000061 echo "'$DIR' has no CVS/Root!"
62 exit
Robert Story3eb149e2002-08-01 18:51:44 +000063fi
64
65if [ -f $DIR/CVS/Tag ]; then
Robert Story842c0882003-08-17 23:17:00 +000066 TAG=`cat $DIR/CVS/Tag | cut -c 2-`
67 CMDTAG="-r $TAG"
Robert Story3eb149e2002-08-01 18:51:44 +000068fi
69
70REP="`cat $DIR/CVS/Repository`"
71ROOT="`cat $DIR/CVS/Root`"
72
Robert Story842c0882003-08-17 23:17:00 +000073cd $DIR
74#echo $PWD
75# COMMAND="cvs -q -z3 -d $ROOT co $TAG -d $DIR $REP"
76
77COMMAND="cvs -q -z3 -d $ROOT update -P -d $CMDTAG"
Robert Story3eb149e2002-08-01 18:51:44 +000078
Robert Storyd6e51b82002-09-30 18:58:42 +000079if [ ! -w $DIR/CVS ]; then
Robert Story31e44f62002-11-05 16:59:40 +000080 if [ -O $DIR/CVS ]; then
81 WO=1
82 echo "Making $DIR writable"
83 chmod -R u+w $DIR
84 fi
Robert Storyd6e51b82002-09-30 18:58:42 +000085fi
86
Robert Story3eb149e2002-08-01 18:51:44 +000087echo "Updating directory $DIR with $TAG $REP..."
88echo "$COMMAND"
89
90$COMMAND
Robert Storya856f612004-06-07 18:39:29 +000091rc=$?
92if [ $rc -ne 0 ]; then
93 echo "cvs command returned $?"
94fi
Robert Storyd6e51b82002-09-30 18:58:42 +000095
96if [ $WO -eq 1 ]; then
Robert Story31e44f62002-11-05 16:59:40 +000097 echo "Making $DIR read-only"
98 chmod -R a-w $DIR
Robert Storyd6e51b82002-09-30 18:58:42 +000099fi
100
Robert Story842c0882003-08-17 23:17:00 +0000101if [ ! -z $DEST ]; then
102 if [ -z $TAG ]; then
103 TAG=MAIN
104 fi
105
Robert Storya856f612004-06-07 18:39:29 +0000106 if [ $rc -ne 0 ]; then
107 echo "skipping upload"
108 else
Robert Story842c0882003-08-17 23:17:00 +0000109 cd ..
110# echo $PWD
Robert Storye39cc7c2003-08-21 21:28:55 +0000111 DATE=`date +%Y%m%d_%H%M`
112 SOURCE=$REP-cvs-$TAG"_$DATE"
Robert Story5ca02392006-03-08 18:48:38 +0000113 $TAR /tmp/$SOURCE.tar $SUBD
Robert Story842c0882003-08-17 23:17:00 +0000114 gzip -f --best /tmp/$SOURCE.tar
115 scp /tmp/$SOURCE.tar.gz $DEST
Robert Story4bb75b82004-03-22 23:37:22 +0000116 rm -f /tmp/$SOURCE.tar.gz
Robert Storya856f612004-06-07 18:39:29 +0000117 fi
Robert Story842c0882003-08-17 23:17:00 +0000118fi