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