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

Unified Diff: lib/cros_build_lib.py

Issue 3612004: Add board option to au test harness so that this works for others without a default board. (Closed) Base URL: http://git.chromium.org/git/crosutils.git
Patch Set: Clean up board Created 10 years, 2 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 | « get_latest_image.sh ('k') | no next file » | 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 71c908648f764575433251a16b45ff181df03f2e..47c8f96ae659b6b31394da97f78107f0e10ffa9d 100644
--- a/lib/cros_build_lib.py
+++ b/lib/cros_build_lib.py
@@ -136,3 +136,36 @@ def Info(message):
"""
print >> sys.stderr, (
Color(_STDOUT_IS_TTY).Color(Color.BLUE, '\nINFO: ' + message))
+
+
+def FindRepoDir():
+ """Returns the nearest higher-level repo dir from the cwd."""
+ cwd = os.getcwd()
+ while cwd != '/':
+ repo_dir = os.path.join(cwd, '.repo')
+ if os.path.isdir(repo_dir):
+ return repo_dir
+ cwd = os.path.dirname(cwd)
+ return None
+
+
+def ReinterpretPathForChroot(path):
+ """Returns reinterpreted path from outside the chroot for use inside.
+
+ Keyword arguments:
+ path: The path to reinterpret. Must be in src tree.
+ """
+ root_path = os.path.join(FindRepoDir(), '..')
+
+ path_abs_path = os.path.abspath(path)
+ root_abs_path = os.path.abspath(root_path)
+
+ # Strip the repository root from the path and strip first /.
+ relative_path = path_abs_path.replace(root_abs_path, '')[1:]
+
+ if relative_path == path_abs_path:
+ raise Exception('Error: path is outside your src tree, cannot reinterpret.')
+
+ new_path = os.path.join('/home', os.getenv('USER'), 'trunk', relative_path)
+ return new_path
+
« no previous file with comments | « get_latest_image.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698