make/scripts/hgforest.sh

Wed, 27 Apr 2016 01:39:08 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:39:08 +0800
changeset 0
75a576e87639
child 1133
50aaf272884f
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/
changeset: 1170:d117f01bfb4f
tag: jdk8u25-b17

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

mercurial