Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: common.sh

Issue 5444002: restart_in_chroot_if_needed can run scripts from bin/. cros_workon_now does this (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: rebased Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bin/cros_workon_make ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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. 116 # Enable --fast by default.
117 DEFAULT_FAST="${FLAGS_TRUE}" 117 DEFAULT_FAST="${FLAGS_TRUE}"
118 118
119 # Detect whether we're inside a chroot or not 119 # Detect whether we're inside a chroot or not
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 pushd "$TOP_SCRIPT_DIR" 224 pushd "$TOP_SCRIPT_DIR"
225 rm -f ../${PKG_BASE}_*.deb 225 rm -f ../${PKG_BASE}_*.deb
226 dpkg-buildpackage -b -tc -us -uc -j$NUM_JOBS 226 dpkg-buildpackage -b -tc -us -uc -j$NUM_JOBS
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 if [ $INSIDE_CHROOT -ne 1 ] 235 if [ $INSIDE_CHROOT -ne 1 ]
235 then 236 then
236 # Equivalent to enter_chroot.sh -- <current command> 237 local abspath=$(readlink -f "$0")
238 # strip everything up to (and including) /src/scripts/ from abspath
239 local path_from_scripts="${abspath##*/src/scripts/}"
237 exec $SCRIPTS_DIR/enter_chroot.sh -- \ 240 exec $SCRIPTS_DIR/enter_chroot.sh -- \
238 $CHROOT_TRUNK_DIR/src/scripts/$(basename $0) $* 241 "$CHROOT_TRUNK_DIR/src/scripts/$path_from_scripts" "$@"
242 exit
239 fi 243 fi
240 } 244 }
241 245
242 # Fail unless we're inside the chroot. This guards against messing up your 246 # Fail unless we're inside the chroot. This guards against messing up your
243 # workstation. 247 # workstation.
244 function assert_inside_chroot { 248 function assert_inside_chroot {
245 if [ $INSIDE_CHROOT -ne 1 ] 249 if [ $INSIDE_CHROOT -ne 1 ]
246 then 250 then
247 echo "This script must be run inside the chroot. Run this first:" 251 echo "This script must be run inside the chroot. Run this first:"
248 echo " $SCRIPTS_DIR/enter_chroot.sh" 252 echo " $SCRIPTS_DIR/enter_chroot.sh"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 chroot_hacks_from_outside() { 520 chroot_hacks_from_outside() {
517 # Give args better names. 521 # Give args better names.
518 local chroot_dir="${1}" 522 local chroot_dir="${1}"
519 523
520 # Add root as a sudoer if not already done. 524 # Add root as a sudoer if not already done.
521 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then 525 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then
522 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers" 526 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers"
523 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\"" 527 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\""
524 fi 528 fi
525 } 529 }
OLDNEW
« no previous file with comments | « bin/cros_workon_make ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698