1 #!/bin/sh 2 # 3 # Update the current version date in all files in the tree containing 4 # it. Consider all single-component-version release branches except 5 # those matching the regular expression in $IGNORE_BRANCHES, and also 6 # consider those branches listed in the space separated list in 7 # $ADD_BRANCHES. 8 9 GITROOT=${GITROOT:-"/git/gcc.git"} 10 IGNORE_BRANCHES='releases/gcc-(.*\..*|5|6|7)' 11 ADD_BRANCHES='master' 12 13 # Run this from /tmp. 14 export GITROOT 15 BASEDIR=/tmp/$$ 16 /bin/rm -rf "$BASEDIR" 17 /bin/mkdir "$BASEDIR" 18 cd "$BASEDIR" 19 20 GIT=${GIT:-/usr/local/bin/git} 21 22 # Compute the branches which we should update. 23 BRANCHES=`(cd $GITROOT \ 24 && ${GIT} for-each-ref --format='%(refname)' \ 25 'refs/heads/releases/gcc-*') \ 26 | sed -e 's/refs\/heads\///' \ 27 | egrep -v $IGNORE_BRANCHES` 28 # Always update the mainline. 29 BRANCHES="${ADD_BRANCHES} ${BRANCHES}" 30 31 # This is put into the datestamp files. 32 CURR_DATE=`/bin/date +"%Y%m%d"` 33 34 datestamp_FILES="gcc/DATESTAMP" 35 36 37 # Assume all will go well. 38 RESULT=0 39 SUBDIR=$BASEDIR/gcc 40 for BRANCH in $BRANCHES; do 41 echo "Working on \"$BRANCH\"." 42 # Check out the files on the branch. 43 if [ -d "$SUBDIR" ]; then 44 cd "$SUBDIR" 45 ${GIT} pull -q 46 ${GIT} checkout -q "$BRANCH" 47 else 48 ${GIT} clone -q -b "$BRANCH" "$GITROOT" "$SUBDIR" 49 fi 50 51 # There are no files to commit yet. 52 COMMIT_FILES="" 53 54 cd "$SUBDIR" 55 for file in $datestamp_FILES; do 56 if test -f $file; then 57 echo "${CURR_DATE}" > $file.new 58 59 if /usr/bin/cmp -s $file $file.new; then 60 rm -f $file.new 61 else 62 mv -f $file.new $file 63 COMMIT_FILES="$COMMIT_FILES $file" 64 fi 65 fi 66 done 67 68 if test -n "$COMMIT_FILES"; then 69 for i in $COMMIT_FILES; do 70 echo "Attempting to commit $i" 71 if ${GIT} commit -m "Daily bump." $i; then 72 if ! ${GIT} push origin "$BRANCH"; then 73 # If we could not push the files, indicate failure. 74 RESULT=1 75 fi 76 else 77 # If we could not commit the files, indicate failure. 78 RESULT=1 79 fi 80 done 81 fi 82 done 83 84 /bin/rm -rf $BASEDIR 85 exit $RESULT 86