annotate get_source.sh @ 2287:5d4431231254

Merge
author aefimov
date Sun, 30 Sep 2018 19:46:50 +0100
parents ec58dd8b23b6
children
rev   line source
ohair@274 1 #!/bin/sh
ohair@274 2
ohair@274 3 #
mduigou@1057 4 # Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
ohair@274 5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@274 6 #
ohair@274 7 # This code is free software; you can redistribute it and/or modify it
ohair@274 8 # under the terms of the GNU General Public License version 2 only, as
ohair@274 9 # published by the Free Software Foundation. Oracle designates this
ohair@274 10 # particular file as subject to the "Classpath" exception as provided
ohair@274 11 # by Oracle in the LICENSE file that accompanied this code.
ohair@274 12 #
ohair@274 13 # This code is distributed in the hope that it will be useful, but WITHOUT
ohair@274 14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@274 15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@274 16 # version 2 for more details (a copy is included in the LICENSE file that
ohair@274 17 # accompanied this code).
ohair@274 18 #
ohair@274 19 # You should have received a copy of the GNU General Public License version
ohair@274 20 # 2 along with this work; if not, write to the Free Software Foundation,
ohair@274 21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@274 22 #
ohair@274 23 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@274 24 # or visit www.oracle.com if you need additional information or have any
ohair@274 25 # questions.
ohair@274 26 #
ohair@274 27
mduigou@1058 28 to_stderr() {
mduigou@1058 29 echo "$@" >&2
mduigou@1058 30 }
mduigou@1058 31
mduigou@1058 32 error() {
mduigou@1058 33 to_stderr "ERROR: $1"
mduigou@1058 34 exit ${2:-126}
mduigou@1058 35 }
mduigou@1058 36
mduigou@1058 37 warning() {
mduigou@1058 38 to_stderr "WARNING: $1"
mduigou@1058 39 }
mduigou@1058 40
mduigou@1058 41 version_field() {
mduigou@1058 42 # rev is typically omitted for minor and major releases
mduigou@1058 43 field=`echo ${1}.0 | cut -f ${2} -d .`
mduigou@1058 44 if expr 1 + $field >/dev/null 2> /dev/null; then
mduigou@1058 45 echo $field
mduigou@1058 46 else
mduigou@1058 47 echo -1
mduigou@1058 48 fi
mduigou@1058 49 }
mduigou@1058 50
mduigou@1057 51 # Version check
mduigou@1057 52
mduigou@1057 53 # required
mduigou@1057 54 reqdmajor=1
mduigou@1058 55 reqdminor=4
mduigou@1057 56 reqdrev=0
mduigou@1057 57
mduigou@1057 58 # requested
mduigou@1057 59 rqstmajor=2
mduigou@1057 60 rqstminor=6
mduigou@1057 61 rqstrev=3
mduigou@1057 62
mduigou@1058 63
mduigou@1057 64 # installed
mduigou@1058 65 hgwhere="`command -v hg`"
mduigou@1057 66 if [ "x$hgwhere" = "x" ]; then
mduigou@1058 67 error "Could not locate Mercurial command"
mduigou@1057 68 fi
mduigou@1057 69
mduigou@1732 70 hgversion="`LANGUAGE=en hg --version 2> /dev/null | sed -n -e 's@^Mercurial Distributed SCM (version \([^+]*\).*)\$@\1@p'`"
mduigou@1057 71 if [ "x${hgversion}" = "x" ] ; then
mduigou@1058 72 error "Could not determine Mercurial version of $hgwhere"
mduigou@1057 73 fi
mduigou@1057 74
mduigou@1058 75 hgmajor="`version_field $hgversion 1`"
mduigou@1058 76 hgminor="`version_field $hgversion 2`"
mduigou@1058 77 hgrev="`version_field $hgversion 3`"
mduigou@1058 78
mduigou@1058 79 if [ $hgmajor -eq -1 -o $hgminor -eq -1 -o $hgrev -eq -1 ] ; then
mduigou@1058 80 error "Could not determine Mercurial version of $hgwhere from \"$hgversion\""
mduigou@1058 81 fi
mduigou@1058 82
mduigou@1057 83
mduigou@1057 84 # Require
mduigou@1057 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
mduigou@1058 86 error "Mercurial version $reqdmajor.$reqdminor.$reqdrev or later is required. $hgwhere is version $hgversion"
mduigou@1057 87 fi
mduigou@1057 88
mduigou@1058 89
mduigou@1057 90 # Request
mduigou@1057 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
mduigou@1058 92 warning "Mercurial version $rqstmajor.$rqstminor.$rqstrev or later is recommended. $hgwhere is version $hgversion"
mduigou@1057 93 fi
mduigou@1057 94
mduigou@1058 95
mduigou@1057 96 # Get clones of all absent nested repositories (harmless if already exist)
mduigou@1057 97 sh ./common/bin/hgforest.sh clone "$@" || exit $?
ohair@274 98
ohair@274 99 # Update all existing repositories to the latest sources
ohrstrom@536 100 sh ./common/bin/hgforest.sh pull -u