added files
[bcm963xx.git] / userapps / opensource / net-snmp / dist / cvsup
1 #!/bin/bash
2 #
3 # $Id: cvsup,v 1.4 2002/11/05 16:59:40 rstory Exp $
4 #
5 export CVS_RSH=ssh
6 TAG=
7 WO=0
8
9
10 if [ $# -eq 0 ]; then
11     DIR=.
12 else
13     if [ $# -ne 1 ]; then
14         echo "usage: $0 <working directory>"
15         exit
16     fi
17     DIR=$1
18 fi
19
20 if [ ! -d $DIR ]; then
21     echo "no such directory '$DIR'"
22     exit
23 fi
24
25 if [ ! -d $DIR/CVS ]; then
26     echo "'$DIR' has no CVS directory!"
27     exit
28 fi
29
30 if [ ! -f $DIR/CVS/Repository ]; then
31     echo "'$DIR' has no CVS/Repository!"
32     exit
33 fi
34
35 if [ ! -f $DIR/CVS/Root ]; then
36     echo "'$DIR' has no CVS/Root!"
37     exit
38 fi
39
40 if [ -f $DIR/CVS/Tag ]; then
41     TAG="-r `cat $DIR/CVS/Tag | cut -c 2-`"
42 fi
43
44 REP="`cat $DIR/CVS/Repository`"
45 ROOT="`cat $DIR/CVS/Root`"
46
47 if [ "x$DIR" = "x." ]; then
48     COMMAND="cvs -q -z3 -d $ROOT update -P -d $TAG"
49 else
50     COMMAND="cvs -q -z3 -d $ROOT co $TAG -d $DIR $REP"
51 fi
52
53 if [ ! -w $DIR/CVS ]; then
54     if [ -O $DIR/CVS ]; then
55         WO=1
56         echo "Making $DIR writable"
57         chmod -R u+w $DIR
58     fi
59 fi
60
61 echo "Updating directory $DIR with $TAG $REP..."
62 echo "$COMMAND"
63
64 $COMMAND
65
66 if [ $WO -eq 1 ]; then
67     echo "Making $DIR read-only"
68     chmod -R a-w $DIR
69 fi
70