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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 299 } |
300 | 300 |
301 function die { | 301 function die { |
302 error "$1" | 302 error "$1" |
303 exit 1 | 303 exit 1 |
304 } | 304 } |
305 | 305 |
306 # Retry an emerge command according to $FLAGS_retries | 306 # Retry an emerge command according to $FLAGS_retries |
307 # The $EMERGE_JOBS flags will only be added the first time the command is run | 307 # The $EMERGE_JOBS flags will only be added the first time the command is run |
308 function eretry () { | 308 function eretry () { |
309 $* $EMERGE_JOBS && return 0 | |
310 local i= | 309 local i= |
311 for i in $(seq $FLAGS_retries); do | 310 for i in $(seq $FLAGS_retries); do |
312 echo Retrying $* | 311 echo Retrying $* |
313 $* && return 0 | 312 $* $EMERGE_JOBS && return 0 |
314 done | 313 done |
| 314 $* && return 0 |
315 return 1 | 315 return 1 |
316 } | 316 } |
317 | 317 |
318 # Removes single quotes around parameter | 318 # Removes single quotes around parameter |
319 # Arguments: | 319 # Arguments: |
320 # $1 - string which optionally has surrounding quotes | 320 # $1 - string which optionally has surrounding quotes |
321 # Returns: | 321 # Returns: |
322 # None, but prints the string without quotes. | 322 # None, but prints the string without quotes. |
323 function remove_quotes() { | 323 function remove_quotes() { |
324 echo "$1" | sed -e "s/^'//; s/'$//" | 324 echo "$1" | sed -e "s/^'//; s/'$//" |
(...skipping 20 matching lines...) Expand all Loading... |
345 path=${1:?} | 345 path=${1:?} |
346 shift | 346 shift |
347 | 347 |
348 if ! sudo umount -d "${path}"; then | 348 if ! sudo umount -d "${path}"; then |
349 warn "Failed to unmount ${path}" | 349 warn "Failed to unmount ${path}" |
350 warn "Doing a lazy unmount" | 350 warn "Doing a lazy unmount" |
351 | 351 |
352 sudo umount -d -l "${path}" || die "Failed to lazily unmount ${path}" | 352 sudo umount -d -l "${path}" || die "Failed to lazily unmount ${path}" |
353 fi | 353 fi |
354 } | 354 } |
OLD | NEW |