annotate bin/jib.sh @ 47945:49e605998d2b

8191313: Deprecate RMIConnectorServer.CREDENTIAL_TYPES Summary: Deprecated RMIConnectorServer.CREDENTIAL_TYPES Reviewed-by: rriggs, dfuchs Contributed-by: ujwal.vangapally@oracle.com
author uvangapally
date Tue, 21 Nov 2017 01:25:36 -0800
parents 565363232665
children
rev   line source
erikj@34491 1 #!/bin/bash
erikj@34491 2 #
ihse@41458 3 # Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
erikj@34491 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@34491 5 #
erikj@34491 6 # This code is free software; you can redistribute it and/or modify it
erikj@34491 7 # under the terms of the GNU General Public License version 2 only, as
erikj@34491 8 # published by the Free Software Foundation.
erikj@34491 9 #
erikj@34491 10 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@34491 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@34491 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@34491 13 # version 2 for more details (a copy is included in the LICENSE file that
erikj@34491 14 # accompanied this code).
erikj@34491 15 #
erikj@34491 16 # You should have received a copy of the GNU General Public License version
erikj@34491 17 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@34491 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@34491 19 #
erikj@34491 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@34491 21 # or visit www.oracle.com if you need additional information or have any
erikj@34491 22 # questions.
erikj@34491 23 #
erikj@34491 24
erikj@34496 25 # This script installs the JIB tool into it's own local repository and
erikj@34496 26 # puts a wrapper scripts into <source-root>/.jib
erikj@34491 27
erikj@34491 28 mydir="$(dirname "${BASH_SOURCE[0]}")"
erikj@34491 29 myname="$(basename "${BASH_SOURCE[0]}")"
erikj@34491 30
erikj@47359 31 installed_jib_script=${mydir}/../.jib/jib
erikj@47359 32 install_data=${mydir}/../.jib/.data
erikj@34491 33
erikj@34491 34 setup_url() {
erikj@34768 35 if [ -f ~/.config/jib/jib.conf ]; then
erikj@34496 36 source ~/.config/jib/jib.conf
erikj@34491 37 fi
erikj@34491 38
erikj@34496 39 jib_repository="jdk-virtual"
erikj@34496 40 jib_organization="jpg/infra/builddeps"
erikj@34496 41 jib_module="jib"
erikj@47431 42 jib_revision="3.0-SNAPSHOT"
erikj@34496 43 jib_ext="jib.sh.gz"
erikj@34491 44
erikj@47359 45 closed_script="${mydir}/../../closed/make/conf/jib-install.conf"
erikj@34491 46 if [ -f "${closed_script}" ]; then
erikj@34491 47 source "${closed_script}"
erikj@34491 48 fi
erikj@34491 49
erikj@34496 50 if [ -n "${JIB_SERVER}" ]; then
erikj@34496 51 jib_server="${JIB_SERVER}"
erikj@34491 52 fi
erikj@34768 53 if [ -n "${JIB_SERVER_MIRRORS}" ]; then
erikj@34768 54 jib_server_mirrors="${JIB_SERVER_MIRRORS}"
erikj@34768 55 fi
erikj@34496 56 if [ -n "${JIB_REPOSITORY}" ]; then
erikj@34496 57 jib_repository="${JIB_REPOSITORY}"
erikj@34491 58 fi
erikj@34496 59 if [ -n "${JIB_ORGANIZATION}" ]; then
erikj@34496 60 jib_organization="${JIB_ORGANIZATION}"
erikj@34491 61 fi
erikj@34496 62 if [ -n "${JIB_MODULE}" ]; then
erikj@34496 63 jib_module="${JIB_MODULE}"
erikj@34491 64 fi
erikj@34496 65 if [ -n "${JIB_REVISION}" ]; then
erikj@34496 66 jib_revision="${JIB_REVISION}"
erikj@34491 67 fi
erikj@34496 68 if [ -n "${JIB_EXTENSION}" ]; then
erikj@34496 69 jib_extension="${JIB_EXTENSION}"
erikj@34491 70 fi
erikj@34491 71
erikj@34496 72 if [ -n "${JIB_URL}" ]; then
erikj@34496 73 jib_url="${JIB_URL}"
erikj@34496 74 data_string="${jib_url}"
erikj@34491 75 else
erikj@34768 76 jib_path="${jib_repository}/${jib_organization}/${jib_module}/${jib_revision}/${jib_module}-${jib_revision}.${jib_ext}"
erikj@34768 77 data_string="${jib_path}"
erikj@34768 78 jib_url="${jib_server}/${jib_path}"
erikj@34491 79 fi
erikj@34491 80 }
erikj@34491 81
erikj@34496 82 install_jib() {
erikj@34496 83 if [ -z "${jib_server}" -a -z "${JIB_URL}" ]; then
erikj@34496 84 echo "No jib server or URL provided, set either"
erikj@34496 85 echo "JIB_SERVER=<base server address>"
erikj@34491 86 echo "or"
erikj@34496 87 echo "JIB_URL=<full path to install script>"
erikj@34491 88 exit 1
erikj@34491 89 fi
erikj@34491 90
erikj@34491 91 if command -v curl > /dev/null; then
erikj@37862 92 getcmd="curl -s -L --retry 3 --retry-delay 5"
erikj@34491 93 elif command -v wget > /dev/null; then
erikj@34491 94 getcmd="wget --quiet -O -"
erikj@34491 95 else
erikj@34491 96 echo "Could not find either curl or wget"
erikj@34491 97 exit 1
erikj@34491 98 fi
erikj@34491 99
erikj@34491 100 if ! command -v gunzip > /dev/null; then
erikj@34491 101 echo "Could not find gunzip"
erikj@34491 102 exit 1
erikj@34491 103 fi
erikj@34491 104
erikj@34496 105 echo "Downloading JIB bootstrap script"
erikj@34496 106 mkdir -p "${installed_jib_script%/*}"
erikj@34496 107 rm -f "${installed_jib_script}.gz"
erikj@34496 108 ${getcmd} ${jib_url} > "${installed_jib_script}.gz"
erikj@34496 109 if [ ! -s "${installed_jib_script}.gz" ]; then
erikj@34496 110 echo "Failed to download ${jib_url}"
erikj@34768 111 if [ -n "${jib_path}" -a -n "${jib_server_mirrors}" ]; then
erikj@34768 112 OLD_IFS="${IFS}"
erikj@34768 113 IFS=" ,"
erikj@34768 114 for mirror in ${jib_server_mirrors}; do
erikj@34768 115 echo "Trying mirror ${mirror}"
erikj@34768 116 jib_url="${mirror}/${jib_path}"
erikj@34768 117 ${getcmd} ${jib_url} > "${installed_jib_script}.gz"
erikj@34768 118 if [ -s "${installed_jib_script}.gz" ]; then
erikj@34768 119 echo "Download from mirror successful"
erikj@34768 120 break
erikj@34768 121 else
erikj@34768 122 echo "Failed to download ${jib_url}"
erikj@34768 123 fi
erikj@34768 124 done
erikj@34768 125 IFS="${OLD_IFS}"
erikj@34768 126 fi
erikj@34768 127 if [ ! -s "${installed_jib_script}.gz" ]; then
erikj@34768 128 exit 1
erikj@34768 129 fi
erikj@34491 130 fi
erikj@34496 131 echo "Extracting JIB bootstrap script"
erikj@34496 132 rm -f "${installed_jib_script}"
erikj@34496 133 gunzip "${installed_jib_script}.gz"
erikj@34496 134 chmod +x "${installed_jib_script}"
erikj@34491 135 echo "${data_string}" > "${install_data}"
erikj@34491 136 }
erikj@34491 137
erikj@34491 138 # Main body starts here
erikj@34491 139
erikj@34491 140 setup_url
erikj@34491 141
erikj@34496 142 if [ ! -x "${installed_jib_script}" ]; then
erikj@34496 143 install_jib
erikj@34491 144 elif [ ! -e "${install_data}" ] || [ "${data_string}" != "$(cat "${install_data}")" ]; then
erikj@34491 145 echo "Install url changed since last time, reinstalling"
erikj@34496 146 install_jib
erikj@34491 147 fi
erikj@34491 148
erikj@47431 149 # Provide a reasonable default for the --src-dir parameter if run out of tree
erikj@47431 150 if [ -z "${JIB_SRC_DIR}" ]; then
erikj@47431 151 export JIB_SRC_DIR="${mydir}/../"
erikj@47431 152 fi
erikj@47431 153
erikj@34496 154 ${installed_jib_script} "$@"