Tidy up chroot location when running from ebuild
The ebuild environment is slightly different - we use CROS_WORKON_SRCROOT
to find the chromiumos overlay.
BUG=chromium-os:17187
TEST=emerge-tegra2_seaboard chromeos-bootimage; flash and boot both normal
and legacy images
Change-Id: I5f3e7a20e5d85dd5e070317f353a5d6fd96a02f1
Reviewed-on: http://gerrit.chromium.org/gerrit/4154
Tested-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
diff --git a/host/lib/tools.py b/host/lib/tools.py
index 90b1acd..a3cbfb9 100755
--- a/host/lib/tools.py
+++ b/host/lib/tools.py
@@ -54,10 +54,15 @@
# Detect whether we're inside a chroot or not
self.in_chroot = cros_build_lib.IsInsideChroot()
self.verbose = verbose
- repo = cros_build_lib.FindRepoDir()
- if not repo:
- raise IOError('Cannot find .repo directory (must be below cwd level)')
- self._SetRoot(os.path.dirname(repo))
+ self._root = None
+ if self.in_chroot:
+ root_dir = os.getenv('CROS_WORKON_SRCROOT')
+ else:
+ repo = cros_build_lib.FindRepoDir()
+ if not repo:
+ raise IOError('Cannot find .repo directory (must be below cwd level)')
+ root_dir = os.path.dirname(repo)
+ self._SetRoot(root_dir)
if verbose >= 3:
print "Chroot is at '%s'" % self.chroot_path