Chromium Code Reviews| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 # Default location for chroot | 99 # Default location for chroot |
| 100 DEFAULT_CHROOT_DIR=${CHROMEOS_CHROOT_DIR:-"$GCLIENT_ROOT/chroot"} | 100 DEFAULT_CHROOT_DIR=${CHROMEOS_CHROOT_DIR:-"$GCLIENT_ROOT/chroot"} |
| 101 | 101 |
| 102 # All output files from build should go under $DEFAULT_BUILD_ROOT, so that | 102 # All output files from build should go under $DEFAULT_BUILD_ROOT, so that |
| 103 # they don't pollute the source directory. | 103 # they don't pollute the source directory. |
| 104 DEFAULT_BUILD_ROOT=${CHROMEOS_BUILD_ROOT:-"$SRC_ROOT/build"} | 104 DEFAULT_BUILD_ROOT=${CHROMEOS_BUILD_ROOT:-"$SRC_ROOT/build"} |
| 105 | 105 |
| 106 # Set up a global ALL_BOARDS value | 106 # Set up a global ALL_BOARDS value |
| 107 if [ -d $SRC_ROOT/overlays ]; then | 107 if [ -d $SRC_ROOT/overlays ]; then |
| 108 ALL_BOARDS=$(cd $SRC_ROOT/overlays;ls -1d overlay-* 2>&-|sed 's,overlay-,,g') | 108 ALL_BOARDS=$(cd $SRC_ROOT/overlays;ls -1d overlay-* 2>&-|sed 's,overlay-,,g') |
| 109 fi | 109 fi |
| 110 # Strip CR | 110 # Strip CR |
| 111 ALL_BOARDS=$(echo $ALL_BOARDS) | 111 ALL_BOARDS=$(echo $ALL_BOARDS) |
| 112 # Set a default BOARD | 112 # Set a default BOARD |
| 113 #DEFAULT_BOARD=x86-generic # or... | 113 #DEFAULT_BOARD=x86-generic # or... |
| 114 DEFAULT_BOARD=$(echo $ALL_BOARDS | awk '{print $NF}') | 114 DEFAULT_BOARD=$(echo $ALL_BOARDS | awk '{print $NF}') |
| 115 | 115 |
| 116 # Enable --fast by default on non-official builds | 116 # Enable --fast by default on non-official builds |
| 117 DEFAULT_FAST="${FLAGS_TRUE}" | 117 DEFAULT_FAST="${FLAGS_TRUE}" |
| 118 if [ "${CHROMEOS_OFFICIAL:-0}" = "1" ]; then | 118 if [ "${CHROMEOS_OFFICIAL:-0}" = "1" ]; then |
| 119 DEFAULT_FAST="${FLAGS_FALSE}" | 119 DEFAULT_FAST="${FLAGS_FALSE}" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 pushd "$TOP_SCRIPT_DIR" | 227 pushd "$TOP_SCRIPT_DIR" |
| 228 rm -f ../${PKG_BASE}_*.deb | 228 rm -f ../${PKG_BASE}_*.deb |
| 229 dpkg-buildpackage -b -tc -us -uc -j$NUM_JOBS | 229 dpkg-buildpackage -b -tc -us -uc -j$NUM_JOBS |
| 230 mv ../${PKG_BASE}_*.deb "$OUT_DIR" | 230 mv ../${PKG_BASE}_*.deb "$OUT_DIR" |
| 231 rm ../${PKG_BASE}_*.changes | 231 rm ../${PKG_BASE}_*.changes |
| 232 popd | 232 popd |
| 233 } | 233 } |
| 234 | 234 |
| 235 # Enter a chroot and restart the current script if needed | 235 # Enter a chroot and restart the current script if needed |
| 236 function restart_in_chroot_if_needed { | 236 function restart_in_chroot_if_needed { |
| 237 # NB: Pass in ARGV: restart_in_chroot_if_needed "$@" | |
| 237 if [ $INSIDE_CHROOT -ne 1 ] | 238 if [ $INSIDE_CHROOT -ne 1 ] |
| 238 then | 239 then |
| 239 # Equivalent to enter_chroot.sh -- <current command> | 240 local abspath=$(readlink -f "$0") |
| 241 # $abspath minus everything up to /src/scripts/ | |
|
Chris Masone
2010/12/01 21:18:52
it removes everything up to and including /src/scr
| |
| 242 local path_from_scripts="${abspath##*/src/scripts/}" | |
| 240 exec $SCRIPTS_DIR/enter_chroot.sh -- \ | 243 exec $SCRIPTS_DIR/enter_chroot.sh -- \ |
| 241 $CHROOT_TRUNK_DIR/src/scripts/$(basename $0) $* | 244 "$CHROOT_TRUNK_DIR/src/scripts/$path_from_scripts" "$@" |
| 245 exit | |
| 242 fi | 246 fi |
| 243 } | 247 } |
| 244 | 248 |
| 245 # Fail unless we're inside the chroot. This guards against messing up your | 249 # Fail unless we're inside the chroot. This guards against messing up your |
| 246 # workstation. | 250 # workstation. |
| 247 function assert_inside_chroot { | 251 function assert_inside_chroot { |
| 248 if [ $INSIDE_CHROOT -ne 1 ] | 252 if [ $INSIDE_CHROOT -ne 1 ] |
| 249 then | 253 then |
| 250 echo "This script must be run inside the chroot. Run this first:" | 254 echo "This script must be run inside the chroot. Run this first:" |
| 251 echo " $SCRIPTS_DIR/enter_chroot.sh" | 255 echo " $SCRIPTS_DIR/enter_chroot.sh" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 chroot_hacks_from_outside() { | 523 chroot_hacks_from_outside() { |
| 520 # Give args better names. | 524 # Give args better names. |
| 521 local chroot_dir="${1}" | 525 local chroot_dir="${1}" |
| 522 | 526 |
| 523 # Add root as a sudoer if not already done. | 527 # Add root as a sudoer if not already done. |
| 524 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then | 528 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then |
| 525 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers" | 529 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers" |
| 526 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\"" | 530 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\"" |
| 527 fi | 531 fi |
| 528 } | 532 } |
| OLD | NEW |