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 re |
10 import optparse | 11 import optparse |
11 import os | 12 import os |
12 import re | |
13 import shutil | |
14 import subprocess | 13 import subprocess |
15 import sys | 14 import sys |
16 | 15 |
| 16 import cbuildbot_comm |
17 from cbuildbot_config import config | 17 from cbuildbot_config import config |
18 | 18 |
19 _DEFAULT_RETRIES = 3 | 19 _DEFAULT_RETRIES = 3 |
20 | 20 |
21 # ======================== Utility functions ================================ | 21 # ======================== Utility functions ================================ |
22 | 22 |
23 def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None, | 23 def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None, |
24 exit_code=False, redirect_stdout=False, redirect_stderr=False, | 24 exit_code=False, redirect_stdout=False, redirect_stderr=False, |
25 cwd=None, input=None, enter_chroot=False): | 25 cwd=None, input=None, enter_chroot=False): |
26 """Runs a shell command. | 26 """Runs a shell command. |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 chroot_path = os.path.join(buildroot, 'chroot') | 364 chroot_path = os.path.join(buildroot, 'chroot') |
365 if not os.path.isdir(chroot_path): | 365 if not os.path.isdir(chroot_path): |
366 _MakeChroot(buildroot) | 366 _MakeChroot(buildroot) |
367 boardpath = os.path.join(chroot_path, 'build', buildconfig['board']) | 367 boardpath = os.path.join(chroot_path, 'build', buildconfig['board']) |
368 if not os.path.isdir(boardpath): | 368 if not os.path.isdir(boardpath): |
369 _SetupBoard(buildroot, board=buildconfig['board']) | 369 _SetupBoard(buildroot, board=buildconfig['board']) |
370 if buildconfig['uprev']: | 370 if buildconfig['uprev']: |
371 _UprevPackages(buildroot, revisionfile, board=buildconfig['board']) | 371 _UprevPackages(buildroot, revisionfile, board=buildconfig['board']) |
372 _Build(buildroot) | 372 _Build(buildroot) |
373 if buildconfig['uprev']: | 373 if buildconfig['uprev']: |
374 _UprevPush(buildroot) | 374 if buildconfig['master']: |
375 _UprevCleanup(buildroot) | 375 # Master bot needs to check if the other slaves completed. |
| 376 if cbuildbot_comm.HaveSlavesCompleted(config): |
| 377 _UprevPush(buildroot) |
| 378 _UprevCleanup(buildroot) |
| 379 else: |
| 380 # At least one of the slaves failed or we timed out. |
| 381 _UprevCleanup(buildroot) |
| 382 sys.stderr('CBUILDBOT - One of the slaves has failed!!!') |
| 383 sys.exit(1) |
| 384 else: |
| 385 # Publish my status to the master. |
| 386 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) |
| 387 _UprevCleanup(buildroot) |
376 except: | 388 except: |
377 # something went wrong, cleanup (being paranoid) for next build | 389 # Something went wrong, cleanup (being paranoid) for next build. |
378 if clobber: | 390 if clobber: |
379 RunCommand(['sudo', 'rm', '-rf', buildroot], print_cmd=False) | 391 RunCommand(['sudo', 'rm', '-rf', buildroot], print_cmd=False) |
| 392 # Send failure to master bot. |
| 393 if not buildconfig['master']: |
| 394 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) |
380 raise | 395 raise |
381 | 396 |
382 | 397 |
383 if __name__ == '__main__': | 398 if __name__ == '__main__': |
384 main() | 399 main() |
OLD | NEW |