annotate get_source.sh @ 25041:9dd97886fae6

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