Whamcloud - gitweb
Severity : major
[fs/lustre-release.git] / lustrecvs
1 #!/bin/bash
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> <pindate>
23   where <lustretag> is a tag of the lustre-core module
24   and <pindate> is an optional quoted timestamp suitable for cvs -D
25 EOF
26 }
27
28 if [ -z "$LUSTRECVS_UPDATED" ] ; then
29     echo "$progname: updating lustrecvs"
30     cvs up -l || fatal 1 "Error updating lustrecvs"
31     export LUSTRECVS_UPDATED=yes
32     exec "$0" "$@"
33 fi
34
35 [ "$1" = "-r" ] && shift
36
37 buildtag="HEAD"
38 lustretag="$1"
39 shift
40 pindate=$1
41 shift
42
43 if [ "$*" ] ; then
44     usage >&2
45     exit 1
46 fi
47
48 case "$lustretag" in
49     '')
50         warn "a lustretag is required."
51         usage >&2
52         exit 1
53         ;;
54     --help | -h)
55         usage
56         exit 0
57         ;;
58
59     # this is the branch table
60     # keep this list sorted alphabetically!
61
62     # These use special build directories 
63
64     b1_4*) buildtag="b1_4" ;;
65
66     b_release_1_4_6-patchless) buildtag="b1_4" ;;
67     b_release_1_4_7-test) buildtag="b_release_1_4_7" ;;
68
69     b_release*) buildtag=$lustretag ;;
70
71     # These releases did not get build tagged for them because they
72     # this build system didn't exist when they were tagged
73     v1_2_8|v1_4_0) 
74         buildtag="b1_4"
75         ;;
76     
77     v*) buildtag=$lustretag ;;
78
79     # this is the branch table
80     # keep this list sorted alphabetically!
81
82     *)
83         buildtag="HEAD"
84         ;;
85 esac
86
87 error_modules=
88 cvs_cmd ()
89 {
90     dir="$1"
91     module="$2"
92     tag="$3"
93     cotag=""
94     update=""
95
96     if [ "$tag" = "HEAD" ] ; then
97         cotag=""
98         uptag="-A"
99     elif [ "$tag" ] ; then
100         cotag="-r $tag"
101         uptag="-r $tag"
102     else
103         # silently skip if no tag was specified
104         return
105     fi
106
107     # create a cvs date format that will survive shell expansion
108     if [ -n "$pindate" ]; then
109         datecmd=$(date -u +%s -d "$pindate")
110         datecmd="-D @$datecmd"
111     else
112         datecmd=""
113     fi
114
115     if [ -d "$dir" ] ; then
116         echo "$progname: Updating $dir to $tag"
117         ( cd "$dir" && cvs up $datecmd -dAP $uptag )
118     else
119         echo "$progname: Checking out $dir from $tag"
120         cvs co $datecmd -P $cotag -d "$dir" "$module"
121     fi
122     if [ $? != 0 ] ; then
123         error_modules="$dir $error_modules"
124     fi
125 }
126
127 cvs_cmd build lustre-build "$buildtag"
128
129 if [ -f build/buildcvs ] ; then
130     . build/buildcvs
131 else
132     fatal 1 "build/buildcvs does not exist; not updating other modules."
133 fi
134
135 if [ "$error_modules" ] ; then
136     fatal 1 "There were errors checking out the following directories: $error_modules"
137 fi