~chrisccoulson/oxide/lp1504853

« back to all changes in this revision

Viewing changes to client.py

  • Committer: Chris Coulson
  • Date: 2014-04-30 09:47:58 UTC
  • mto: This revision was merged to the branch mainline in revision 541.
  • Revision ID: chris.coulson@canonical.com-20140430094758-pga5rt2p9u2xkpig
Move depot_tools and chromium in to third_party

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
os.environ["PYTHONDONTWRITEBYTECODE"] = "1"
30
30
 
31
31
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "build", "python"))
32
 
from oxide_utils import CheckCall, CheckOutput, CHROMIUMDIR, CHROMIUMSRCDIR, TOPSRCDIR
 
32
from oxide_utils import CheckCall, CheckOutput, CHROMIUMSRCDIR, TOPSRCDIR
33
33
from patch_utils import SyncablePatchSet, SyncError
34
34
 
35
 
DEPOT_TOOLS = "https://chromium.googlesource.com/chromium/tools/depot_tools.git"
36
 
DEPOT_TOOLS_REV = "d9839e8e7a078df40b33b76bf25c4a2f3199d3be"
 
35
DEPOT_TOOLS_GIT_URL = "https://chromium.googlesource.com/chromium/tools/depot_tools.git"
 
36
DEPOT_TOOLS_GIT_REV = "d9839e8e7a078df40b33b76bf25c4a2f3199d3be"
 
37
DEPOT_TOOLS_PATH = os.path.join(TOPSRCDIR, "third_party", "depot_tools")
 
38
DEPOT_TOOLS_OLD_PATH = os.path.join(TOPSRCDIR, "chromium", "depot_tools")
37
39
 
38
40
GCLIENTFILE = os.path.join(TOPSRCDIR, "gclient.conf")
39
 
GCLIENTFILECOPY = os.path.join(CHROMIUMDIR, ".gclient")
40
 
DEPOTTOOLSPATH = os.path.join(CHROMIUMDIR, "depot_tools")
 
41
GCLIENTFILECOPY = os.path.join(os.path.dirname(CHROMIUMSRCDIR), ".gclient")
 
42
 
 
43
def is_git_repo(repo):
 
44
  try:
 
45
    CheckCall(["git", "status"], repo)
 
46
    return True
 
47
  except:
 
48
    return False
41
49
 
42
50
def get_svn_info(repo):
43
51
  for line in CheckOutput(["svn", "info", repo]).split("\n"):
61
69
    return SplitUrlRevision(gclient_dict["solutions"][0]["url"])
62
70
 
63
71
def prepare_depot_tools():
64
 
  if not os.path.isdir(DEPOTTOOLSPATH):
65
 
    CheckCall(["git", "clone", DEPOT_TOOLS, DEPOTTOOLSPATH])
 
72
  if is_git_repo(DEPOT_TOOLS_OLD_PATH) and not is_git_repo(DEPOT_TOOLS_PATH):
 
73
    os.rename(DEPOT_TOOLS_OLD_PATH, DEPOT_TOOLS_PATH)
 
74
 
 
75
  if not os.path.isdir(DEPOT_TOOLS_PATH):
 
76
    CheckCall(["git", "clone", DEPOT_TOOLS_GIT_URL, DEPOT_TOOLS_PATH])
66
77
 
67
 
  CheckCall(["git", "pull", "origin", "master"], DEPOTTOOLSPATH)
68
 
  CheckCall(["git", "checkout", DEPOT_TOOLS_REV], DEPOTTOOLSPATH)
 
78
  CheckCall(["git", "pull", "origin", "master"], DEPOT_TOOLS_PATH)
 
79
  CheckCall(["git", "checkout", DEPOT_TOOLS_GIT_REV], DEPOT_TOOLS_PATH)
69
80
 
70
 
  sys.path.insert(0, DEPOTTOOLSPATH)
71
 
  os.environ["PATH"] = DEPOTTOOLSPATH + ":" + os.getenv("PATH")
 
81
  sys.path.insert(0, DEPOT_TOOLS_PATH)
 
82
  os.environ["PATH"] = DEPOT_TOOLS_PATH + ":" + os.getenv("PATH")
72
83
 
73
84
def ensure_patch_consistency():
74
85
  patchset = SyncablePatchSet()
131
142
    os.remove(os.path.join(CHROMIUMSRCDIR, ".hgignore"))
132
143
 
133
144
  # Don't use the gclient shell wrapper, as it updates depot_tools
134
 
  CheckCall([sys.executable, os.path.join(DEPOTTOOLSPATH, "gclient.py"),
135
 
             "sync", "-D"], CHROMIUMDIR)
 
145
  CheckCall([sys.executable, os.path.join(DEPOT_TOOLS_PATH, "gclient.py"),
 
146
             "sync", "-D"], os.path.dirname(CHROMIUMSRCDIR))
136
147
 
137
148
  with open(os.path.join(CHROMIUMSRCDIR, ".hgignore"), "w") as f:
138
149
    f.write("~$\n")
174
185
 
175
186
  (need_sync, full_sync) = check_chromium_status()
176
187
 
 
188
  chromium_dir = os.path.dirname(CHROMIUMSRCDIR)
 
189
  if not os.path.isdir(chromium_dir):
 
190
    os.makedirs(chromium_dir)
 
191
 
177
192
  shutil.copyfile(GCLIENTFILE, GCLIENTFILECOPY)
178
193
  shutil.copystat(GCLIENTFILE, GCLIENTFILECOPY)
179
194
 
 
195
  old_chromium_dir = os.path.join(TOPSRCDIR, "chromium")
 
196
  if os.path.isdir(old_chromium_dir):
 
197
    shutil.rmtree(old_chromium_dir)
 
198
 
180
199
  if full_sync and os.path.isdir(CHROMIUMSRCDIR):
181
200
    shutil.rmtree(CHROMIUMSRCDIR)
182
201
  if need_sync: