bin/jib.sh
author sundar
Mon, 25 Sep 2017 20:32:44 +0530
changeset 47261 ae970828ec0c
parent 47217 72e3ae9a25eb
child 47291 c87f7ff9ef65
permissions -rw-r--r--
8187934: dropping a shebang script in src/sample/nashorn directory results in test failure Reviewed-by: hannesw, jlaskey
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
     1
#!/bin/bash
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
     2
#
41458
f285e333e8db 8167424: Various trivial fixes in build system
ihse
parents: 37862
diff changeset
     3
# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
     4
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
     5
#
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
     6
# This code is free software; you can redistribute it and/or modify it
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
     7
# under the terms of the GNU General Public License version 2 only, as
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
     8
# published by the Free Software Foundation.
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
     9
#
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    10
# This code is distributed in the hope that it will be useful, but WITHOUT
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    12
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    13
# version 2 for more details (a copy is included in the LICENSE file that
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    14
# accompanied this code).
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    15
#
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    16
# You should have received a copy of the GNU General Public License version
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    17
# 2 along with this work; if not, write to the Free Software Foundation,
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    18
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    19
#
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    20
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    21
# or visit www.oracle.com if you need additional information or have any
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    22
# questions.
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    23
#
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    24
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    25
# This script installs the JIB tool into it's own local repository and
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    26
# puts a wrapper scripts into <source-root>/.jib
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    27
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    28
mydir="$(dirname "${BASH_SOURCE[0]}")"
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    29
myname="$(basename "${BASH_SOURCE[0]}")"
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    30
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    31
installed_jib_script=${mydir}/../../.jib/jib
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    32
install_data=${mydir}/../../.jib/.data
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    33
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    34
setup_url() {
34768
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
    35
    if [ -f ~/.config/jib/jib.conf ]; then
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    36
        source ~/.config/jib/jib.conf
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    37
    fi
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    38
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    39
    jib_repository="jdk-virtual"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    40
    jib_organization="jpg/infra/builddeps"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    41
    jib_module="jib"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    42
    jib_revision="2.0-SNAPSHOT"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    43
    jib_ext="jib.sh.gz"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    44
47217
72e3ae9a25eb 8187444: Forest Consolidation: Make build work
erikj
parents: 47216
diff changeset
    45
    closed_script="${mydir}/../../../closed/conf/jib-install.conf"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    46
    if [ -f "${closed_script}" ]; then
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    47
        source "${closed_script}"
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    48
    fi
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    49
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    50
    if [ -n "${JIB_SERVER}" ]; then
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    51
        jib_server="${JIB_SERVER}"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    52
    fi
34768
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
    53
    if [ -n "${JIB_SERVER_MIRRORS}" ]; then
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
    54
        jib_server_mirrors="${JIB_SERVER_MIRRORS}"
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
    55
    fi
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    56
    if [ -n "${JIB_REPOSITORY}" ]; then
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    57
        jib_repository="${JIB_REPOSITORY}"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    58
    fi
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    59
    if [ -n "${JIB_ORGANIZATION}" ]; then
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    60
        jib_organization="${JIB_ORGANIZATION}"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    61
    fi
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    62
    if [ -n "${JIB_MODULE}" ]; then
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    63
        jib_module="${JIB_MODULE}"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    64
    fi
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    65
    if [ -n "${JIB_REVISION}" ]; then
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    66
        jib_revision="${JIB_REVISION}"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    67
    fi
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    68
    if [ -n "${JIB_EXTENSION}" ]; then
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    69
        jib_extension="${JIB_EXTENSION}"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    70
    fi
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    71
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    72
    if [ -n "${JIB_URL}" ]; then
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    73
        jib_url="${JIB_URL}"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    74
        data_string="${jib_url}"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    75
    else
34768
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
    76
        jib_path="${jib_repository}/${jib_organization}/${jib_module}/${jib_revision}/${jib_module}-${jib_revision}.${jib_ext}"
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
    77
        data_string="${jib_path}"
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
    78
        jib_url="${jib_server}/${jib_path}"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    79
    fi
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    80
}
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    81
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    82
install_jib() {
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    83
    if [ -z "${jib_server}" -a -z "${JIB_URL}" ]; then
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    84
        echo "No jib server or URL provided, set either"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    85
        echo "JIB_SERVER=<base server address>"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    86
        echo "or"
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
    87
        echo "JIB_URL=<full path to install script>"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    88
        exit 1
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    89
    fi
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    90
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    91
    if command -v curl > /dev/null; then
37862
bc9aa7bc5385 8156733: JIB fails to follow redirects
erikj
parents: 34768
diff changeset
    92
        getcmd="curl -s -L --retry 3 --retry-delay 5"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    93
    elif command -v wget > /dev/null; then
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    94
        getcmd="wget --quiet -O -"
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    95
    else
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    96
        echo "Could not find either curl or wget"
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    97
        exit 1
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    98
    fi
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
    99
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   100
    if ! command -v gunzip > /dev/null; then
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   101
        echo "Could not find gunzip"
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   102
        exit 1
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   103
    fi
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   104
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   105
    echo "Downloading JIB bootstrap script"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   106
    mkdir -p "${installed_jib_script%/*}"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   107
    rm -f "${installed_jib_script}.gz"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   108
    ${getcmd} ${jib_url} > "${installed_jib_script}.gz"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   109
    if [ ! -s "${installed_jib_script}.gz" ]; then
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   110
        echo "Failed to download ${jib_url}"
34768
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   111
        if [ -n "${jib_path}" -a -n "${jib_server_mirrors}" ]; then
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   112
            OLD_IFS="${IFS}"
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   113
            IFS=" ,"
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   114
            for mirror in ${jib_server_mirrors}; do
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   115
                echo "Trying mirror ${mirror}"
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   116
                jib_url="${mirror}/${jib_path}"
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   117
                ${getcmd} ${jib_url} > "${installed_jib_script}.gz"
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   118
                if [ -s "${installed_jib_script}.gz" ]; then
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   119
                    echo "Download from mirror successful"
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   120
                    break
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   121
                else
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   122
                    echo "Failed to download ${jib_url}"
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   123
                fi
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   124
            done
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   125
            IFS="${OLD_IFS}"
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   126
        fi
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   127
        if [ ! -s "${installed_jib_script}.gz" ]; then
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   128
            exit 1
2d0d643ca57c 8146002: Need to support mirrors for bootstrapping Jib
erikj
parents: 34496
diff changeset
   129
        fi
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   130
    fi
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   131
    echo "Extracting JIB bootstrap script"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   132
    rm -f "${installed_jib_script}"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   133
    gunzip "${installed_jib_script}.gz"
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   134
    chmod +x "${installed_jib_script}"
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   135
    echo "${data_string}" > "${install_data}"
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   136
}
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   137
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   138
# Main body starts here
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   139
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   140
setup_url
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   141
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   142
if [ ! -x "${installed_jib_script}" ]; then
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   143
    install_jib
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   144
elif [ ! -e "${install_data}" ] || [ "${data_string}" != "$(cat "${install_data}")" ]; then
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   145
    echo "Install url changed since last time, reinstalling"
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   146
    install_jib
34491
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   147
fi
307c28cb36c2 8136782: Introduce a build/configure wrapper
erikj
parents:
diff changeset
   148
34496
b05757ebc035 8145185: Rename JAB the build tool to JIB
erikj
parents: 34491
diff changeset
   149
${installed_jib_script} "$@"