OSDN Git Service

2007-01-21 Tobias Burnus <burnus@net-b.de>
[pf3gnuchains/gcc-fork.git] / maintainer-scripts / update_version_svn
1 #!/bin/sh
2 #
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.
7
8 SVNROOT=${SVNROOT:-"file:///svn/gcc"}
9 IGNORE_BRANCHES='gcc-(2_95|3_0|3_1|3_2|3_3|3_4)-branch'
10 ADD_BRANCHES='HEAD autovect-branch'
11
12 # Run this from /tmp.
13 export SVNROOT
14 /bin/rm -rf /tmp/$$
15 /bin/mkdir /tmp/$$
16 cd /tmp/$$
17
18 # The path to cvs.
19 SVN=${SVN:-/usr/bin/svn}
20
21 # Compute the branches which we should update.
22 BRANCHES=`$SVN ls $SVNROOT/branches \
23           | sed -e 's/\///' \
24           | egrep 'gcc-[0-9]+_[0-9]+-branch$' \
25           | egrep -v $IGNORE_BRANCHES`
26 # Always update the mainline.
27 BRANCHES="${BRANCHES} ${ADD_BRANCHES}"
28
29 # ARGS is passed to 'cvs co'
30 CURR_DATE=`/bin/date +"%Y%m%d"`
31
32 # version is contained within a char*
33 textstring_FILES="gcc/version.c"
34
35 # version is contained within a #define
36 cppdefine_FILES="libstdc++-v3/include/bits/c++config"
37
38 # version is all there is
39 datestamp_FILES="gcc/DATESTAMP"
40
41 FILES="$textstring_FILES $cppdefine_FILES $datestamp_FILES"
42 DIRS="$textstring_DIRS $cppdefine_DIRS $datestamp_DIRS"
43
44 # Assume all will go well.
45 RESULT=0
46 for BRANCH in $BRANCHES; do
47   echo "Working on \"$BRANCH\"."
48   # Check out the files on the branch.  HEAD is a special case; if
49   # you check out files with -r HEAD, CVS will not let you check 
50   # in changes.
51   if test "$BRANCH" = HEAD; then 
52     for i in $FILES; do
53       ${SVN} -q co -N ${SVNROOT}/trunk/`dirname $i` `basename $i`
54     done
55   else
56     for i in $FILES; do
57       ${SVN} -q co -N ${SVNROOT}/branches/${BRANCH}/`dirname $i` `basename $i`
58     done
59   fi
60
61   # There are no files to commit yet.
62   COMMIT_FILES=""
63    
64   for file in $textstring_FILES; do
65     dirname=`basename $file`
66     file=`basename $file`
67     file="$dirname/$file"
68     if test -f $file; then 
69       /bin/sed  <$file >$file.new -e \
70   "s/\(.*\"[^ ]*\) [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/\1 ${CURR_DATE}/" 
71
72       if /usr/bin/cmp -s $file $file.new; then
73         rm -f $file.new
74       else
75         mv -f $file.new $file
76         COMMIT_FILES="$COMMIT_FILES $file"
77       fi
78     fi
79   done
80   
81   for file in $cppdefine_FILES; do
82     dirname=`basename $file`
83     file=`basename $file`
84     file="$dirname/$file"
85     if test -f $file; then
86       /bin/sed <$file >$file.new -e \
87   "s/\(#.*\) [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/\1 ${CURR_DATE}/"
88
89       if /usr/bin/cmp -s $file $file.new; then
90         rm -f $file.new
91       else
92         mv -f $file.new $file
93         COMMIT_FILES="$COMMIT_FILES $file"
94       fi
95     fi
96   done
97
98   for file in $datestamp_FILES; do
99     dirname=`basename $file`
100     file=`basename $file`
101     file="$dirname/$file"
102     if test -f $file; then
103       echo ${CURR_DATE} > $file.new
104
105       if /usr/bin/cmp -s $file $file.new; then
106         rm -f $file.new
107       else
108         mv -f $file.new $file
109         COMMIT_FILES="$COMMIT_FILES $file"
110       fi
111     fi
112   done
113
114   if test -n "$COMMIT_FILES"; then
115     for i in $COMMIT_FILES; do
116     echo "Attempting to commit $i"
117     if ! ${SVN} commit -m "Daily bump." $i; then
118        # If we could not commit the files, indicate failure.
119        RESULT=1
120      fi
121     done
122   fi
123   
124   # Remove the files.
125   for i in $FILES; do
126    rm -rf /tmp/$$/`basename $i`
127   done
128 done
129
130 /bin/rm -rf /tmp/$$
131 exit $RESULT