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@1093
|
28 to_stderr() {
|
mduigou@1093
|
29 echo "$@" >&2
|
mduigou@1093
|
30 }
|
mduigou@1093
|
31
|
mduigou@1093
|
32 error() {
|
mduigou@1093
|
33 to_stderr "ERROR: $1"
|
mduigou@1093
|
34 exit ${2:-126}
|
mduigou@1093
|
35 }
|
mduigou@1093
|
36
|
mduigou@1093
|
37 warning() {
|
mduigou@1093
|
38 to_stderr "WARNING: $1"
|
mduigou@1093
|
39 }
|
mduigou@1093
|
40
|
mduigou@1093
|
41 version_field() {
|
mduigou@1093
|
42 # rev is typically omitted for minor and major releases
|
mduigou@1093
|
43 field=`echo ${1}.0 | cut -f ${2} -d .`
|
mduigou@1093
|
44 if expr 1 + $field >/dev/null 2> /dev/null; then
|
mduigou@1093
|
45 echo $field
|
mduigou@1093
|
46 else
|
mduigou@1093
|
47 echo -1
|
mduigou@1093
|
48 fi
|
mduigou@1093
|
49 }
|
mduigou@1093
|
50
|
mduigou@1083
|
51 # Version check
|
mduigou@1083
|
52
|
mduigou@1083
|
53 # required
|
mduigou@1083
|
54 reqdmajor=1
|
mduigou@1093
|
55 reqdminor=4
|
mduigou@1083
|
56 reqdrev=0
|
mduigou@1083
|
57
|
mduigou@1083
|
58 # requested
|
mduigou@1083
|
59 rqstmajor=2
|
mduigou@1083
|
60 rqstminor=6
|
mduigou@1083
|
61 rqstrev=3
|
mduigou@1083
|
62
|
mduigou@1093
|
63
|
mduigou@1083
|
64 # installed
|
mduigou@1093
|
65 hgwhere="`command -v hg`"
|
mduigou@1083
|
66 if [ "x$hgwhere" = "x" ]; then
|
mduigou@1093
|
67 error "Could not locate Mercurial command"
|
mduigou@1083
|
68 fi
|
mduigou@1083
|
69
|
mduigou@1093
|
70 hgversion="`hg --version 2> /dev/null | sed -n -e 's@^Mercurial Distributed SCM (version \([^+]*\).*)\$@\1@p'`"
|
mduigou@1083
|
71 if [ "x${hgversion}" = "x" ] ; then
|
mduigou@1093
|
72 error "Could not determine Mercurial version of $hgwhere"
|
mduigou@1083
|
73 fi
|
mduigou@1083
|
74
|
mduigou@1093
|
75 hgmajor="`version_field $hgversion 1`"
|
mduigou@1093
|
76 hgminor="`version_field $hgversion 2`"
|
mduigou@1093
|
77 hgrev="`version_field $hgversion 3`"
|
mduigou@1093
|
78
|
mduigou@1093
|
79 if [ $hgmajor -eq -1 -o $hgminor -eq -1 -o $hgrev -eq -1 ] ; then
|
mduigou@1093
|
80 error "Could not determine Mercurial version of $hgwhere from \"$hgversion\""
|
mduigou@1093
|
81 fi
|
mduigou@1093
|
82
|
mduigou@1083
|
83
|
mduigou@1083
|
84 # Require
|
mduigou@1083
|
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@1093
|
86 error "Mercurial version $reqdmajor.$reqdminor.$reqdrev or later is required. $hgwhere is version $hgversion"
|
mduigou@1083
|
87 fi
|
mduigou@1083
|
88
|
mduigou@1093
|
89
|
mduigou@1083
|
90 # Request
|
mduigou@1083
|
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@1093
|
92 warning "Mercurial version $rqstmajor.$rqstminor.$rqstrev or later is recommended. $hgwhere is version $hgversion"
|
mduigou@1083
|
93 fi
|
mduigou@1083
|
94
|
mduigou@1093
|
95
|
mduigou@1083
|
96 # Get clones of all absent nested repositories (harmless if already exist)
|
mduigou@1083
|
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
|