Chromium Code Reviews| 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
|