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

Unified Diff: lib/cros_build_lib.py

Issue 6765001: Add better support for getting the path to crosutils. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: 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 | « no previous file | lib/cros_build_lib_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/cros_build_lib.py
diff --git a/lib/cros_build_lib.py b/lib/cros_build_lib.py
index d8467576772d4048fa86c7bf171cfccfbe7eb59b..c1428f738afdf7673787d8dc715ef30199738c36 100644
--- a/lib/cros_build_lib.py
+++ b/lib/cros_build_lib.py
@@ -11,8 +11,6 @@ import subprocess
import sys
_STDOUT_IS_TTY = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
-CROSUTILS_DIRECTORY = os.path.dirname(os.path.dirname(
- os.path.realpath(__file__)))
# TODO(sosa): Move logging to logging module.
@@ -326,3 +324,29 @@ def UnmountImage(root_dir, stateful_dir):
'--stateful_mountpt=%s' % stateful_dir,
], print_cmd=False, redirect_stdout=True, redirect_stderr=True,
cwd=CROSUTILS_DIRECTORY)
+
+
+def GetCrosUtilsPath(from_source=True):
petkov 2011/03/28 20:48:56 s/from_source/to_src/
sosa 2011/03/28 20:57:34 renamed to source_path_dir On 2011/03/28 20:48:56
+ """Return the path to src/scripts.
+
+ Args:
+ from_src: If True, returns the path to the src location.
+ """
+ if IsInsideChroot():
+ if from_source:
+ return os.path.join(os.getenv('HOME'), 'trunk', 'src', 'scripts')
+ else:
petkov 2011/03/28 20:48:56 remove?
sosa 2011/03/28 20:57:34 Done.
+ return os.path.join('/usr/lib/crosutils')
+
+ # Outside the chroot => from_source.
+ return os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')
+
+
+# TODO(sosa): Copied from chromite.
petkov 2011/03/28 20:48:56 what's left to do?
sosa 2011/03/28 20:57:34 Done.
+def IsInsideChroot():
+ """Returns True if we are inside chroot."""
+ return os.path.exists('/etc/debian_chroot')
+
+
+# TODO(sosa): Remove once all callers use method.
+CROSUTILS_DIRECTORY = GetCrosUtilsPath(True)
petkov 2011/03/28 20:48:56 you can still keep the constant at the beginning o
sosa 2011/03/28 20:57:34 I thought so too, but python complains. It's prob
« no previous file with comments | « no previous file | lib/cros_build_lib_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698