xref: /netbsd-src/external/gpl3/gcc/dist/contrib/reghunt/bin/gcc-svn-update (revision 4fee23f98c45552038ad6b5bd05124a41302fb01)
1*4fee23f9Smrg#! /bin/bash
2*4fee23f9Smrg
3*4fee23f9Smrg# Update or check out GCC sources for a particular Subversion revision
4*4fee23f9Smrg# and a particular branch.
5*4fee23f9Smrg#
6*4fee23f9Smrg# Copyright (C) 2007 Free Software Foundation.
7*4fee23f9Smrg#
8*4fee23f9Smrg# This file is free software; you can redistribute it and/or modify
9*4fee23f9Smrg# it under the terms of the GNU General Public License as published by
10*4fee23f9Smrg# the Free Software Foundation; either version 3 of the License, or
11*4fee23f9Smrg# (at your option) any later version.
12*4fee23f9Smrg#
13*4fee23f9Smrg# This program is distributed in the hope that it will be useful,
14*4fee23f9Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
15*4fee23f9Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*4fee23f9Smrg# GNU General Public License for more details.
17*4fee23f9Smrg#
18*4fee23f9Smrg# For a copy of the GNU General Public License, write the the
19*4fee23f9Smrg# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20*4fee23f9Smrg# Boston, MA 02111-1301, USA.
21*4fee23f9Smrg
22*4fee23f9Smrg#set -ex
23*4fee23f9Smrg
24*4fee23f9Smrgif [ $# != 1 ]; then
25*4fee23f9Smrg  echo Usage: $0 id
26*4fee23f9Smrg  exit 1
27*4fee23f9Smrgfi
28*4fee23f9Smrg
29*4fee23f9Smrgif [ "x${REG_DO_CLEANUPS}" != "x" ]; then
30*4fee23f9Smrg  reg_cleanup
31*4fee23f9Smrgfi
32*4fee23f9Smrg
33*4fee23f9SmrgID=$1
34*4fee23f9SmrgBRANCH=""
35*4fee23f9Smrg
36*4fee23f9Smrg########################################################################
37*4fee23f9Smrg# Get sources.
38*4fee23f9Smrg########################################################################
39*4fee23f9Smrg
40*4fee23f9Smrgsvn_get() {
41*4fee23f9Smrg  # In case there are problems with updates (there were with CVS),
42*4fee23f9Smrg  # creating a file called REMOVE in the REG_SRCDIR directory causes us
43*4fee23f9Smrg  # to start with a clean tree each time.
44*4fee23f9Smrg
45*4fee23f9Smrg  unset LC_ALL
46*4fee23f9Smrg  unset LANG
47*4fee23f9Smrg
48*4fee23f9Smrg  cd ${REG_SRCDIR}
49*4fee23f9Smrg  if [ -d gcc ]; then
50*4fee23f9Smrg    # There's already a tree; do an update with the new revision.
51*4fee23f9Smrg    cd gcc
52*4fee23f9Smrg    echo "`date`  svn update begun for id ${ID}, rev ${REV}"
53*4fee23f9Smrg    echo svn update --non-interactive --revision ${REV} >> $LOG
54*4fee23f9Smrg    svn update --non-interactive --revision ${REV} >> $LOG
55*4fee23f9Smrg    if [ $? -eq 0 ]; then
56*4fee23f9Smrg      echo "`date`  svn update done"
57*4fee23f9Smrg    else
58*4fee23f9Smrg      echo "`date`  svn update failed"
59*4fee23f9Smrg      exit 1
60*4fee23f9Smrg    fi
61*4fee23f9Smrg  else
62*4fee23f9Smrg    echo "`date`  svn checkout begun for id ${ID}, rev ${REV}"
63*4fee23f9Smrg    echo svn checkout --non-interactive --revision ${REV} \
64*4fee23f9Smrg      ${REG_SVN_REPO}/${BRANCHPATH} gcc >> $LOG
65*4fee23f9Smrg    svn checkout --non-interactive --revision ${REV} \
66*4fee23f9Smrg      ${REG_SVN_REPO}/${BRANCHPATH} gcc >> $LOG
67*4fee23f9Smrg    if [ $? -eq 0 ]; then
68*4fee23f9Smrg      echo "`date`  svn checkout done"
69*4fee23f9Smrg    else
70*4fee23f9Smrg      echo "`date`  svn checkout failed"
71*4fee23f9Smrg      exit 1
72*4fee23f9Smrg    fi
73*4fee23f9Smrg    cd gcc
74*4fee23f9Smrg  fi
75*4fee23f9Smrg
76*4fee23f9Smrg  # Touch generated files.
77*4fee23f9Smrg  contrib/gcc_update --touch >> $LOG
78*4fee23f9Smrg}
79*4fee23f9Smrg
80*4fee23f9Smrg########################################################################
81*4fee23f9Smrg# Main program
82*4fee23f9Smrg########################################################################
83*4fee23f9Smrg
84*4fee23f9Smrgcd ${REG_SRCDIR}
85*4fee23f9Smrg
86*4fee23f9Smrg# This is a simple way to stop a long regression search fairly cleanly;
87*4fee23f9Smrg# just touch a file called STOP.
88*4fee23f9Smrg
89*4fee23f9Smrgif [ -f STOP ]; then
90*4fee23f9Smrg  echo "`date`  $0 detected STOP file"
91*4fee23f9Smrg  rm -f STOP
92*4fee23f9Smrg  exit 1
93*4fee23f9Smrgfi
94*4fee23f9Smrg
95*4fee23f9Smrg# Set up the log file.
96*4fee23f9SmrgREV=`${REG_IDS} -f index -t rev ${ID}`
97*4fee23f9SmrgLOG=${REG_SRCDIR}/logs/${BUGID}/${REV}.log
98*4fee23f9Smrgmkdir -p ${REG_SRCDIR}/logs/${BUGID}
99*4fee23f9Smrgrm -f $LOG
100*4fee23f9Smrgtouch $LOG
101*4fee23f9Smrg
102*4fee23f9Smrg# Get the branch for this patch.
103*4fee23f9SmrgBRANCH=`${REG_IDS} -f index -t branch ${ID}`
104*4fee23f9Smrgif [ "${BRANCH}" = "error" ]; then
105*4fee23f9Smrg  echo "`date`  $0: cannot determine the SVN branch for id ${ID}"
106*4fee23f9Smrg  exit 1
107*4fee23f9Smrgfi
108*4fee23f9Smrg
109*4fee23f9Smrgif [ "${BRANCH}" = "trunk" ]; then
110*4fee23f9Smrg  BRANCHPATH=trunk
111*4fee23f9Smrgelse
112*4fee23f9Smrg  BRANCHPATH=branches/${BRANCH}
113*4fee23f9Smrgfi
114*4fee23f9Smrg
115*4fee23f9Smrgsvn_get
116*4fee23f9Smrg
117*4fee23f9Smrgexit 0
118