get_source.sh
author cjplummer
Fri, 05 Dec 2014 15:44:01 -0800
changeset 27954 d2c87a8d2f37
parent 26117 f33e2783f40d
permissions -rw-r--r--
8066507: JPRT is not capable of running jtreg tests located jdk/test Summary: Fixed by copying same fix already in place in hotspot/test/Makefile. Reviewed-by: dholmes, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     1
#!/bin/sh
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     2
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     3
#
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
     4
# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     6
#
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     9
# published by the Free Software Foundation.  Oracle designates this
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    10
# particular file as subject to the "Classpath" exception as provided
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    11
# by Oracle in the LICENSE file that accompanied this code.
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    12
#
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    13
# This code is distributed in the hope that it will be useful, but WITHOUT
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    14
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    15
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    16
# version 2 for more details (a copy is included in the LICENSE file that
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    17
# accompanied this code).
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    18
#
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    19
# You should have received a copy of the GNU General Public License version
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    20
# 2 along with this work; if not, write to the Free Software Foundation,
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    21
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    22
#
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    23
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    24
# or visit www.oracle.com if you need additional information or have any
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    25
# questions.
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    26
#
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    27
25317
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    28
to_stderr() {
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    29
    echo "$@" >&2
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    30
}
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    31
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    32
error() {
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    33
    to_stderr "ERROR: $1"
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    34
    exit ${2:-126}
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    35
}
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    36
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    37
warning() {
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    38
    to_stderr "WARNING: $1"
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    39
}
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    40
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    41
version_field() {
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    42
  # rev is typically omitted for minor and major releases
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    43
  field=`echo ${1}.0 | cut -f ${2} -d .`
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    44
  if expr 1 + $field >/dev/null 2> /dev/null; then
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    45
    echo $field
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    46
  else
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    47
    echo -1
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    48
  fi
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    49
}
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    50
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    51
# Version check
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    52
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    53
# required
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    54
reqdmajor=1
25317
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    55
reqdminor=4
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    56
reqdrev=0
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    57
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    58
# requested
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    59
rqstmajor=2
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    60
rqstminor=6
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    61
rqstrev=3
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    62
25317
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    63
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    64
# installed
25317
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    65
hgwhere="`command -v hg`"
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    66
if [ "x$hgwhere" = "x" ]; then
25317
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    67
  error "Could not locate Mercurial command"
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    68
fi
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    69
26117
f33e2783f40d 8055772: get_source.sh : version check assumes English localization
mduigou
parents: 25317
diff changeset
    70
hgversion="`LANGUAGE=en hg --version 2> /dev/null | sed -n -e 's@^Mercurial Distributed SCM (version \([^+]*\).*)\$@\1@p'`"
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    71
if [ "x${hgversion}" = "x" ] ; then
25317
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    72
  error "Could not determine Mercurial version of $hgwhere"
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    73
fi
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    74
25317
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    75
hgmajor="`version_field $hgversion 1`"
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    76
hgminor="`version_field $hgversion 2`"
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    77
hgrev="`version_field $hgversion 3`"
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    78
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    79
if [ $hgmajor -eq -1 -o $hgminor -eq -1 -o $hgrev -eq -1 ] ; then
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    80
  error "Could not determine Mercurial version of $hgwhere from \"$hgversion\""
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    81
fi
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    82
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    83
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    84
# Require
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    85
if [ $hgmajor -lt $reqdmajor -o \( $hgmajor -eq $reqdmajor -a $hgminor -lt $reqdminor \) -o \( $hgmajor -eq $reqdmajor -a $hgminor -eq $reqdminor -a $hgrev -lt $reqdrev \) ] ; then
25317
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    86
  error "Mercurial version $reqdmajor.$reqdminor.$reqdrev or later is required. $hgwhere is version $hgversion"
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    87
fi
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    88
25317
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    89
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    90
# Request
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    91
if [ $hgmajor -lt $rqstmajor -o \( $hgmajor -eq $rqstmajor -a $hgminor -lt $rqstminor \) -o \( $hgmajor -eq $rqstmajor -a $hgminor -eq $rqstminor -a $hgrev -lt $rqstrev \) ] ; then
25317
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    92
  warning "Mercurial version $rqstmajor.$rqstminor.$rqstrev or later is recommended. $hgwhere is version $hgversion"
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    93
fi
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    94
25317
fa3876203ca9 8048184: handle mercurial dev build version string
mduigou
parents: 25041
diff changeset
    95
25041
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    96
# Get clones of all absent nested repositories (harmless if already exist)
9dd97886fae6 8047925: Add mercurial version checks to get_source.sh
mduigou
parents: 15575
diff changeset
    97
sh ./common/bin/hgforest.sh clone "$@" || exit $?
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    98
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    99
# Update all existing repositories to the latest sources
14735
804551752e64 8004145: New improved hgforest.sh, ctrl-c now properly terminates mercurial processes.
ohrstrom
parents: 12582
diff changeset
   100
sh ./common/bin/hgforest.sh pull -u