| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 set -o nounset | 6 set -o nounset |
| 7 set -o errexit | 7 set -o errexit |
| 8 | 8 |
| 9 # Turn on/off debugging mode | 9 # Turn on/off debugging mode |
| 10 readonly UTMAN_DEBUG=${UTMAN_DEBUG:-false} | 10 readonly PNACL_DEBUG=${PNACL_DEBUG:-false} |
| 11 | 11 |
| 12 # True if the scripts are running on the build bots. | 12 # True if the scripts are running on the build bots. |
| 13 readonly UTMAN_BUILDBOT=${UTMAN_BUILDBOT:-false} | 13 readonly PNACL_BUILDBOT=${PNACL_BUILDBOT:-false} |
| 14 | 14 |
| 15 # Dump all build output to stdout | 15 # Dump all build output to stdout |
| 16 readonly UTMAN_VERBOSE=${UTMAN_VERBOSE:-false} | 16 readonly PNACL_VERBOSE=${PNACL_VERBOSE:-false} |
| 17 | 17 |
| 18 # Mercurial Retry settings | 18 # Mercurial Retry settings |
| 19 HG_MAX_RETRIES=${HG_MAX_RETRIES:-3} | 19 HG_MAX_RETRIES=${HG_MAX_RETRIES:-3} |
| 20 if ${UTMAN_BUILDBOT} ; then | 20 if ${PNACL_BUILDBOT} ; then |
| 21 HG_RETRY_DELAY_SEC=${HG_RETRY_DELAY_SEC:-60} | 21 HG_RETRY_DELAY_SEC=${HG_RETRY_DELAY_SEC:-60} |
| 22 else | 22 else |
| 23 HG_RETRY_DELAY_SEC=${HG_RETRY_DELAY_SEC:-1} | 23 HG_RETRY_DELAY_SEC=${HG_RETRY_DELAY_SEC:-1} |
| 24 fi | 24 fi |
| 25 | 25 |
| 26 readonly TIME_AT_STARTUP=$(date '+%s') | 26 readonly TIME_AT_STARTUP=$(date '+%s') |
| 27 | 27 |
| 28 SetScriptPath() { | 28 SetScriptPath() { |
| 29 SCRIPT_PATH="$1" | 29 SCRIPT_PATH="$1" |
| 30 } | 30 } |
| 31 | 31 |
| 32 SetLogDirectory() { | 32 SetLogDirectory() { |
| 33 TC_LOG="$1" | 33 TC_LOG="$1" |
| 34 TC_LOG_ALL="${TC_LOG}/ALL" | 34 TC_LOG_ALL="${TC_LOG}/ALL" |
| 35 } | 35 } |
| 36 | 36 |
| 37 ###################################################################### | 37 ###################################################################### |
| 38 # Detect if we are in a ChromiumOS chroot | 38 # Detect if we are in a ChromiumOS chroot |
| 39 ###################################################################### | 39 ###################################################################### |
| 40 if [ -e /etc/debian_chroot ]; then | 40 if [ -e /etc/debian_chroot ]; then |
| 41 readonly UTMAN_IN_CROS_CHROOT=true | 41 readonly PNACL_IN_CROS_CHROOT=true |
| 42 else | 42 else |
| 43 readonly UTMAN_IN_CROS_CHROOT=false | 43 readonly PNACL_IN_CROS_CHROOT=false |
| 44 fi | 44 fi |
| 45 | 45 |
| 46 ###################################################################### | 46 ###################################################################### |
| 47 # Detect system type | 47 # Detect system type |
| 48 ###################################################################### | 48 ###################################################################### |
| 49 | 49 |
| 50 BUILD_PLATFORM=$(uname | tr '[A-Z]' '[a-z]') | 50 BUILD_PLATFORM=$(uname | tr '[A-Z]' '[a-z]') |
| 51 BUILD_PLATFORM_LINUX=false | 51 BUILD_PLATFORM_LINUX=false |
| 52 BUILD_PLATFORM_MAC=false | 52 BUILD_PLATFORM_MAC=false |
| 53 BUILD_PLATFORM_WIN=false | 53 BUILD_PLATFORM_WIN=false |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 echo "$*" >> "${TC_LOG_ALL}" | 508 echo "$*" >> "${TC_LOG_ALL}" |
| 509 } | 509 } |
| 510 | 510 |
| 511 RunWithLog() { | 511 RunWithLog() { |
| 512 local log="${TC_LOG}/$1" | 512 local log="${TC_LOG}/$1" |
| 513 | 513 |
| 514 mkdir -p "${TC_LOG}" | 514 mkdir -p "${TC_LOG}" |
| 515 | 515 |
| 516 shift 1 | 516 shift 1 |
| 517 local ret=1 | 517 local ret=1 |
| 518 if ${UTMAN_VERBOSE}; then | 518 if ${PNACL_VERBOSE}; then |
| 519 echo "RUNNING: " "$@" | tee -a "${log}" "${TC_LOG_ALL}" | 519 echo "RUNNING: " "$@" | tee -a "${log}" "${TC_LOG_ALL}" |
| 520 "$@" 2>&1 | tee -a "${log}" "${TC_LOG_ALL}" | 520 "$@" 2>&1 | tee -a "${log}" "${TC_LOG_ALL}" |
| 521 ret=${PIPESTATUS[0]} | 521 ret=${PIPESTATUS[0]} |
| 522 else | 522 else |
| 523 echo "RUNNING: " "$@" | tee -a "${log}" "${TC_LOG_ALL}" &> /dev/null | 523 echo "RUNNING: " "$@" | tee -a "${log}" "${TC_LOG_ALL}" &> /dev/null |
| 524 "$@" 2>&1 | tee -a "${log}" "${TC_LOG_ALL}" &> /dev/null | 524 "$@" 2>&1 | tee -a "${log}" "${TC_LOG_ALL}" &> /dev/null |
| 525 ret=${PIPESTATUS[0]} | 525 ret=${PIPESTATUS[0]} |
| 526 fi | 526 fi |
| 527 if [ ${ret} -ne 0 ]; then | 527 if [ ${ret} -ne 0 ]; then |
| 528 echo | 528 echo |
| 529 Banner "ERROR" | 529 Banner "ERROR" |
| 530 echo -n "COMMAND:" | 530 echo -n "COMMAND:" |
| 531 PrettyPrint "$@" | 531 PrettyPrint "$@" |
| 532 echo | 532 echo |
| 533 echo "LOGFILE: ${log}" | 533 echo "LOGFILE: ${log}" |
| 534 echo | 534 echo |
| 535 echo "PWD: $(pwd)" | 535 echo "PWD: $(pwd)" |
| 536 echo | 536 echo |
| 537 if ${UTMAN_BUILDBOT}; then | 537 if ${PNACL_BUILDBOT}; then |
| 538 echo "BEGIN LOGFILE Contents." | 538 echo "BEGIN LOGFILE Contents." |
| 539 cat "${log}" | 539 cat "${log}" |
| 540 echo "END LOGFILE Contents." | 540 echo "END LOGFILE Contents." |
| 541 fi | 541 fi |
| 542 return 1 | 542 return 1 |
| 543 fi | 543 fi |
| 544 return 0 | 544 return 0 |
| 545 } | 545 } |
| 546 | 546 |
| 547 PrettyPrint() { | 547 PrettyPrint() { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 # command2 & | 738 # command2 & |
| 739 # QueueLastProcess | 739 # QueueLastProcess |
| 740 # command3 & | 740 # command3 & |
| 741 # QueueLastProcess | 741 # QueueLastProcess |
| 742 # echo "Waiting for commands finish..." | 742 # echo "Waiting for commands finish..." |
| 743 # QueueWait | 743 # QueueWait |
| 744 # | 744 # |
| 745 # TODO(pdox): Right now, this abstraction is only used for | 745 # TODO(pdox): Right now, this abstraction is only used for |
| 746 # paralellizing translations in the self-build. If we're going | 746 # paralellizing translations in the self-build. If we're going |
| 747 # to use this for anything more complex, then throttling the | 747 # to use this for anything more complex, then throttling the |
| 748 # number of active processes to exactly UTMAN_CONCURRENCY would | 748 # number of active processes to exactly PNACL_CONCURRENCY would |
| 749 # be a useful feature. | 749 # be a useful feature. |
| 750 CT_WAIT_QUEUE="" | 750 CT_WAIT_QUEUE="" |
| 751 QueueLastProcess() { | 751 QueueLastProcess() { |
| 752 local pid=$! | 752 local pid=$! |
| 753 CT_WAIT_QUEUE+=" ${pid}" | 753 CT_WAIT_QUEUE+=" ${pid}" |
| 754 if ! QueueConcurrent ; then | 754 if ! QueueConcurrent ; then |
| 755 QueueWait | 755 QueueWait |
| 756 fi | 756 fi |
| 757 } | 757 } |
| 758 | 758 |
| 759 QueueConcurrent() { | 759 QueueConcurrent() { |
| 760 [ ${UTMAN_CONCURRENCY} -gt 1 ] | 760 [ ${PNACL_CONCURRENCY} -gt 1 ] |
| 761 } | 761 } |
| 762 | 762 |
| 763 QueueWait() { | 763 QueueWait() { |
| 764 for pid in ${CT_WAIT_QUEUE} ; do | 764 for pid in ${CT_WAIT_QUEUE} ; do |
| 765 wait ${pid} | 765 wait ${pid} |
| 766 done | 766 done |
| 767 CT_WAIT_QUEUE="" | 767 CT_WAIT_QUEUE="" |
| 768 } | 768 } |
| 769 | 769 |
| 770 # Add a trap so that if the user Ctrl-C's or kills | 770 # Add a trap so that if the user Ctrl-C's or kills |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 StepBanner "RUN-WITH-RETRY" "Retrying in ${delay_sec} seconds." | 804 StepBanner "RUN-WITH-RETRY" "Retrying in ${delay_sec} seconds." |
| 805 sleep ${delay_sec} | 805 sleep ${delay_sec} |
| 806 else | 806 else |
| 807 StepBanner "RUN-WITH-RETRY" \ | 807 StepBanner "RUN-WITH-RETRY" \ |
| 808 "'${cmdname}' failed ${max_retries} times. Aborting." | 808 "'${cmdname}' failed ${max_retries} times. Aborting." |
| 809 return 1 | 809 return 1 |
| 810 fi | 810 fi |
| 811 done | 811 done |
| 812 | 812 |
| 813 } | 813 } |
| OLD | NEW |