OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Common constants for build scripts | 5 # Common constants for build scripts |
6 # This must evaluate properly for both /bin/bash and /bin/sh | 6 # This must evaluate properly for both /bin/bash and /bin/sh |
7 | 7 |
8 # All scripts should die on error unless commands are specifically excepted | 8 # All scripts should die on error unless commands are specifically excepted |
9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. | 9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. |
10 # TODO: Re-enable this once shflags is less prone to dying. | 10 # TODO: Re-enable this once shflags is less prone to dying. |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 function error { | 318 function error { |
319 echo -e "${V_BOLD_RED}ERROR : $1${V_VIDOFF}" | 319 echo -e "${V_BOLD_RED}ERROR : $1${V_VIDOFF}" |
320 } | 320 } |
321 | 321 |
322 function die { | 322 function die { |
323 error "$1" | 323 error "$1" |
324 exit 1 | 324 exit 1 |
325 } | 325 } |
326 | 326 |
327 # Retry an emerge command according to $FLAGS_retries | 327 # Retry an emerge command according to $FLAGS_retries |
328 # The $EMERGE_JOBS flags will only be added the first time the command is run | |
329 function eretry () { | 328 function eretry () { |
| 329 $* && return 0 |
330 local i= | 330 local i= |
331 for i in $(seq $FLAGS_retries); do | 331 for i in $(seq $FLAGS_retries); do |
332 echo Retrying $* | 332 echo Retrying $* |
333 $* $EMERGE_JOBS && return 0 | 333 $* && return 0 |
334 done | 334 done |
335 $* && return 0 | |
336 return 1 | 335 return 1 |
337 } | 336 } |
338 | 337 |
339 # Removes single quotes around parameter | 338 # Removes single quotes around parameter |
340 # Arguments: | 339 # Arguments: |
341 # $1 - string which optionally has surrounding quotes | 340 # $1 - string which optionally has surrounding quotes |
342 # Returns: | 341 # Returns: |
343 # None, but prints the string without quotes. | 342 # None, but prints the string without quotes. |
344 function remove_quotes() { | 343 function remove_quotes() { |
345 echo "$1" | sed -e "s/^'//; s/'$//" | 344 echo "$1" | sed -e "s/^'//; s/'$//" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 start_time=$(date +%s) | 438 start_time=$(date +%s) |
440 | 439 |
441 # Print time elsapsed since start_time. | 440 # Print time elsapsed since start_time. |
442 print_time_elapsed() { | 441 print_time_elapsed() { |
443 end_time=$(date +%s) | 442 end_time=$(date +%s) |
444 elapsed_seconds="$(( $end_time - $start_time ))" | 443 elapsed_seconds="$(( $end_time - $start_time ))" |
445 minutes="$(( $elapsed_seconds / 60 ))" | 444 minutes="$(( $elapsed_seconds / 60 ))" |
446 seconds="$(( $elapsed_seconds % 60 ))" | 445 seconds="$(( $elapsed_seconds % 60 ))" |
447 echo "Elapsed time: ${minutes}:${seconds}" | 446 echo "Elapsed time: ${minutes}:${seconds}" |
448 } | 447 } |
OLD | NEW |