2005-12-29 Paul Brook <paul@codesourcery.com>
[official-gcc.git] / maintainer-scripts / update_version
blob2217052332c9a1fafd753c006a1f781a5bfb57fb
1 #!/bin/sh
3 # Update the current version date in all files in the tree containing
4 # it. Consider all release branches except those matching the regular
5 # expression in $IGNORE_BRANCHES, and also consider those branches listed
6 # in $ADD_BRANCHES.
8 CVSROOT=${CVSROOT:-/cvs/gcc}
9 IGNORE_BRANCHES='gcc-(2_95|3_0|3_1|3_2|3_3)-branch'
10 ADD_BRANCHES='HEAD autovect-branch dfp-branch'
12 # Run this from /tmp.
13 export CVSROOT
14 /bin/rm -rf /tmp/$$
15 /bin/mkdir /tmp/$$
16 cd /tmp/$$
18 # The path to cvs.
19 CVS=${CVS:-/usr/local/bin/cvs}
21 # Compute the branches which we should update.
22 $CVS co gcc/ChangeLog
23 BRANCHES=`$CVS status -v gcc/ChangeLog \
24 | awk '{print $1;}' \
25 | egrep 'gcc-[0-9]+_[0-9]+-branch$' \
26 | egrep -v $IGNORE_BRANCHES`
27 # Always update the mainline.
28 BRANCHES="${BRANCHES} ${ADD_BRANCHES}"
30 # ARGS is passed to 'cvs co'
31 CURR_DATE=`/bin/date +"%Y%m%d"`
33 # version is contained within a char*
34 textstring_FILES="gcc/gcc/version.c"
36 # version is contained within a #define
37 cppdefine_FILES="gcc/libstdc++-v3/include/bits/c++config"
39 # version is all there is
40 datestamp_FILES="gcc/gcc/DATESTAMP"
42 FILES="$textstring_FILES $cppdefine_FILES $datestamp_FILES"
44 # Assume all will go well.
45 RESULT=0
47 for BRANCH in $BRANCHES; do
48 echo "Working on \"$BRANCH\"."
49 # Check out the files on the branch. HEAD is a special case; if
50 # you check out files with -r HEAD, CVS will not let you check
51 # in changes.
52 if test "$BRANCH" = HEAD; then
53 ${CVS} co $FILES
54 else
55 ${CVS} co -r $BRANCH $FILES
58 # There are no files to commit yet.
59 COMMIT_FILES=""
61 for file in $textstring_FILES; do
62 if test -f $file; then
63 /bin/sed <$file >$file.new -e \
64 "s/\(.*\"[^ ]*\) [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/\1 ${CURR_DATE}/"
66 if /usr/bin/cmp -s $file $file.new; then
67 rm -f $file.new
68 else
69 mv -f $file.new $file
70 COMMIT_FILES="$COMMIT_FILES $file"
73 done
75 for file in $cppdefine_FILES; do
76 if test -f $file; then
77 /bin/sed <$file >$file.new -e \
78 "s/\(#.*\) [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/\1 ${CURR_DATE}/"
80 if /usr/bin/cmp -s $file $file.new; then
81 rm -f $file.new
82 else
83 mv -f $file.new $file
84 COMMIT_FILES="$COMMIT_FILES $file"
87 done
89 for file in $datestamp_FILES; do
90 if test -f $file; then
91 echo ${CURR_DATE} > $file.new
93 if /usr/bin/cmp -s $file $file.new; then
94 rm -f $file.new
95 else
96 mv -f $file.new $file
97 COMMIT_FILES="$COMMIT_FILES $file"
100 done
102 if test -n "$COMMIT_FILES" \
103 && ! ${CVS} commit -m "Daily bump." $COMMIT_FILES; then
104 # If we could not commit the files, indicate failure.
105 RESULT=1
108 # Remove the files.
109 rm -rf gcc
110 done
112 /bin/rm -rf /tmp/$$
113 exit $RESULT