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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 start_time=$(date +%s) | 453 start_time=$(date +%s) |
454 | 454 |
455 # Print time elsapsed since start_time. | 455 # Print time elsapsed since start_time. |
456 print_time_elapsed() { | 456 print_time_elapsed() { |
457 end_time=$(date +%s) | 457 end_time=$(date +%s) |
458 elapsed_seconds="$(( $end_time - $start_time ))" | 458 elapsed_seconds="$(( $end_time - $start_time ))" |
459 minutes="$(( $elapsed_seconds / 60 ))" | 459 minutes="$(( $elapsed_seconds / 60 ))" |
460 seconds="$(( $elapsed_seconds % 60 ))" | 460 seconds="$(( $elapsed_seconds % 60 ))" |
461 echo "Elapsed time: ${minutes}m${seconds}s" | 461 echo "Elapsed time: ${minutes}m${seconds}s" |
462 } | 462 } |
463 | |
464 # This function is a place to put code to incrementally update the | |
465 # chroot so that users don't need to fully re-make it. It should | |
466 # be called from scripts that are run _outside_ the chroot. | |
467 # | |
468 # Please put date information so it's easy to keep track of when | |
469 # old hacks can be retired and so that people can detect when a | |
470 # hack triggered when it shouldn't have. | |
471 # | |
472 # ${1} specifies the location of the chroot. | |
473 chroot_hacks_from_outside() { | |
474 # Give args better names. | |
davidjames
2010/10/19 21:24:23
No need for this comment.
| |
475 local chroot_dir="${1}" | |
476 | |
477 # Add root as a sudoer if not already done. | |
478 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then | |
479 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers" | |
480 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\"" | |
481 fi | |
482 } | |
OLD | NEW |