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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 mv ../${PKG_BASE}_*.deb "$OUT_DIR" | 227 mv ../${PKG_BASE}_*.deb "$OUT_DIR" |
228 rm ../${PKG_BASE}_*.changes | 228 rm ../${PKG_BASE}_*.changes |
229 popd | 229 popd |
230 } | 230 } |
231 | 231 |
232 # Enter a chroot and restart the current script if needed | 232 # Enter a chroot and restart the current script if needed |
233 function restart_in_chroot_if_needed { | 233 function restart_in_chroot_if_needed { |
234 # NB: Pass in ARGV: restart_in_chroot_if_needed "$@" | 234 # NB: Pass in ARGV: restart_in_chroot_if_needed "$@" |
235 if [ $INSIDE_CHROOT -ne 1 ] | 235 if [ $INSIDE_CHROOT -ne 1 ] |
236 then | 236 then |
237 local abspath=$(readlink -f "$0") | 237 # Equivalent to enter_chroot.sh -- <current command> |
238 # strip everything up to (and including) /src/scripts/ from abspath | |
239 local path_from_scripts="${abspath##*/src/scripts/}" | |
240 exec $SCRIPTS_DIR/enter_chroot.sh -- \ | 238 exec $SCRIPTS_DIR/enter_chroot.sh -- \ |
241 "$CHROOT_TRUNK_DIR/src/scripts/$path_from_scripts" "$@" | 239 $CHROOT_TRUNK_DIR/src/scripts/$(basename $0) "$@" |
242 exit | |
243 fi | 240 fi |
244 } | 241 } |
245 | 242 |
246 # Fail unless we're inside the chroot. This guards against messing up your | 243 # Fail unless we're inside the chroot. This guards against messing up your |
247 # workstation. | 244 # workstation. |
248 function assert_inside_chroot { | 245 function assert_inside_chroot { |
249 if [ $INSIDE_CHROOT -ne 1 ] | 246 if [ $INSIDE_CHROOT -ne 1 ] |
250 then | 247 then |
251 echo "This script must be run inside the chroot. Run this first:" | 248 echo "This script must be run inside the chroot. Run this first:" |
252 echo " $SCRIPTS_DIR/enter_chroot.sh" | 249 echo " $SCRIPTS_DIR/enter_chroot.sh" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 chroot_hacks_from_outside() { | 517 chroot_hacks_from_outside() { |
521 # Give args better names. | 518 # Give args better names. |
522 local chroot_dir="${1}" | 519 local chroot_dir="${1}" |
523 | 520 |
524 # Add root as a sudoer if not already done. | 521 # Add root as a sudoer if not already done. |
525 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then | 522 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then |
526 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers" | 523 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers" |
527 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\"" | 524 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\"" |
528 fi | 525 fi |
529 } | 526 } |
OLD | NEW |