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