1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
DESIREDREVISION=""
if [ "$1" != "" ]
then
DESIREDREVISION="-r $1"
fi
# You should NOT need to modify anything below.
# NB: derby_source must be defined.
# NB NB: Assumes a svn update IS done when run first time!
# If neccessary do a svn up -rXXXXXX to a previous revision first.
#---------------------------------------------
TOOLDIR="${DERBYDIR}/${BRANCH_DIR}/tools/testing/reporting/scripts"
. ${TOOLDIR}/env
SRCDIR=${derby_source}
if [ ! -e ${SRCDIR} ]
then
echo "${SRCDIR} does not exist."
exit
fi
SANDBOX=`basename ${DERBYDIR}`
UPDATELOGDIR=${DERBYDIR}/UpdateLog
UPDATEID=`date +%Y-%m-%d_%H-%M-%S`
UPDATELOGDIRCUR=${UPDATELOGDIR}/${UPDATEID}
mkdir -p ${UPDATELOGDIRCUR}
if [ ! -e ${UPDATELOGDIRCUR} ]
then
echo "${UPDATELOGDIRCUR} does not exist."
exit
fi
# First time...
mkdir -p ${DERBYDIR}/testing
SVNHOSTINFO=`uname -srpi`
SVNHOST=`uname -n`
SVNHOST=`host ${SVNHOST} | awk '{print $1}'`
cd ${SRCDIR}
rm -f ${UPDATELOGDIR}/updateOK
svn --version > ${UPDATELOGDIRCUR}/svn--version
LASTUPDATEREVISION=`head -1 ${REVISIONLIST}`
OLDREVISION=`svn info | grep '^Revision:'`
OLDREPOSITORY=`svn info | grep '^URL:'`
echo "${SVNHOSTINFO}[${SVNHOST}]" > ${UPDATELOGDIRCUR}/status-u.out
echo "${OLDREVISION} ${OLDREPOSITORY}" >> ${UPDATELOGDIRCUR}/status-u.out
svn status -u >> ${UPDATELOGDIRCUR}/status-u.out 2> ${UPDATELOGDIRCUR}/status-u.err
echo "${SVNHOSTINFO}[${SVNHOST}]" > ${UPDATELOGDIRCUR}/update.out
STARTTIME=`date +%Y-%m-%d" "%H:%M:%S" "%Z`
####################################
# Do the update
#
svn update ${DESIREDREVISION} >> ${UPDATELOGDIRCUR}/update.out 2> ${UPDATELOGDIRCUR}/update.err
#
####################################
REVISION=`svn info | grep '^Revision:'`
REPOSITORY=`svn info | grep '^URL:'`
REVISION=`echo ${REVISION} | gawk '{ print $2 }'`
OLDREVISION=`echo ${OLDREVISION} | gawk '{ print $2 }'`
echo "${REVISION} ${REPOSITORY}" >> ${UPDATELOGDIRCUR}/update.out
svn status >> ${UPDATELOGDIRCUR}/update.out 2>> ${UPDATELOGDIRCUR}/update.err
cp ${UPDATELOGDIRCUR}/update.out ${UPDATELOGDIR}/update.out
echo "LASTUPDATEREVISION: ${LASTUPDATEREVISION}, OLDREVISION: ${OLDREVISION}, REVISION: ${REVISION}"
# java/testing/README.htm is NOT readable by 'o' by default....
# I publish a web-link to it:
chmod go+r java/testing/README.htm
# Flag that update went OK:
if [ -e ${UPDATELOGDIR}/${UPDATEID}/update.err ]
then
LNSERR=`wc -l ${UPDATELOGDIR}/${UPDATEID}/update.err | gawk '{ print $1 }'`
echo "LNSERR: ${LNSERR}"
if [ "${LNSERR}" = "0" ]
then
ls -l ${UPDATELOGDIR}/${UPDATEID}/update.out
if [ -e ${UPDATELOGDIR}/${UPDATEID}/update.out ]
then
UPDATED=`grep "Updated to revision" ${UPDATELOGDIR}/${UPDATEID}/update.out | wc -l | gawk '{ print $1 }'`
UNCHANGED=`grep "At revision" ${UPDATELOGDIR}/${UPDATEID}/update.out | wc -l | gawk '{ print $1 }'`
echo "UPDATED: ${UPDATED}, UNCHANGED: ${UNCHANGED}."
if [ "${UPDATED}" = "1" -o "${UNCHANGED}" = "1" ]
then
echo "LASTUPDATEREVISION: ${LASTUPDATEREVISION}, OLDREVISION: ${OLDREVISION}, REVISION: ${REVISION}"
if [ "${UNCHANGED}" = "1" ]
then
echo "UNCHANGED is 1"
STATUS="unchanged from revision ${LASTUPDATEREVISION}/${OLDREVISION} to"
# echo "${TOOLDIR}/textMail \"Derby ${STATUS} ${REVISION}\" \"${MAILTOEXT}\" \"${UPDATELOGDIR}/update.out\""
# ${TOOLDIR}/textMail "Derby ${STATUS} ${REVISION}" "${MAILTOEXT}" "${UPDATELOGDIR}/update.out"
# Remove ...../${UPDATEID}/
rm -rf ${UPDATELOGDIR}/${UPDATEID}
echo "${STATUS} ${REVISION}"
exit
else
echo "UNCHANGED is not 1"
STATUS="updated to revision"
echo ${REVISION} > ${REVISIONLIST}.this
cp ${REVISIONLIST} ${REVISIONLIST}.prev
cat ${REVISIONLIST}.this ${REVISIONLIST}.prev > ${REVISIONLIST}
rm -f ${REVISIONLIST}.prev ${REVISIONLIST}.this
echo "touch ${UPDATELOGDIR}/updateOK"
touch ${UPDATELOGDIR}/updateOK
UPDATEINFO="UpdateInfo"
mkdir -p ${DERBYDIR}/${UPDATEINFO}
REVLO="${DERBYDIR}/${UPDATEINFO}/${REVISION}.txt"
echo "Changes from ${LASTUPDATEREVISION}/${OLDREVISION} to ${REVISION}:" > ${REVLO}
${TOOLDIR}/svnLogRevs.new ${OLDREVISION} ${REVISION} >> ${REVLO}
echo " " >> ${REVLO}
cat ${UPDATELOGDIR}/${UPDATEID}/update.out >> ${REVLO}
LUREV="${DERBYDIR}/${UPDATEINFO}/LatestUpdateRevision.txt"
echo ${REVISION} > ${LUREV}
SRC="${REVLO} ${LUREV}"
chmod go+r ${SRC}
SCPUT=/usr/bin/scp # Do NOT block this one
DST="${PUBLISHDIR}/${UPDATEINFO}/"
echo "**** OBS! ${SCPUT} ${SRC} ${PUBLISHUSER}@${PUBLISHSITE}:${DST}"
### UNCOMMENT TO PUBLISH. ${SCPUT} ${SRC} ${PUBLISHUSER}@${PUBLISHSITE}:${DST}
# echo "${TOOLDIR}/textMail \"${SANDBOX} ${STATUS} ${REVISION}\" \"${MAILTOEXT}\" \"${UPDATELOGDIR}/update.out\""
# ${TOOLDIR}/textMail "Derby ${STATUS} ${REVISION}" "${MAILTOEXT}" "${UPDATELOGDIR}/update.out"
# Rename ...../${UPDATEID}/ to ...../${REVISION}/
mv ${UPDATELOGDIR}/${UPDATEID} ${UPDATELOGDIR}/${REVISION}
echo ${STARTTIME} > ${UPDATELOGDIR}/${REVISION}/UpdateTime
echo "Changes from ${LASTUPDATEREVISION}/${OLDREVISION} to ${REVISION}."
exit
fi
echo "updateDerby 1"
fi
echo "updateDerby 2"
fi
echo "updateDerby 3"
fi
echo "updateDerby 4"
fi
echo "updateDerby 5"
### UNCOMMENT TO SEND MAIL. ${TOOLDIR}/textMail "${SANDBOX} update failed" "${MAILTOINT}" "${UPDATELOGDIR}/update.out ${UPDATELOGDIRCUR}/update.err"
### UNCOMMENT TO SEND MAIL. ${TOOLDIR}/textMail "${SANDBOX} update failed" "${MAILTOEXT}" "${UPDATELOGDIR}/update.out ${UPDATELOGDIRCUR}/update.err"
|