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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bin/cros_run_vm_update ('k') | cros_run_unit_tests » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common.sh
diff --git a/common.sh b/common.sh
index 18e04cdd9a6ff0ca4718ce1d55fa6256f75b768a..879ebb3829de56938103ca54dacd387d42f6a6cd 100644
--- a/common.sh
+++ b/common.sh
@@ -305,11 +305,10 @@ function make_pkg_common {
function restart_in_chroot_if_needed {
# NB: Pass in ARGV: restart_in_chroot_if_needed "$@"
if [ $INSIDE_CHROOT -ne 1 ]; then
- local abspath=$(readlink -f "$0")
- # strip everything up to (and including) /scripts/ from abspath
- local path_from_scripts="${abspath##*/scripts/}"
+ # Get inside_chroot path for script.
+ local chroot_path="$(reinterpret_path_for_chroot "$0")"
exec $SCRIPTS_DIR/enter_chroot.sh -- \
- "$CHROOT_TRUNK_DIR/src/scripts/$path_from_scripts" "$@"
+ "$chroot_path" "$@"
petkov 2011/03/24 03:35:17 move this up?
fi
}
@@ -696,3 +695,31 @@ check_for_tool() {
exit 1
fi
}
+
+# Reinterprets path from outside the chroot for use inside.
+# Returns "" if "" given.
+# $1 - The path to reinterpret.
+function reinterpret_path_for_chroot() {
+ if [ $INSIDE_CHROOT -ne 1 ]; then
+ if [ -z "${1}" ]; then
+ echo ""
+ else
+ local path_abs_path=$(readlink -f "${1}")
+ local gclient_root_abs_path=$(readlink -f "${GCLIENT_ROOT}")
+
+ # Strip the repository root from the path.
+ local relative_path=$(echo ${path_abs_path} \
+ | sed s:${gclient_root_abs_path}/::)
petkov 2011/03/24 03:35:17 move | up
+
+ if [ "${relative_path}" = "${path_abs_path}" ]; then
+ die "Error reinterpreting path. Path ${1} is not within source tree."
+ fi
+
+ # Prepend the chroot repository path.
+ echo "/home/${USER}/trunk/${relative_path}"
+ fi
+ else
+ # Path is already inside the chroot :).
+ echo "${1}"
+ fi
+}
« 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