Whamcloud - gitweb
- lustrecvs now updates and reexecs itself
[fs/lustre-release.git] / lustrecvs
1 #!/bin/sh
2
3 LC_COLLATE="C"
4 progname="${0##*/}"
5
6 warn ()
7 {
8     [ "$1" ] && echo >&2
9     [ "$1" ] && echo "$progname: $1" >&2
10     [ "$1" ] && echo >&2
11 }
12
13 fatal ()
14 {
15     warn "$2"
16     exit "$1"
17 }
18
19 usage ()
20 {
21     cat <<EOF
22 Usage: $progname lustretag
23   where lustretag is a tag of the lustre-core module
24 EOF
25 }
26
27 if [ -z "$LUSTRECVS_UPDATED" ] ; then
28     cvs up "$0" || fatal 1 "Error updating lustrecvs"
29     export LUSTRECVS_UPDATED=yes
30     exec "$0" "$@"
31 fi
32
33 buildtag="HEAD"
34 lustretag="$1"
35
36 case "$lustretag" in
37     '')
38         warn "a lustretag is required."
39         usage >&2
40         exit 1
41         ;;
42     --help | -h)
43         usage
44         exit 0
45         ;;
46
47     # this is the branch table
48     # keep this list sorted alphabetically!
49
50     *)
51         buildtag="HEAD"
52         ;;
53
54 esac
55
56 cvs_cmd ()
57 {
58     dir="$1"
59     module="$2"
60     tag="$3"
61     cotag=""
62     update=""
63
64     if [ "$tag" = "HEAD" ] ; then
65         cotag=""
66         uptag="-A"
67     else
68         cotag="-r $tag"
69         uptag="-r $tag"
70     fi
71
72     if [ -d "$dir" ] ; then
73         echo "$progname: Updating $dir to $tag"
74         ( cd "$dir" && cvs up -dP $uptag )
75     else
76         echo "$progname: Checking out $dir from $tag"
77         cvs co $cotag -d "$dir" "$module"
78     fi
79 }
80
81 cvs_cmd build lustre-build "$buildtag"
82
83 if [ -f build/buildcvs ] ; then
84     . build/buildcvs
85 else
86     fatal 1 "build/buildcvs does not exist; not updating other modules."
87 fi