annotate get_source.sh @ 1083:e533bd64ec46

8047925: Add mercurial version checks to get_source.sh Reviewed-by: tbell, mikael
author mduigou
date Tue, 24 Jun 2014 15:21:47 -0700
parents 8dd61906da5f
children db6f64d068e3
rev   line source
ohair@274 1 #!/bin/sh
ohair@274 2
ohair@274 3 #
mduigou@1083 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@1083 28 # Version check
mduigou@1083 29
mduigou@1083 30 # required
mduigou@1083 31 reqdmajor=1
mduigou@1083 32 reqdminor=5
mduigou@1083 33 reqdrev=0
mduigou@1083 34
mduigou@1083 35 # requested
mduigou@1083 36 rqstmajor=2
mduigou@1083 37 rqstminor=6
mduigou@1083 38 rqstrev=3
mduigou@1083 39
mduigou@1083 40 # installed
mduigou@1083 41 hgwhere="`which hg 2> /dev/null | grep -v '^no hg in '`"
mduigou@1083 42 if [ "x$hgwhere" = "x" ]; then
mduigou@1083 43 echo "ERROR: Could not locate Mercurial command" >&2
mduigou@1083 44 exit 126
mduigou@1083 45 fi
mduigou@1083 46
mduigou@1083 47 hgversion="`hg --version 2> /dev/null | sed -n -e 's@^Mercurial Distributed SCM (version \(.*\))\$@\1@p'`"
mduigou@1083 48 if [ "x${hgversion}" = "x" ] ; then
mduigou@1083 49 echo "ERROR: Could not determine Mercurial version" >&2
mduigou@1083 50 exit 126
mduigou@1083 51 fi
mduigou@1083 52
mduigou@1083 53 hgmajor="`echo $hgversion | cut -f 1 -d .`"
mduigou@1083 54 hgminor="`echo $hgversion | cut -f 2 -d .`"
mduigou@1083 55 hgrev="`echo $hgversion.0 | cut -f 3 -d .`" # rev is omitted for minor and major releases
mduigou@1083 56
mduigou@1083 57 # Require
mduigou@1083 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@1083 59 echo "ERROR: Mercurial version $reqdmajor.$reqdminor.$reqdrev or later is required. $hgwhere is version $hgversion" >&2
mduigou@1083 60 exit 126
mduigou@1083 61 fi
mduigou@1083 62
mduigou@1083 63 # Request
mduigou@1083 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@1083 65 echo "WARNING: Mercurial version $rqstmajor.$rqstminor.$rqstrev or later is recommended. $hgwhere is version $hgversion" >&2
mduigou@1083 66 fi
mduigou@1083 67
mduigou@1083 68 # Get clones of all absent nested repositories (harmless if already exist)
mduigou@1083 69 sh ./common/bin/hgforest.sh clone "$@" || exit $?
ohair@274 70
ohair@274 71 # Update all existing repositories to the latest sources
ohrstrom@536 72 sh ./common/bin/hgforest.sh pull -u