make/scripts/hgforest.sh

Print this page

        

*** 1,9 **** #!/bin/sh # ! # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. --- 1,9 ---- #!/bin/sh # ! # Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation.
*** 22,31 **** --- 22,33 ---- # or visit www.oracle.com if you need additional information or have any # questions. # # Shell script for a fast parallel forest command + command="$1" + pull_extra_base="$2" tmp=/tmp/forest.$$ rm -f -r ${tmp} mkdir -p ${tmp}
*** 33,86 **** trap 'rm -f -r ${tmp}' KILL trap 'rm -f -r ${tmp}' EXIT # Only look in specific locations for possible forests (avoids long searches) pull_default="" ! if [ "$1" = "clone" -o "$1" = "fclone" ] ; then subrepos="corba jaxp jaxws langtools jdk hotspot" if [ -f .hg/hgrc ] ; then pull_default=`hg paths default` - fi if [ "${pull_default}" = "" ] ; then echo "ERROR: Need initial clone with 'hg paths default' defined" exit 1 fi ! repos="" for i in ${subrepos} ; do if [ ! -f ${i}/.hg/hgrc ] ; then repos="${repos} ${i}" fi done at_a_time=2 else hgdirs=`ls -d ./.hg ./*/.hg ./*/*/.hg ./*/*/*/.hg ./*/*/*/*/.hg 2>/dev/null` # Derive repository names from the .hg directory locations - repos="" for i in ${hgdirs} ; do repos="${repos} `echo ${i} | sed -e 's@/.hg$@@'`" done at_a_time=8 ! fi ! ! # Any repos to deal with? ! if [ "${repos}" = "" ] ; then echo "No repositories to process." exit fi ! # Echo out what repositories we will process ! echo "# Repos: ${repos}" # Run the supplied command on all repos in parallel, save output until end n=0 for i in ${repos} ; do echo "Starting on ${i}" n=`expr ${n} '+' 1` ( ( ! if [ "$1" = "clone" -o "$1" = "fclone" ] ; then ! cline="hg $* ${pull_default}/${i} ${i}" echo "# ${cline}" ( eval "${cline}" ) else cline="hg $*" echo "# cd ${i} && ${cline}" --- 35,106 ---- trap 'rm -f -r ${tmp}' KILL trap 'rm -f -r ${tmp}' EXIT # Only look in specific locations for possible forests (avoids long searches) pull_default="" ! repos="" ! repos_extra="" ! if [ "${command}" = "clone" -o "${command}" = "fclone" ] ; then subrepos="corba jaxp jaxws langtools jdk hotspot" if [ -f .hg/hgrc ] ; then pull_default=`hg paths default` if [ "${pull_default}" = "" ] ; then echo "ERROR: Need initial clone with 'hg paths default' defined" exit 1 fi ! fi ! if [ "${pull_default}" = "" ] ; then ! echo "ERROR: Need initial repository to use this script" ! exit 1 ! fi for i in ${subrepos} ; do if [ ! -f ${i}/.hg/hgrc ] ; then repos="${repos} ${i}" fi done + if [ "${pull_extra_base}" != "" ] ; then + subrepos_extra="jdk/src/closed jdk/make/closed jdk/test/closed hotspot/src/closed hotspot/test/closed deploy install sponsors pubs" + pull_default_base=`echo ${pull_default} | sed -e 's@\(^.*://[^/]*\)/.*@\1@'` + pull_extra=`echo ${pull_default} | sed -e "s@${pull_default_base}@${pull_extra_base}@"` + for i in ${subrepos_extra} ; do + if [ ! -f ${i}/.hg/hgrc ] ; then + repos_extra="${repos_extra} ${i}" + fi + done + fi at_a_time=2 + # Any repos to deal with? + if [ "${repos}" = "" -a "${repos_extra}" = "" ] ; then + echo "No repositories to clone." + exit + fi else hgdirs=`ls -d ./.hg ./*/.hg ./*/*/.hg ./*/*/*/.hg ./*/*/*/*/.hg 2>/dev/null` # Derive repository names from the .hg directory locations for i in ${hgdirs} ; do repos="${repos} `echo ${i} | sed -e 's@/.hg$@@'`" done at_a_time=8 ! # Any repos to deal with? ! if [ "${repos}" = "" ] ; then echo "No repositories to process." exit + fi fi ! # Echo out what repositories we will clone ! echo "# Repos: ${repos} ${repos_extra}" # Run the supplied command on all repos in parallel, save output until end n=0 for i in ${repos} ; do echo "Starting on ${i}" n=`expr ${n} '+' 1` ( ( ! if [ "${command}" = "clone" -o "${command}" = "fclone" ] ; then ! cline="hg clone ${pull_default}/${i} ${i}" echo "# ${cline}" ( eval "${cline}" ) else cline="hg $*" echo "# cd ${i} && ${cline}"
*** 90,99 **** --- 110,135 ---- ) > ${tmp}/repo.${n} 2>&1 ; cat ${tmp}/repo.${n} ) & if [ `expr ${n} '%' ${at_a_time}` -eq 0 ] ; then sleep 5 fi done + if [ "${repos_extra}" != "" ] ; then + for i in ${repos_extra} ; do + echo "Starting on ${i}" + n=`expr ${n} '+' 1` + ( + ( + cline="hg clone ${pull_extra}/${i} ${i}" + echo "# ${cline}" + ( eval "${cline}" ) + echo "# exit code $?" + ) > ${tmp}/repo.${n} 2>&1 ; cat ${tmp}/repo.${n} ) & + if [ `expr ${n} '%' ${at_a_time}` -eq 0 ] ; then + sleep 5 + fi + done + fi # Wait for all hg commands to complete wait # Cleanup