OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """CBuildbot is wrapper around the build process used by the pre-flight queue""" | 7 """CBuildbot is wrapper around the build process used by the pre-flight queue""" |
8 | 8 |
9 import errno | 9 import errno |
10 import heapq | 10 import heapq |
(...skipping 27 matching lines...) Expand all Loading... |
38 """ | 38 """ |
39 try: | 39 try: |
40 os.makedirs(path) | 40 os.makedirs(path) |
41 except OSError, e: | 41 except OSError, e: |
42 if e.errno == errno.EEXIST and parents: | 42 if e.errno == errno.EEXIST and parents: |
43 pass | 43 pass |
44 else: | 44 else: |
45 raise | 45 raise |
46 | 46 |
47 | 47 |
48 def RepoSync(buildroot, rw_checkout=False, retries=_DEFAULT_RETRIES): | 48 def RepoSync(buildroot, retries=_DEFAULT_RETRIES): |
49 """Uses repo to checkout the source code. | 49 """Uses repo to checkout the source code. |
50 | 50 |
51 Keyword arguments: | 51 Keyword arguments: |
52 rw_checkout -- Reconfigure repo after sync'ing to read-write. | |
53 retries -- Number of retries to try before failing on the sync. | 52 retries -- Number of retries to try before failing on the sync. |
54 | |
55 """ | 53 """ |
56 while retries > 0: | 54 while retries > 0: |
57 try: | 55 try: |
58 # The --trace option ensures that repo shows the output from git. This | 56 # The --trace option ensures that repo shows the output from git. This |
59 # is needed so that the buildbot can kill us if git is not making | 57 # is needed so that the buildbot can kill us if git is not making |
60 # progress. | 58 # progress. |
| 59 RunCommand(['repo', 'forall', '-c', 'git', 'config', |
| 60 'url.ssh://git@gitrw.chromium.org:9222.insteadof', |
| 61 'http://git.chromium.org/git'], cwd=buildroot) |
61 RunCommand(['repo', '--trace', 'sync'], cwd=buildroot) | 62 RunCommand(['repo', '--trace', 'sync'], cwd=buildroot) |
62 if rw_checkout: | |
63 # Always re-run in case of new git repos or repo sync | |
64 # failed in a previous run because of a forced Stop Build. | |
65 RunCommand(['repo', 'forall', '-c', 'git', 'config', | |
66 'url.ssh://git@gitrw.chromium.org:9222.pushinsteadof', | |
67 'http://git.chromium.org/git'], cwd=buildroot) | |
68 | |
69 retries = 0 | 63 retries = 0 |
70 except: | 64 except: |
71 retries -= 1 | 65 retries -= 1 |
72 if retries > 0: | 66 if retries > 0: |
73 Warning('CBUILDBOT -- Repo Sync Failed, retrying') | 67 Warning('CBUILDBOT -- Repo Sync Failed, retrying') |
74 else: | 68 else: |
75 Warning('CBUILDBOT -- Retries exhausted') | 69 Warning('CBUILDBOT -- Retries exhausted') |
76 raise | 70 raise |
77 | 71 |
78 # Output manifest | 72 # Output manifest |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 # =========================== Main Commands =================================== | 274 # =========================== Main Commands =================================== |
281 | 275 |
282 | 276 |
283 def _PreFlightRinse(buildroot, board, tracking_branch, overlays): | 277 def _PreFlightRinse(buildroot, board, tracking_branch, overlays): |
284 """Cleans up any leftover state from previous runs.""" | 278 """Cleans up any leftover state from previous runs.""" |
285 _GitCleanup(buildroot, board, tracking_branch, overlays) | 279 _GitCleanup(buildroot, board, tracking_branch, overlays) |
286 _CleanUpMountPoints(buildroot) | 280 _CleanUpMountPoints(buildroot) |
287 RunCommand(['sudo', 'killall', 'kvm'], error_ok=True) | 281 RunCommand(['sudo', 'killall', 'kvm'], error_ok=True) |
288 | 282 |
289 | 283 |
290 def _FullCheckout(buildroot, tracking_branch, rw_checkout=True, | 284 def _FullCheckout(buildroot, tracking_branch, |
291 retries=_DEFAULT_RETRIES, | 285 retries=_DEFAULT_RETRIES, |
292 url='http://git.chromium.org/git/manifest'): | 286 url='http://git.chromium.org/git/manifest'): |
293 """Performs a full checkout and clobbers any previous checkouts.""" | 287 """Performs a full checkout and clobbers any previous checkouts.""" |
294 RunCommand(['sudo', 'rm', '-rf', buildroot]) | 288 RunCommand(['sudo', 'rm', '-rf', buildroot]) |
295 MakeDir(buildroot, parents=True) | 289 MakeDir(buildroot, parents=True) |
296 branch = tracking_branch.split('/'); | 290 branch = tracking_branch.split('/'); |
297 RunCommand(['repo', 'init', '-u', | 291 RunCommand(['repo', 'init', '-u', |
298 url, '-b', | 292 url, '-b', |
299 '%s' % branch[-1]], cwd=buildroot, input='\n\ny\n') | 293 '%s' % branch[-1]], cwd=buildroot, input='\n\ny\n') |
300 RepoSync(buildroot, rw_checkout, retries) | 294 RepoSync(buildroot, retries) |
301 | 295 |
302 | 296 |
303 def _IncrementalCheckout(buildroot, rw_checkout=True, | 297 def _IncrementalCheckout(buildroot, retries=_DEFAULT_RETRIES): |
304 retries=_DEFAULT_RETRIES): | |
305 """Performs a checkout without clobbering previous checkout.""" | 298 """Performs a checkout without clobbering previous checkout.""" |
306 RepoSync(buildroot, rw_checkout, retries) | 299 RepoSync(buildroot, retries) |
307 | 300 |
308 | 301 |
309 def _MakeChroot(buildroot): | 302 def _MakeChroot(buildroot): |
310 """Wrapper around make_chroot.""" | 303 """Wrapper around make_chroot.""" |
311 cwd = os.path.join(buildroot, 'src', 'scripts') | 304 cwd = os.path.join(buildroot, 'src', 'scripts') |
312 RunCommand(['./make_chroot', '--fast'], cwd=cwd) | 305 RunCommand(['./make_chroot', '--fast'], cwd=cwd) |
313 | 306 |
314 | 307 |
315 def _SetupBoard(buildroot, board='x86-generic'): | 308 def _SetupBoard(buildroot, board='x86-generic'): |
316 """Wrapper around setup_board.""" | 309 """Wrapper around setup_board.""" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 except: | 637 except: |
645 # Send failure to master bot. | 638 # Send failure to master bot. |
646 if not buildconfig['master'] and buildconfig['important']: | 639 if not buildconfig['master'] and buildconfig['important']: |
647 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) | 640 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) |
648 | 641 |
649 raise | 642 raise |
650 | 643 |
651 | 644 |
652 if __name__ == '__main__': | 645 if __name__ == '__main__': |
653 main() | 646 main() |
OLD | NEW |