Debian Codegraph @

tools/testing/reporting/scripts/updateDerby

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