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

Side by Side Diff: bin/chromite

Issue 6312167: In the chroot, don't do any path mucking. Just run chromite. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/chromite.git@master
Patch Set: Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Wrapper for the chromite shell. 6 """Wrapper for the chromite shell.
7 7
8 This script is intended to run in several ways: 8 This script is intended to run in several ways:
9 - Outside the chroot, it should be _copied_ to someplace that is in the 9 - Outside the chroot, it should be _copied_ to someplace that is in the
10 path (like depot_tools). It will search for the right chromite by looking 10 path (like depot_tools). It will search for the right chromite by looking
(...skipping 12 matching lines...) Expand all
23 23
24 """ 24 """
25 25
26 # Python imports. 26 # Python imports.
27 import os 27 import os
28 import sys 28 import sys
29 29
30 def Search(path): 30 def Search(path):
31 """Return an iterator of lists of places to look for chromite.""" 31 """Return an iterator of lists of places to look for chromite."""
32 32
33 # Look in $CROS_WORKON_SRCROOT first. 33 if os.path.exists('/etc/debian_chroot'):
34 if 'CROS_WORKON_SRCROOT' in os.environ: 34 # We're in the chroot. Chromite should be in the python path inside the
35 yield [os.environ['CROS_WORKON_SRCROOT']] 35 # chroot, so we don't do any searching. NOTE that we purposely don't want
36 # CROS_WORKON_SRCROOT in the python path.
37 yield []
38 else:
39 # Look in $CROS_WORKON_SRCROOT first. The idea is that a user would set
40 # this manually if they wanted to specify a particular version of chromite.
41 if 'CROS_WORKON_SRCROOT' in os.environ:
42 yield [os.environ['CROS_WORKON_SRCROOT']]
36 43
37 # Try the path as is 44 # Search upward until we either end up with a blank dir or the "parent" dir
38 yield [] 45 # doesn't change.
39 46 prev_path = None
40 # Search upward until we either end up with a blank dir or the "parent" dir 47 while path and path != prev_path:
41 # doesn't change. 48 yield [path]
42 prev_path = None 49 path, prev_path = os.path.dirname(path), path
43 while path and path != prev_path:
44 yield [path]
45 path, prev_path = os.path.dirname(path), path
46 50
47 51
48 for path in Search(os.getcwd()): 52 for path in Search(os.getcwd()):
49 sys.path = path + sys.path 53 sys.path = path + sys.path
jrbarnette 2011/02/07 19:51:23 I just now noticed this, though I should have noti
diandersAtChromium 2011/02/07 21:31:02 It looks like the paths are deleted in the "except
50 try: 54 try:
51 import chromite.shell.main 55 import chromite.shell.main
52 break 56 break
53 except ImportError, e: 57 except ImportError, e:
54 # We've got different modules named chromite in the tree, pulling in the 58 # We've got different modules named chromite in the tree, pulling in the
55 # wrong one will break the right one. So unload it. 59 # wrong one will break the right one. So unload it.
56 if 'chromite' in sys.modules: 60 if 'chromite' in sys.modules:
57 del sys.modules['chromite'] 61 del sys.modules['chromite']
58 sys.path = sys.path[len(path):] 62 sys.path = sys.path[len(path):]
diandersAtChromium 2011/02/07 21:31:02 Paths are deleted here.
jrbarnette 2011/02/08 00:46:06 Ah, I missed this.
59 else: 63 else:
60 # TODO(dianders): Should we actually print out the 'repo init' call that 64 # TODO(dianders): Should we actually print out the 'repo init' call that
61 # the user should use? 65 # the user should use?
62 sys.stderr.write( 66 sys.stderr.write(
63 "ERROR: Couldn't find the chromite tool.\n" 67 "ERROR: Couldn't find the chromite tool.\n"
64 "\n" 68 "\n"
65 "Please change to a directory inside your Chromium OS source tree\n" 69 "Please change to a directory inside your Chromium OS source tree\n"
66 "and retry. If you need to setup a Chromium OS source tree, see:\n" 70 "and retry. If you need to setup a Chromium OS source tree, see:\n"
67 " http://www.chromium.org/chromium-os/developer-guide\n") 71 " http://www.chromium.org/chromium-os/developer-guide\n")
68 sys.exit(1) 72 sys.exit(1)
69 73
70 chromite.shell.main.main() 74 chromite.shell.main.main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698