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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 function sudo_clobber() { | 330 function sudo_clobber() { |
331 sudo tee "$1" > /dev/null | 331 sudo tee "$1" > /dev/null |
332 } | 332 } |
333 | 333 |
334 # Writes stdin to the given file name as root using sudo in append mode. | 334 # Writes stdin to the given file name as root using sudo in append mode. |
335 # | 335 # |
336 # $1 - The output file name. | 336 # $1 - The output file name. |
337 function sudo_append() { | 337 function sudo_append() { |
338 sudo tee -a "$1" > /dev/null | 338 sudo tee -a "$1" > /dev/null |
339 } | 339 } |
| 340 |
| 341 # Unmounts a directory, if the unmount fails, warn, and then lazily unmount. |
| 342 # |
| 343 # $1 - The path to unmount. |
| 344 function safe_umount { |
| 345 path=${1:?} |
| 346 shift |
| 347 |
| 348 if ! sudo umount -d "${path}"; then |
| 349 warn "Failed to unmount ${path}" |
| 350 warn "Doing a lazy unmount" |
| 351 |
| 352 sudo umount -d -l "${path}" || die "Failed to lazily unmount ${path}" |
| 353 fi |
| 354 } |
OLD | NEW |