Whamcloud - gitweb
Branch b1_4
[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     b1_4*) buildtag="b1_4" ;;
63
64     b_release_1_4_6-patchless) buildtag="b1_4" ;;
65     b_release_1_4_7-test) buildtag="b_release_1_4_7" ;;
66
67     b_release*) buildtag=$lustretag ;;
68
69     # These releases did not get build tagged for them because they
70     # this build system didn't exist when they were tagged
71     v1_2_8|v1_4_0) 
72         buildtag="b1_4"
73         ;;
74     
75     v*) buildtag=$lustretag ;;
76
77     # this is the branch table
78     # keep this list sorted alphabetically!
79
80     *)
81         buildtag="HEAD"
82         ;;
83 esac
84
85 error_modules=
86 cvs_cmd ()
87 {
88     dir="$1"
89     module="$2"
90     tag="$3"
91     cotag=""
92     update=""
93
94     if [ "$tag" = "HEAD" ] ; then
95         cotag=""
96         uptag="-A"
97     elif [ "$tag" ] ; then
98         cotag="-r $tag"
99         uptag="-r $tag"
100     else
101         # silently skip if no tag was specified
102         return
103     fi
104
105     # create a cvs date format that will survive shell expansion
106     if [ -n "$pindate" ]; then
107         datecmd=$(date -u +%s -d "$pindate")
108         datecmd="-D @$datecmd"
109     else
110         datecmd=""
111     fi
112
113     if [ -d "$dir" ] ; then
114         echo "$progname: Updating $dir to $tag"
115         ( cd "$dir" && cvs up $datecmd -dAP $uptag )
116     else
117         echo "$progname: Checking out $dir from $tag"
118         cvs co $datecmd -P $cotag -d "$dir" "$module"
119     fi
120     if [ $? != 0 ] ; then
121         error_modules="$dir $error_modules"
122     fi
123 }
124
125 cvs_cmd build lustre-build "$buildtag"
126
127 if [ -f build/buildcvs ] ; then
128     . build/buildcvs
129 else
130     fatal 1 "build/buildcvs does not exist; not updating other modules."
131 fi
132
133 if [ "$error_modules" ] ; then
134     fatal 1 "There were errors checking out the following directories: $error_modules"
135 fi