guihive-deploy.sh 5.6 KB
Newer Older
1 2
#!/bin/bash

3 4 5
DEFAULT_DEPLOY_LOCATION="$(dirname "$0")"
DEPLOY_LOCATION=${DEPLOY_LOCATION:-$DEFAULT_DEPLOY_LOCATION}

6 7 8
EHIVE_CLONE_LOCATION="${DEPLOY_LOCATION}/clones/ensembl-hive"
GUIHIVE_CLONE_LOCATION="${DEPLOY_LOCATION}/clones/guiHive"
EHIVE_VERSIONS_DIR="${DEPLOY_LOCATION}"/ensembl-hive
9 10
GUIHIVE_VERSIONS_DIR="${DEPLOY_LOCATION}"/versions

11 12 13
    # if you specify a new EHIVE_SOURCE, the Hive cache will be automatically cleaned up:
if [ -n "$EHIVE_SOURCE" ]
then
14
    echo "RM " rm -rf "$EHIVE_CLONE_LOCATION" "$EHIVE_VERSIONS_DIR"
15 16 17 18 19 20
    rm -rf "$EHIVE_CLONE_LOCATION" "$EHIVE_VERSIONS_DIR"
fi

    # if you specify a new EHIVE_SOURCE, the guiHive cache will be automatically cleaned up:
if [ -n "$GUIHIVE_SOURCE" ]
then
21
    echo "RM " rm -rf "$GUIHIVE_CLONE_LOCATION" "$GUIHIVE_VERSIONS_DIR"
22 23
    rm -rf "$GUIHIVE_CLONE_LOCATION" "$GUIHIVE_VERSIONS_DIR"
fi
24 25 26 27 28 29

EHIVE_DEFAULT_SOURCE='git://www.github.com/Ensembl/ensembl-hive'
EHIVE_SOURCE=${EHIVE_SOURCE:-$EHIVE_DEFAULT_SOURCE}

GUIHIVE_DEFAULT_SOURCE='git://www.github.com/Ensembl/guiHive'
GUIHIVE_SOURCE=${GUIHIVE_SOURCE:-$GUIHIVE_DEFAULT_SOURCE}
30

Brandon Walts's avatar
Brandon Walts committed
31 32
umask 0002

33 34 35 36 37
if [ -d "$GUIHIVE_VERSIONS_DIR" ] && [ -d "$EHIVE_VERSIONS_DIR" ]
then
  echo "'$GUIHIVE_VERSIONS_DIR' and/or '$EHIVE_VERSIONS_DIR' already exist. Press ctrl+c to exit now, or enter otherwise/"
  read
fi
38 39

mkdir -p "$DEPLOY_LOCATION"
40 41
mkdir -p "$GUIHIVE_VERSIONS_DIR"
mkdir -p "$EHIVE_VERSIONS_DIR"
42

43 44 45 46 47 48 49 50 51 52 53
# Any failure will cause the script to exit
trap "echo 'An error occurred. Deployment aborted'; exit 1" EXIT
set -e

reference_clone () {
  # $git_url $target_dir
  echo "get reference clone for $2 from $1"
  if [ -d "$2" ]
  then
    GIT_DIR="$2" git fetch
  else
54
    echo "GITCLONE: " git clone --mirror "$1" "$2"
55 56 57 58
    git clone --mirror "$1" "$2"
  fi
}

59 60
reference_clone "$EHIVE_SOURCE" "$EHIVE_CLONE_LOCATION"
reference_clone "$GUIHIVE_SOURCE" "$GUIHIVE_CLONE_LOCATION"
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

## "Safe" functions that can deal with pre-incarnations of the target

safe_clone () {
  # safe_clone $branch $URL $dest
  rm -rf "$3"
  mkdir -p "$3"
  GIT_DIR="$2" GIT_WORK_TREE="$3" git checkout -qf "$1"
}

safe_symlink () {
  # safe_symlink $source $target
  rm -rf "$2"
  ln -s "$1" "$2"
}


## Higher-level functions that wrap the safe functions

80 81 82 83 84 85 86 87
trim_ehive_repo () {
  # $dir
  rm -rf "$1/docs"
  rm -rf "$1/wrappers"
  rm -rf "$1/scripts"
  rm -rf "$1/t"
}

88 89 90 91
add_guihive_version () {
  echo "checkout $1: guiHive $2 and eHive $3"
  safe_clone "$2" "$GUIHIVE_CLONE_LOCATION" "${GUIHIVE_VERSIONS_DIR}/$1"
  safe_clone "$3" "$EHIVE_CLONE_LOCATION" "${EHIVE_VERSIONS_DIR}/$1"
92
  trim_ehive_repo "${EHIVE_VERSIONS_DIR}/$1"
93 94 95
}

link_guihive_version () {
96 97 98
  DEFAULT_TAG="sql_schema_$((${1}+1))_start^"
  EHIVE_COMMIT=${3:-$DEFAULT_TAG}
  echo "checkout $1: guiHive =$2 and eHive $EHIVE_COMMIT"
99
  safe_symlink "$2" "${GUIHIVE_VERSIONS_DIR}/$1"
100
  safe_clone "$EHIVE_COMMIT" "$EHIVE_CLONE_LOCATION" "${EHIVE_VERSIONS_DIR}/$1"
101
  trim_ehive_repo "${EHIVE_VERSIONS_DIR}/$1"
102 103 104
}


105 106 107 108 109 110 111 112 113 114
## Checkout the server branch

if [ -e "$DEPLOY_LOCATION/README.md" ]
then
  echo "$DEPLOY_LOCATION/README.md is there, assuming the server branch is checked out"
else
  #safe_clone server "$GUIHIVE_CLONE_LOCATION" "$DEPLOY_LOCATION"
  GIT_DIR="$GUIHIVE_CLONE_LOCATION" GIT_WORK_TREE="$DEPLOY_LOCATION" git checkout -qf 'server'
fi

115 116
## List of versions

Matthieu Muffato's avatar
Matthieu Muffato committed
117 118 119
# 1. First we list all the eHive stable branches + master and map them to their database versions
#    In case several branches are based on the same schema, we keep the latest.
#    We also list specific guiHive versions that were made whilst developing eHive's master
120 121 122 123
# $db_version  guihive_branch  ehive_branch
add_guihive_version "56" "db_version/56" "version/2.0"
add_guihive_version "62" "db_version/62" "version/2.2"
add_guihive_version "73" "db_version/73" "version/2.3"
124
add_guihive_version "80" "db_version/80" "version/2.4"
125 126 127 128
add_guihive_version "84" "db_version/84" "sql_schema_85_start~3"   # is_excluded analysis property
add_guihive_version "88" "db_version/88" "sql_schema_89_start^"    # Switched to using HivePipeline and some AnalysisJobAdaptor methods, and added support for global max_retry_count
add_guihive_version "89" "db_version/89" "sql_schema_90_start^"    # New semaphore table
add_guihive_version "91" "db_version/91" "sql_schema_92_start^"    # Added analysis tags and comments
Matthieu Muffato's avatar
Matthieu Muffato committed
129 130

# 2. Then we list all the other eHive database versions and link them to a compatible guiHive version
131 132

# $db_version  $aliased_db_version
Matthieu Muffato's avatar
Matthieu Muffato committed
133
# 57 to 61 are skipped
134 135 136 137 138 139 140
link_guihive_version "63" "62"
link_guihive_version "64" "73"
link_guihive_version "65" "73"
link_guihive_version "66" "73"
link_guihive_version "67" "73"
link_guihive_version "68" "73"
link_guihive_version "69" "73"
141
link_guihive_version "70" "73" "sql_schema_71_start^2"	# because the merge of the python branch has swapped its two parents
142 143
link_guihive_version "71" "73"
link_guihive_version "72" "73"
Matthieu Muffato's avatar
Matthieu Muffato committed
144
# 73 is listed in the first section
145 146 147 148 149 150
link_guihive_version "74" "80"
link_guihive_version "75" "80" "44d78112401c21e2a704b8335dd4b247b85fe93a"  # this is the last "safe" commit for guiHive 75, i.e. before Utils/Graph starts printing extra messages on stdout
link_guihive_version "76" "80"
link_guihive_version "77" "80"
link_guihive_version "78" "80"
link_guihive_version "79" "80"
Matthieu Muffato's avatar
Matthieu Muffato committed
151
# 80 is listed in the first section
Brandon Walts's avatar
Brandon Walts committed
152 153 154
link_guihive_version "81" "80"
link_guihive_version "82" "80"
link_guihive_version "83" "80"
Matthieu Muffato's avatar
Matthieu Muffato committed
155 156 157 158
# 84 is listed in the first section
link_guihive_version "85" "88"
link_guihive_version "86" "88"
link_guihive_version "87" "88"
159 160
# 88 is listed in the first section
# 89 is listed in the first section
Leo Gordon's avatar
Leo Gordon committed
161 162
link_guihive_version "90" "89"
# 91 is listed in the first section
163 164
link_guihive_version "92" "91"
link_guihive_version "93" "91" "master"
165 166 167

trap - EXIT