Whamcloud - gitweb
*** empty log message ***
[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
31     # If checking out a specific tag, make sure all of the files here are also
32     # checked out with the same tag to avoid later changes breaking things.
33     case "$1" in
34     v*|b_release_*) TAG="-r $1" ;;
35     esac
36
37     cvs update -l $TAG
38     export LUSTRECVS_UPDATED=yes
39     exec "$0" "$@"
40 fi
41
42 [ "$1" = "-r" ] && shift
43
44 buildtag="HEAD"
45 lustretag="$1"
46 shift
47 pindate=$1
48 shift
49
50 if [ "$*" ] ; then
51     usage >&2
52     exit 1
53 fi
54
55 case "$lustretag" in
56     '')
57         warn "a lustretag is required."
58         usage >&2
59         exit 1
60         ;;
61     --help | -h)
62         usage
63         exit 0
64         ;;
65
66     # this is the branch table
67     # keep this list sorted alphabetically!
68
69     # These use special build directories 
70
71     b1_4*) buildtag="b1_4" ;;
72
73     b_release_1_4_6-patchless) buildtag="b1_4" ;;
74     b_release_1_4_7-test) buildtag="b_release_1_4_7" ;;
75
76     b_release*) buildtag=$lustretag ;;
77
78     b_uoss) buildtag=$lustretag ;;
79
80     # These releases did not get build tagged for them because they
81     # this build system didn't exist when they were tagged
82     v1_2_8|v1_4_0) 
83         buildtag="b1_4"
84         ;;
85     
86     v*) buildtag=$lustretag ;;
87
88     # this is the branch table
89     # keep this list sorted alphabetically!
90
91     *_gate) buildtag="b_build_gate" ;;
92
93     *)
94         buildtag="HEAD"
95         ;;
96 esac
97
98 error_modules=
99 cvs_cmd ()
100 {
101     dir="$1"
102     module="$2"
103     tag="$3"
104     cotag=""
105     update=""
106
107     if [ "$tag" = "HEAD" ] ; then
108         cotag=""
109         uptag="-A"
110     elif [ "$tag" ] ; then
111         cotag="-r $tag"
112         uptag="-r $tag"
113     else
114         # silently skip if no tag was specified
115         return
116     fi
117
118     # create a cvs date format that will survive shell expansion
119     if [ -n "$pindate" ]; then
120         datecmd=$(date -u +%s -d "$pindate")
121         datecmd="-D @$datecmd"
122     else
123         datecmd=""
124     fi
125
126     if [ -d "$dir" ] ; then
127         echo "$progname: Updating $dir to $tag"
128         ( cd "$dir" && cvs up $datecmd -dAP $uptag )
129     else
130         echo "$progname: Checking out $dir from $tag"
131         cvs co $datecmd -P $cotag -d "$dir" "$module"
132     fi
133     if [ $? != 0 ] ; then
134         error_modules="$dir $error_modules"
135     fi
136 }
137
138 hg_cmd ()
139 {
140     dir="$1"
141     base_url="$2"
142     repository="$3"
143
144     if [ ! "$repository" ]; then
145         return
146     fi
147
148     if ! which hg &> /dev/null; then
149     cat <<EOF
150
151 Error: Mercurial is missing, try 'yum install mercurial', 'apt-get install
152 mercurial' or try http://rpmfind.net/linux/rpm2html/search.php?query=mercurial
153 EOF
154         error_modules="$dir $error_modules"
155         return
156     fi
157
158     url="$base_url/$repository"
159
160     # create a cvs date format that will survive shell expansion
161     if [ -n "$pindate" ]; then
162         datecmd=$(date -u +%s -d "$pindate")
163         datecmd="-d \"$datecmd 0\""
164     else
165         datecmd=""
166     fi
167
168     if [ -d "$dir" ]; then
169         echo "$progname: Updating $dir"
170         if [ -f "$dir/update.sh" ]; then
171             ( cd "$dir" && ./update.sh $datecmd )
172         else
173             ( cd "$dir" && hg pull && hg update $datecmd )
174         fi
175     else
176         echo "$progname: Checking out $dir"
177         hg clone $url $dir
178         if [ -f "$dir/setup.sh" ]; then
179             ( cd "$dir" && ./setup.sh $datecmd )
180         else
181             ( cd "$dir" && hg update $datecmd )
182         fi
183     fi
184
185     if [ $? != 0 ] ; then
186         error_modules="$dir $error_modules"
187     fi
188 }
189
190 cvs_cmd build lustre-build "$buildtag"
191
192 if [ -f build/buildcvs ] ; then
193     . build/buildcvs
194 else
195     fatal 1 "build/buildcvs does not exist; not updating other modules."
196 fi
197
198 if [ "$error_modules" ] ; then
199     fatal 1 "There were errors checking out the following directories: $error_modules"
200 fi