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