get_source.sh

Tue, 24 Jun 2014 15:21:47 -0700

author
mduigou
date
Tue, 24 Jun 2014 15:21:47 -0700
changeset 1146
406ecd8cce66
parent 615
8dd61906da5f
child 1147
ec58dd8b23b6
permissions
-rw-r--r--

8047925: Add mercurial version checks to get_source.sh
Reviewed-by: tbell, mikael

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

mercurial