1#! /bin/bash 2 3#set -ex 4 5# Update an SVN tree for a particular date. 6 7if [ $# != 1 ]; then 8 echo Usage: $0 id 9 exit 1 10fi 11 12if [ "x${REG_DO_CLEANUPS}" != "x" ]; then 13 reg_cleanup 14fi 15 16ID=$1 17BRANCH="" 18 19######################################################################## 20# Get sources. 21######################################################################## 22 23svn_get() { 24 # In case there are problems with updates (there were with CVS), 25 # creating a file called REMOVE in the REG_SRCDIR directory causes us 26 # to start with a clean tree each time. 27 28 unset LC_ALL 29 unset LANG 30 31 cd ${REG_SRCDIR} 32 if [ -d gcc ]; then 33 # There's already a tree; do an update with the new revision. 34 cd gcc 35 echo "`date` svn update begun for id ${ID}, rev ${REV} (fix)" 36 echo svn update --non-interactive --revision ${REV} >> $LOG 37 svn update --non-interactive --revision ${REV} >> $LOG 38 if [ $? -eq 0 ]; then 39 echo "`date` svn update done" 40 else 41 echo "`date` svn update failed" 42 exit 1 43 fi 44 else 45 echo "`date` svn checkout begun for id ${ID}, rev ${REV}" 46 echo svn checkout --non-interactive --revision ${REV} \ 47 ${REG_SVN_REPO}/${BRANCHPATH} gcc >> $LOG 48 svn checkout --non-interactive --revision ${REV} \ 49 ${REG_SVN_REPO}/${BRANCHPATH} gcc >> $LOG 50 if [ $? -eq 0 ]; then 51 echo "`date` svn checkout done" 52 else 53 echo "`date` svn checkout failed" 54 exit 1 55 fi 56 cd gcc 57 fi 58 59 # Touch generated files. 60 contrib/gcc_update --touch >> $LOG 61} 62 63######################################################################## 64# Main program 65######################################################################## 66 67cd ${REG_SRCDIR} 68 69# This is a simple way to stop a long regression search fairly cleanly; 70# just touch a file called STOP. 71 72if [ -f STOP ]; then 73 echo "`date` $0 detected STOP file" 74 rm -f STOP 75 exit 1 76fi 77 78# Set up the log file. 79REV=`${REG_IDS} -f index -t rev ${ID}` 80LOG=${REG_SRCDIR}/logs/${BUGID}/${REV}.log 81mkdir -p ${REG_SRCDIR}/logs/${BUGID} 82rm -f $LOG 83touch $LOG 84 85# Get the branch for this patch. 86BRANCH=`${REG_IDS} -f index -t branch ${ID}` 87if [ "${BRANCH}" = "error" ]; then 88 echo "`date` $0: cannot determine the SVN branch for id ${ID}" 89 exit 1 90fi 91 92if [ "${BRANCH}" = "trunk" ]; then 93 BRANCHPATH=trunk 94else 95 BRANCHPATH=branches/${BRANCH} 96fi 97 98svn_get 99 100# Look for a patch that's needed for this revision to build. 101FIX=${REG_PATCHES}/${REV}.fix 102echo "`date` looking for $FIX" 103if [ -f $FIX ]; then 104 echo "`date` fix needed; checking whether it is already applied" 105 cd ${REG_SRCDIR}/gcc 106 patch --dry-run -s -p0 -i $FIX < /dev/null > /dev/null 2>&1 107 if [ $? -eq 0 ]; then 108 echo "`date` applying fix" 109 patch -s -p0 -i $FIX 110 fi 111fi 112 113exit 0 114