OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 | |
7 """Sync the Android sources.""" | |
8 | |
9 | |
10 import os | |
11 import shlex | |
12 import sys | |
13 | |
14 from build_step import BuildStep | |
15 from py.utils import misc | |
16 from py.utils import shell_utils | |
17 from utils.gclient_utils import GIT | |
18 | |
19 | |
20 ANDROID_CHECKOUT_PATH = os.path.join(os.pardir, 'android_repo') | |
21 ANDROID_REPO_URL = ('https://googleplex-android.googlesource.com/a/platform/' | |
22 'manifest') | |
23 GIT_COOKIE_AUTHDAEMON = os.path.join(os.path.expanduser('~'), 'skia-repo', | |
24 'gcompute-tools', 'git-cookie-authdaemon') | |
25 REPO_URL = 'http://commondatastorage.googleapis.com/git-repo-downloads/repo' | |
26 REPO = os.path.join(os.path.expanduser('~'), 'bin', 'repo') | |
27 | |
28 class GitAuthenticate(object): | |
29 def __init__(self): | |
30 self._auth_daemon_pid = None | |
31 | |
32 def __enter__(self): | |
33 shell_utils.run([GIT, 'config', 'user.email', | |
34 '"31977622648@project.gserviceaccount.com"']) | |
35 shell_utils.run([GIT, 'config', 'user.name', | |
36 '"Skia_Android Canary Bot"']) | |
37 # Authenticate. This is only required on the actual build slave - not on | |
38 # a test slave on someone's machine, where the file does not exist. | |
39 if os.path.exists(GIT_COOKIE_AUTHDAEMON): | |
40 output = shell_utils.run([GIT_COOKIE_AUTHDAEMON]) | |
41 self._auth_daemon_pid = shlex.split(output)[-1] | |
42 else: | |
43 print 'No authentication file. Did you authenticate?' | |
44 | |
45 def __exit__(self, *args): | |
46 if self._auth_daemon_pid: | |
47 shell_utils.run(['kill', self._auth_daemon_pid]) | |
48 | |
49 | |
50 class SyncAndroid(BuildStep): | |
51 """BuildStep which syncs the Android sources.""" | |
52 | |
53 def _Run(self): | |
54 try: | |
55 os.makedirs(ANDROID_CHECKOUT_PATH) | |
56 except OSError: | |
57 pass | |
58 with misc.ChDir(ANDROID_CHECKOUT_PATH): | |
59 if not os.path.exists(REPO): | |
60 # Download repo. | |
61 shell_utils.run(['curl', REPO_URL, '>', REPO]) | |
62 shell_utils.run(['chmod', 'a+x', REPO]) | |
63 | |
64 with GitAuthenticate(): | |
65 shell_utils.run([REPO, 'init', '-u', ANDROID_REPO_URL, '-g', | |
66 'all,-notdefault,-darwin', '-b', 'master-skia']) | |
67 shell_utils.run([REPO, 'sync', '-j32']) | |
68 | |
69 | |
70 if '__main__' == __name__: | |
71 sys.exit(BuildStep.RunBuildStep(SyncAndroid)) | |
OLD | NEW |