Whamcloud - gitweb
b=16046
[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     b_uoss) buildtag=$lustretag ;;
72
73     # These releases did not get build tagged for them because they
74     # this build system didn't exist when they were tagged
75     v1_2_8|v1_4_0) 
76         buildtag="b1_4"
77         ;;
78     
79     v*) buildtag=$lustretag ;;
80
81     # this is the branch table
82     # keep this list sorted alphabetically!
83
84     *)
85         buildtag="HEAD"
86         ;;
87 esac
88
89 error_modules=
90 cvs_cmd ()
91 {
92     dir="$1"
93     module="$2"
94     tag="$3"
95     cotag=""
96     update=""
97
98     if [ "$tag" = "HEAD" ] ; then
99         cotag=""
100         uptag="-A"
101     elif [ "$tag" ] ; then
102         cotag="-r $tag"
103         uptag="-r $tag"
104     else
105         # silently skip if no tag was specified
106         return
107     fi
108
109     # create a cvs date format that will survive shell expansion
110     if [ -n "$pindate" ]; then
111         datecmd=$(date -u +%s -d "$pindate")
112         datecmd="-D @$datecmd"
113     else
114         datecmd=""
115     fi
116
117     if [ -d "$dir" ] ; then
118         echo "$progname: Updating $dir to $tag"
119         ( cd "$dir" && cvs up $datecmd -dAP $uptag )
120     else
121         echo "$progname: Checking out $dir from $tag"
122         cvs co $datecmd -P $cotag -d "$dir" "$module"
123     fi
124     if [ $? != 0 ] ; then
125         error_modules="$dir $error_modules"
126     fi
127 }
128
129 hg_cmd ()
130 {
131     dir="$1"
132     base_url="$2"
133     repository="$3"
134
135     if [ ! "$repository" ]; then
136         return
137     fi
138
139     url="$base_url/$repository"
140
141     # create a cvs date format that will survive shell expansion
142     if [ -n "$pindate" ]; then
143         datecmd=$(date -u +%s -d "$pindate")
144         datecmd="-d \"$datecmd 0\""
145     else
146         datecmd=""
147     fi
148
149     if [ -d "$dir" ]; then
150         echo "$progname: Updating $dir"
151         if [ -f "$dir/update.sh" ]; then
152             ( cd "$dir" && ./update.sh $datecmd )
153         else
154             ( cd "$dir" && hg pull && hg update $datecmd )
155         fi
156     else
157         echo "$progname: Checking out $dir"
158         hg clone $url $dir
159         if [ -f "$dir/setup.sh" ]; then
160             ( cd "$dir" && ./setup.sh $datecmd )
161         else
162             ( cd "$dir" && hg update $datecmd )
163         fi
164     fi
165
166     if [ $? != 0 ] ; then
167         error_modules="$dir $error_modules"
168     fi
169 }
170
171 cvs_cmd build lustre-build "$buildtag"
172
173 if [ -f build/buildcvs ] ; then
174     . build/buildcvs
175 else
176     fatal 1 "build/buildcvs does not exist; not updating other modules."
177 fi
178
179 if [ "$error_modules" ] ; then
180     fatal 1 "There were errors checking out the following directories: $error_modules"
181 fi