make/scripts/hgforest.sh
author ohair
Thu, 10 May 2012 08:26:26 -0700
changeset 12582 46d24df71c5d
parent 7650 6a3a53d8eacc
child 12583 78cadbe9f385
permissions -rw-r--r--
7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest Reviewed-by: erikj, asaha, chegar, sla, dholmes, mbykov, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     1
#!/bin/sh
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     2
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     3
#
12582
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
     4
# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     6
#
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
     9
# published by the Free Software Foundation.
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    10
#
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    15
# accompanied this code).
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    16
#
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    20
#
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    23
# questions.
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    24
#
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    25
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    26
# Shell script for a fast parallel forest command
12582
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    27
command="$1"
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    28
pull_extra_base="$2"
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    29
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    30
tmp=/tmp/forest.$$
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    31
rm -f -r ${tmp}
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    32
mkdir -p ${tmp}
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    33
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    34
# Remove tmp area on A. B. Normal termination
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    35
trap 'rm -f -r ${tmp}' KILL
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    36
trap 'rm -f -r ${tmp}' EXIT
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    37
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    38
# Only look in specific locations for possible forests (avoids long searches)
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    39
pull_default=""
12582
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    40
repos=""
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    41
repos_extra=""
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    42
if [ "${command}" = "clone" -o "${command}" = "fclone" ] ; then
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    43
  subrepos="corba jaxp jaxws langtools jdk hotspot"
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    44
  if [ -f .hg/hgrc ] ; then
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    45
    pull_default=`hg paths default`
12582
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    46
    if [ "${pull_default}" = "" ] ; then
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    47
      echo "ERROR: Need initial clone with 'hg paths default' defined"
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    48
      exit 1
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    49
    fi
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    50
  fi
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    51
  if [ "${pull_default}" = "" ] ; then
12582
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    52
    echo "ERROR: Need initial repository to use this script"
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    53
    exit 1
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    54
  fi
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    55
  for i in ${subrepos} ; do
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    56
    if [ ! -f ${i}/.hg/hgrc ] ; then
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    57
      repos="${repos} ${i}"
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    58
    fi
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    59
  done
12582
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    60
  if [ "${pull_extra_base}" != "" ] ; then
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    61
    subrepos_extra="jdk/src/closed jdk/make/closed jdk/test/closed hotspot/src/closed hotspot/test/closed deploy install sponsors pubs"
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    62
    pull_default_base=`echo ${pull_default} | sed -e 's@\(^.*://[^/]*\)/.*@\1@'`
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    63
    pull_extra=`echo ${pull_default} | sed -e "s@${pull_default_base}@${pull_extra_base}@"`
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    64
    for i in ${subrepos_extra} ; do
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    65
      if [ ! -f ${i}/.hg/hgrc ] ; then
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    66
        repos_extra="${repos_extra} ${i}"
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    67
      fi
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    68
    done
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    69
  fi
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    70
  at_a_time=2
12582
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    71
  # Any repos to deal with?
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    72
  if [ "${repos}" = "" -a "${repos_extra}" = "" ] ; then
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    73
    echo "No repositories to clone."
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    74
    exit
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    75
  fi
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    76
else
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    77
  hgdirs=`ls -d ./.hg ./*/.hg ./*/*/.hg ./*/*/*/.hg ./*/*/*/*/.hg 2>/dev/null`
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    78
  # Derive repository names from the .hg directory locations
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    79
  for i in ${hgdirs} ; do
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    80
    repos="${repos} `echo ${i} | sed -e 's@/.hg$@@'`"
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    81
  done
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    82
  at_a_time=8
12582
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    83
  # Any repos to deal with?
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    84
  if [ "${repos}" = "" ] ; then
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    85
    echo "No repositories to process."
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    86
    exit
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    87
  fi
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    88
fi
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    89
12582
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    90
# Echo out what repositories we will clone
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
    91
echo "# Repos: ${repos} ${repos_extra}"
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    92
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    93
# Run the supplied command on all repos in parallel, save output until end
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    94
n=0
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    95
for i in ${repos} ; do
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    96
  echo "Starting on ${i}"
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    97
  n=`expr ${n} '+' 1`
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    98
  (
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
    99
    (
12582
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   100
      if [ "${command}" = "clone" -o "${command}" = "fclone" ] ; then
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   101
        cline="hg clone ${pull_default}/${i} ${i}"
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   102
        echo "# ${cline}"
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   103
        ( eval "${cline}" )
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   104
      else
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   105
        cline="hg $*"
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   106
        echo "# cd ${i} && ${cline}"
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   107
        ( cd ${i} && eval "${cline}" )
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   108
      fi
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   109
      echo "# exit code $?"
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   110
    ) > ${tmp}/repo.${n} 2>&1 ; cat ${tmp}/repo.${n} ) &
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   111
  if [ `expr ${n} '%' ${at_a_time}` -eq 0 ] ; then
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   112
    sleep 5
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   113
  fi
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   114
done
12582
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   115
if [ "${repos_extra}" != "" ] ; then
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   116
  for i in ${repos_extra} ; do
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   117
    echo "Starting on ${i}"
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   118
    n=`expr ${n} '+' 1`
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   119
    (
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   120
      (
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   121
          cline="hg clone ${pull_extra}/${i} ${i}"
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   122
          echo "# ${cline}"
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   123
          ( eval "${cline}" )
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   124
        echo "# exit code $?"
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   125
      ) > ${tmp}/repo.${n} 2>&1 ; cat ${tmp}/repo.${n} ) &
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   126
    if [ `expr ${n} '%' ${at_a_time}` -eq 0 ] ; then
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   127
      sleep 5
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   128
    fi
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   129
  done
46d24df71c5d 7167593: Changed get_source.sh to allow for getting full oracle jdk repo forest
ohair
parents: 7650
diff changeset
   130
fi
7650
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   131
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   132
# Wait for all hg commands to complete
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   133
wait
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   134
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   135
# Cleanup
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   136
rm -f -r ${tmp}
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   137
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   138
# Terminate with exit 0 all the time (hard to know when to say "failed")
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   139
exit 0
6a3a53d8eacc 7003845: README-builds document proper location of forest extension, provide alternatives
ohair
parents:
diff changeset
   140