1#!/bin/sh 2 3# Copyright (c) 2007, 2021, Oracle and/or its affiliates. 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License, version 2.0, 7# as published by the Free Software Foundation. 8# 9# This program is also distributed with certain software (including 10# but not limited to OpenSSL) that is licensed under separate terms, 11# as designated in a particular file or component or in included license 12# documentation. The authors of MySQL hereby grant you an additional 13# permission to link the program and your derivative works with the 14# separately licensed software that they have included with MySQL. 15# 16# This program is distributed in the hope that it will be useful, 17# but WITHOUT ANY WARRANTY; without even the implied warranty of 18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19# GNU General Public License, version 2.0, for more details. 20# 21# You should have received a copy of the GNU General Public License 22# along with this program; if not, write to the Free Software 23# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 25############################################################# 26# This script created by Jonas does the following # 27# Cleans up clones and pevious builds, pulls new clones, # 28# builds, deploys, configures the tests and launches ATRT # 29############################################################# 30 31############### 32#Script setup # 33############## 34 35save_args=$* 36VERSION="upgrade-boot.sh version 1.00" 37 38DATE=`date '+%Y-%m-%d'` 39HOST=`hostname -s` 40export DATE HOST 41 42set -e 43 44echo "`date` starting: $*" 45 46verbose=0 47do_clone=yes 48build=yes 49 50tag0= 51tag1= 52conf= 53extra_args= 54extra_clone= 55LOCK=$HOME/.autotest-lock 56 57############################ 58# Read command line entries# 59############################ 60 61while [ "$1" ] 62do 63 case "$1" in 64 --no-clone) do_clone="";; 65 --no-build) build="";; 66 --verbose) verbose=`expr $verbose + 1`;; 67 --clone=*) clone0=`echo $1 | sed s/--clone=//`;; 68 --clone0=*) clone0=`echo $1 | sed s/--clone0=//`;; 69 --clone1=*) clone1=`echo $1 | sed s/--clone1=//`;; 70 --version) echo $VERSION; exit;; 71 --conf=*) conf=`echo $1 | sed s/--conf=//`;; 72 --tag=*) tag0=`echo $1 | sed s/--tag=//`;; 73 --tag0=*) tag0=`echo $1 | sed s/--tag0=//`;; 74 --tag1=*) tag1=`echo $1 | sed s/--tag1=//`;; 75 --*) echo "Unknown arg: $1";; 76 *) RUN=$*;; 77 esac 78 shift 79done 80 81if [ -z "$clone1" ] 82then 83 clone1=$clone0 84fi 85 86if [ -z "$tag0" ] 87then 88 echo "No tag0 specified" 89 exit 90fi 91 92if [ -z "$tag1" ] 93then 94 echo "No tag1 specified" 95 exit 96fi 97 98################################# 99#Make sure the configfile exists# 100#if it does not exit. if it does# 101# (.) load it # 102################################# 103if [ -z "$conf" ] 104then 105 if [ -f "`pwd`/autotest.conf" ] 106 then 107 conf="`pwd`/autotest.conf" 108 elif [ -f "$HOME/autotest.conf" ] 109 then 110 conf="$HOME/autotest.conf" 111 fi 112fi 113 114if [ -f $conf ] 115then 116 . $conf 117else 118 echo "Can't find config file: >$conf<" 119 exit 120fi 121 122############################### 123# Validate that all interesting 124# variables where set in conf 125############################### 126vars="src_clone_base install_dir build_dir" 127for i in $vars 128do 129 t=`echo echo \\$$i` 130 if [ -z "`eval $t`" ] 131 then 132 echo "Invalid config: $conf, variable $i is not set" 133 exit 134 fi 135done 136 137############################### 138#Print out the enviroment vars# 139############################### 140 141if [ $verbose -gt 0 ] 142then 143 env 144fi 145 146#################################### 147# Setup the lock file name and path# 148# Setup the clone source location # 149#################################### 150 151src_clone0=${src_clone_base}${clone0} 152src_clone1=${src_clone_base}${clone1} 153 154####################################### 155# Check to see if the lock file exists# 156# If it does exit. # 157####################################### 158 159if [ -f $LOCK ] 160then 161 echo "Lock file exists: $LOCK" 162 exit 1 163fi 164 165####################################### 166# If the lock file does not exist then# 167# create it with date and run info # 168####################################### 169 170echo "$DATE $RUN" > $LOCK 171 172############################# 173#If any errors here down, we# 174# trap them, and remove the # 175# Lock file before exit # 176############################# 177if [ `uname -s` != "SunOS" ] 178then 179 trap "rm -f $LOCK" ERR 180fi 181 182# You can add more to this path# 183################################ 184 185dst_place0=${build_dir}/clone-$tag0-$DATE.$$ 186dst_place1=${build_dir}/clone-$tag1-$DATE.$$ 187 188######################################### 189# Delete source and pull down the latest# 190######################################### 191 192if [ "$do_clone" ] 193then 194 rm -rf $dst_place0 $dst_place1 195 if [ `echo $src_clone0 | grep -c 'file:\/\/'` = 1 ] 196 then 197 bk clone -l -r$tag0 $src_clone0 $dst_place0 198 else 199 bk clone -r$tag0 $src_clone0 $dst_place0 200 fi 201 202 if [ `echo $src_clone1 | grep -c 'file:\/\/'` = 1 ] 203 then 204 bk clone -l -r$tag1 $src_clone1 $dst_place1 205 else 206 bk clone -r$tag1 $src_clone1 $dst_place1 207 fi 208fi 209 210########################################## 211# Build the source, make installs, and # 212# create the database to be rsynced # 213########################################## 214function build_cluster() 215{ 216 if [ -x storage/ndb/compile-cluster ] 217 then 218 storage/ndb/compile-cluster --autotest $* 219 else 220 BUILD/compile-ndb-autotest $* 221 fi 222} 223 224install_dir0=$install_dir/$tag0 225install_dir1=$install_dir/$tag1 226if [ "$build" ] 227then 228 cd $dst_place0 229 rm -rf $install_dir0 230 build_cluster --prefix=$install_dir0 231 make install 232 233 cd $dst_place1 234 rm -rf $install_dir1 235 build_cluster --prefix=$install_dir1 236 make install 237 fi 238fi 239 240 241################################ 242# Start run script # 243################################ 244 245script=$install_dir1/mysql-test/ndb/upgrade-run.sh 246$script $save_args --conf=$conf --install-dir=$install_dir --suite=$RUN --nolock $extra_args 247 248if [ "$build" ] 249then 250 rm -rf $dst_place0 $dst_place1 251fi 252rm -f $LOCK 253