Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / ldiskfs / ldiskfscvs
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 <tag> <pindate>
23   where <tag> is a tag of the ldiskfs module
24   and <pindate> is an optional quoted timestamp suitable for cvs -D
25 EOF
26 }
27
28 if [ -z "$LDISKFSCVS_UPDATED" ] ; then
29     echo "$progname: updating ldiskfscvs"
30     cvs up -l || fatal 1 "Error updating ldiskfscvs"
31     export LDISKFSCVS_UPDATED=yes
32     exec "$0" "$@"
33 fi
34
35 [ "$1" = "-r" ] && shift
36
37 buildtag="HEAD"
38 tag="$1"
39 shift
40 pindate=$1
41 shift
42
43 if [ "$*" ] ; then
44     usage >&2
45     exit 1
46 fi
47
48 case "$tag" in
49     '')
50         warn "a tag 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     # So far there's just HEAD.
63
64     *)
65         buildtag="HEAD"
66         ;;
67 esac
68
69 error_modules=
70 cvs_cmd ()
71 {
72     dir="$1"
73     module="$2"
74     tag="$3"
75     cotag=""
76     update=""
77
78     if [ "$tag" = "HEAD" ] ; then
79         cotag=""
80         uptag="-A"
81     elif [ "$tag" ] ; then
82         cotag="-r $tag"
83         uptag="-r $tag"
84     else
85         # silently skip if no tag was specified
86         return
87     fi
88
89     # create a cvs date format that will survive shell expansion
90     if [ -n "$pindate" ]; then
91         datecmd=$(date -u +%s -d "$pindate")
92         datecmd="-D @$datecmd"
93     else
94         datecmd=""
95     fi
96
97     if [ -d "$dir" ] ; then
98         echo "$progname: Updating $dir to $tag"
99         ( cd "$dir" && cvs up $datecmd -dAP $uptag )
100     else
101         echo "$progname: Checking out $dir from $tag"
102         cvs co $datecmd -P $cotag -d "$dir" "$module"
103     fi
104     if [ $? != 0 ] ; then
105         error_modules="$dir $error_modules"
106     fi
107 }
108
109 cvs_cmd build lustre-build "$buildtag"