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

Side by Side Diff: common.sh

Issue 6730012: Remove testing utilities and fix symlinks. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Fix common Created 9 years, 9 months 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_run_vm_update ('k') | cros_run_unit_tests » ('j') | 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 dpkg-buildpackage -b -tc -us -uc -j$NUM_JOBS 298 dpkg-buildpackage -b -tc -us -uc -j$NUM_JOBS
299 mv ../${PKG_BASE}_*.deb "$out_dir" 299 mv ../${PKG_BASE}_*.deb "$out_dir"
300 rm ../${PKG_BASE}_*.changes 300 rm ../${PKG_BASE}_*.changes
301 popd 301 popd
302 } 302 }
303 303
304 # Enter a chroot and restart the current script if needed 304 # Enter a chroot and restart the current script if needed
305 function restart_in_chroot_if_needed { 305 function restart_in_chroot_if_needed {
306 # NB: Pass in ARGV: restart_in_chroot_if_needed "$@" 306 # NB: Pass in ARGV: restart_in_chroot_if_needed "$@"
307 if [ $INSIDE_CHROOT -ne 1 ]; then 307 if [ $INSIDE_CHROOT -ne 1 ]; then
308 local abspath=$(readlink -f "$0") 308 # Get inside_chroot path for script.
309 # strip everything up to (and including) /scripts/ from abspath 309 local chroot_path="$(reinterpret_path_for_chroot "$0")"
310 local path_from_scripts="${abspath##*/scripts/}"
311 exec $SCRIPTS_DIR/enter_chroot.sh -- \ 310 exec $SCRIPTS_DIR/enter_chroot.sh -- \
312 "$CHROOT_TRUNK_DIR/src/scripts/$path_from_scripts" "$@" 311 "$chroot_path" "$@"
petkov 2011/03/24 03:35:17 move this up?
313 fi 312 fi
314 } 313 }
315 314
316 # Fail unless we're inside the chroot. This guards against messing up your 315 # Fail unless we're inside the chroot. This guards against messing up your
317 # workstation. 316 # workstation.
318 function assert_inside_chroot { 317 function assert_inside_chroot {
319 if [ $INSIDE_CHROOT -ne 1 ]; then 318 if [ $INSIDE_CHROOT -ne 1 ]; then
320 echo "This script must be run inside the chroot. Run this first:" 319 echo "This script must be run inside the chroot. Run this first:"
321 echo " $SCRIPTS_DIR/enter_chroot.sh" 320 echo " $SCRIPTS_DIR/enter_chroot.sh"
322 exit 1 321 exit 1
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 check_for_tool() { 688 check_for_tool() {
690 local tool=$1 689 local tool=$1
691 local ebuild=$2 690 local ebuild=$2
692 691
693 if ! which "${tool}" >/dev/null ; then 692 if ! which "${tool}" >/dev/null ; then
694 error "The ${tool} utility was not found in your path. Run the following" 693 error "The ${tool} utility was not found in your path. Run the following"
695 error "command in your chroot to install it: sudo -E emerge ${ebuild}" 694 error "command in your chroot to install it: sudo -E emerge ${ebuild}"
696 exit 1 695 exit 1
697 fi 696 fi
698 } 697 }
698
699 # Reinterprets path from outside the chroot for use inside.
700 # Returns "" if "" given.
701 # $1 - The path to reinterpret.
702 function reinterpret_path_for_chroot() {
703 if [ $INSIDE_CHROOT -ne 1 ]; then
704 if [ -z "${1}" ]; then
705 echo ""
706 else
707 local path_abs_path=$(readlink -f "${1}")
708 local gclient_root_abs_path=$(readlink -f "${GCLIENT_ROOT}")
709
710 # Strip the repository root from the path.
711 local relative_path=$(echo ${path_abs_path} \
712 | sed s:${gclient_root_abs_path}/::)
petkov 2011/03/24 03:35:17 move | up
713
714 if [ "${relative_path}" = "${path_abs_path}" ]; then
715 die "Error reinterpreting path. Path ${1} is not within source tree."
716 fi
717
718 # Prepend the chroot repository path.
719 echo "/home/${USER}/trunk/${relative_path}"
720 fi
721 else
722 # Path is already inside the chroot :).
723 echo "${1}"
724 fi
725 }
OLDNEW
« no previous file with comments | « bin/cros_run_vm_update ('k') | cros_run_unit_tests » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698