| 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 """Wrapper around make_chroot.""" | 303 """Wrapper around make_chroot.""" |
| 304 cwd = os.path.join(buildroot, 'src', 'scripts') | 304 cwd = os.path.join(buildroot, 'src', 'scripts') |
| 305 RunCommand(['./make_chroot', '--fast'], cwd=cwd) | 305 RunCommand(['./make_chroot', '--fast'], cwd=cwd) |
| 306 | 306 |
| 307 | 307 |
| 308 def _GetPortageEnvVar(buildroot, board, envvar): | 308 def _GetPortageEnvVar(buildroot, board, envvar): |
| 309 """Get a portage environment variable for the specified board, if any. | 309 """Get a portage environment variable for the specified board, if any. |
| 310 | 310 |
| 311 buildroot: The root directory where the build occurs. Must be an absolute | 311 buildroot: The root directory where the build occurs. Must be an absolute |
| 312 path. | 312 path. |
| 313 board: Board type that was built on this machine. E.g. x86-generic. | 313 board: Board type that was built on this machine. E.g. x86-generic. If this |
| 314 envvar: The environment variable to get. E.g. "PORTAGE_BINHOST". | 314 is None, get the env var from the host. |
| 315 envvar: The environment variable to get. E.g. 'PORTAGE_BINHOST'. |
| 315 | 316 |
| 316 Returns: | 317 Returns: |
| 317 The value of the environment variable, as a string. If no such variable | 318 The value of the environment variable, as a string. If no such variable |
| 318 can be found, return the empty string. | 319 can be found, return the empty string. |
| 319 """ | 320 """ |
| 320 cwd = os.path.join(buildroot, 'src', 'scripts') | 321 cwd = os.path.join(buildroot, 'src', 'scripts') |
| 321 binhost = RunCommand(['portageq-%s' % board, 'envvar', envvar], | 322 portageq = 'portageq' |
| 322 cwd=cwd, redirect_stdout=True, enter_chroot=True, | 323 if board: |
| 323 error_ok=True) | 324 portageq += '-%s' % board |
| 325 binhost = RunCommand([portageq, 'envvar', envvar], cwd=cwd, |
| 326 redirect_stdout=True, enter_chroot=True, error_ok=True) |
| 324 return binhost.rstrip('\n') | 327 return binhost.rstrip('\n') |
| 325 | 328 |
| 326 | 329 |
| 327 def _SetupBoard(buildroot, board='x86-generic'): | 330 def _SetupBoard(buildroot, board='x86-generic'): |
| 328 """Wrapper around setup_board.""" | 331 """Wrapper around setup_board.""" |
| 329 cwd = os.path.join(buildroot, 'src', 'scripts') | 332 cwd = os.path.join(buildroot, 'src', 'scripts') |
| 330 RunCommand(['./setup_board', '--fast', '--default', '--board=%s' % board], | 333 RunCommand(['./setup_board', '--fast', '--default', '--board=%s' % board], |
| 331 cwd=cwd, enter_chroot=True) | 334 cwd=cwd, enter_chroot=True) |
| 332 | 335 |
| 333 | 336 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 paths = [private_overlay] | 518 paths = [private_overlay] |
| 516 elif overlays == 'public': | 519 elif overlays == 'public': |
| 517 paths = [public_overlay] | 520 paths = [public_overlay] |
| 518 elif overlays == 'both': | 521 elif overlays == 'both': |
| 519 paths = [public_overlay, private_overlay] | 522 paths = [public_overlay, private_overlay] |
| 520 else: | 523 else: |
| 521 Die('Incorrect overlay configuration: %s' % overlays) | 524 Die('Incorrect overlay configuration: %s' % overlays) |
| 522 return paths | 525 return paths |
| 523 | 526 |
| 524 | 527 |
| 525 def _UploadPrebuilts(buildroot, board, overlay_config): | 528 def _UploadPrebuilts(buildroot, board, overlay_config, binhosts): |
| 526 """Upload prebuilts. | 529 """Upload prebuilts. |
| 527 | 530 |
| 528 Args: | 531 Args: |
| 529 buildroot: The root directory where the build occurs. | 532 buildroot: The root directory where the build occurs. |
| 530 board: Board type that was built on this machine | 533 board: Board type that was built on this machine |
| 531 overlay_config: A string describing which overlays you want. | 534 overlay_config: A string describing which overlays you want. |
| 532 'private': Just the private overlay. | 535 'private': Just the private overlay. |
| 533 'public': Just the public overlay. | 536 'public': Just the public overlay. |
| 534 'both': Both the public and private overlays. | 537 'both': Both the public and private overlays. |
| 538 binhosts: The URLs of the current binhosts. Binaries that are already |
| 539 present will not be uploaded twice. Empty URLs will be ignored. |
| 535 """ | 540 """ |
| 536 | 541 |
| 537 cmd = ['%s/src/scripts/prebuilt.py' % buildroot, | 542 cmd = ['%s/src/scripts/prebuilt.py' % buildroot, |
| 538 '--sync-binhost-conf', | 543 '--sync-binhost-conf', |
| 544 '--sync-host', |
| 539 '--build-path', buildroot, | 545 '--build-path', buildroot, |
| 540 '--board', board, | 546 '--board', board, |
| 541 '--prepend-version', 'preflight', | 547 '--prepend-version', 'preflight', |
| 542 '--key', _PREFLIGHT_BINHOST] | 548 '--key', _PREFLIGHT_BINHOST] |
| 549 for binhost in binhosts: |
| 550 if binhost: |
| 551 cmd.extend(['--previous-binhost-url', binhost]) |
| 543 if overlay_config == 'public': | 552 if overlay_config == 'public': |
| 544 cmd.extend(['--upload', 'gs://chromeos-prebuilt']) | 553 cmd.extend(['--upload', 'gs://chromeos-prebuilt']) |
| 545 else: | 554 else: |
| 546 assert overlay_config in ('private', 'both') | 555 assert overlay_config in ('private', 'both') |
| 547 cmd.extend(['--upload', 'chromeos-images:/var/www/prebuilt/', | 556 cmd.extend(['--upload', 'chromeos-images:/var/www/prebuilt/', |
| 548 '--binhost-base-url', 'http://chromeos-prebuilt']) | 557 '--binhost-base-url', 'http://chromeos-prebuilt']) |
| 549 | 558 |
| 550 RunCommand(cmd, cwd='%s/src/scripts' % buildroot) | 559 RunCommand(cmd, cwd='%s/src/scripts' % buildroot) |
| 551 | 560 |
| 552 | 561 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 # Calculate list of overlay directories. | 597 # Calculate list of overlay directories. |
| 589 overlays = _ResolveOverlays(buildroot, buildconfig['overlays']) | 598 overlays = _ResolveOverlays(buildroot, buildconfig['overlays']) |
| 590 board = buildconfig['board'] | 599 board = buildconfig['board'] |
| 591 | 600 |
| 592 try: | 601 try: |
| 593 _PreFlightRinse(buildroot, buildconfig['board'], tracking_branch, overlays) | 602 _PreFlightRinse(buildroot, buildconfig['board'], tracking_branch, overlays) |
| 594 chroot_path = os.path.join(buildroot, 'chroot') | 603 chroot_path = os.path.join(buildroot, 'chroot') |
| 595 boardpath = os.path.join(chroot_path, 'build', board) | 604 boardpath = os.path.join(chroot_path, 'build', board) |
| 596 if options.clobber or not os.path.isdir(buildroot): | 605 if options.clobber or not os.path.isdir(buildroot): |
| 597 _FullCheckout(buildroot, tracking_branch, url=options.url) | 606 _FullCheckout(buildroot, tracking_branch, url=options.url) |
| 607 new_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST), |
| 598 else: | 608 else: |
| 599 old_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST) | 609 old_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST) |
| 600 _IncrementalCheckout(buildroot) | 610 _IncrementalCheckout(buildroot) |
| 601 new_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST) | 611 new_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST) |
| 602 if old_binhost != new_binhost: | 612 if old_binhost != new_binhost: |
| 603 RunCommand(['sudo', 'rm', '-rf', boardpath]) | 613 RunCommand(['sudo', 'rm', '-rf', boardpath]) |
| 614 binhosts = [new_binhost, _GetPortageEnvVar(buildroot, None, _FULL_BINHOST)] |
| 604 | 615 |
| 605 # Check that all overlays can be found. | 616 # Check that all overlays can be found. |
| 606 for path in overlays: | 617 for path in overlays: |
| 607 assert ':' not in path, 'Overlay must not contain colons: %s' % path | 618 assert ':' not in path, 'Overlay must not contain colons: %s' % path |
| 608 if not os.path.isdir(path): | 619 if not os.path.isdir(path): |
| 609 Die('Missing overlay: %s' % path) | 620 Die('Missing overlay: %s' % path) |
| 610 | 621 |
| 611 if not os.path.isdir(chroot_path): | 622 if not os.path.isdir(chroot_path): |
| 612 _MakeChroot(buildroot) | 623 _MakeChroot(buildroot) |
| 613 | 624 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 634 _ArchiveTestResults(buildroot, buildconfig['board'], | 645 _ArchiveTestResults(buildroot, buildconfig['board'], |
| 635 archive_dir=options.buildnumber, | 646 archive_dir=options.buildnumber, |
| 636 test_results_dir=test_results_dir) | 647 test_results_dir=test_results_dir) |
| 637 | 648 |
| 638 if buildconfig['uprev']: | 649 if buildconfig['uprev']: |
| 639 # Don't push changes for developers. | 650 # Don't push changes for developers. |
| 640 if not options.debug: | 651 if not options.debug: |
| 641 if buildconfig['master']: | 652 if buildconfig['master']: |
| 642 # Master bot needs to check if the other slaves completed. | 653 # Master bot needs to check if the other slaves completed. |
| 643 if cbuildbot_comm.HaveSlavesCompleted(config): | 654 if cbuildbot_comm.HaveSlavesCompleted(config): |
| 644 _UploadPrebuilts(buildroot, board, buildconfig['overlays']) | 655 _UploadPrebuilts(buildroot, board, buildconfig['overlays'], |
| 656 binhosts) |
| 645 _UprevPush(buildroot, tracking_branch, buildconfig['board'], | 657 _UprevPush(buildroot, tracking_branch, buildconfig['board'], |
| 646 overlays) | 658 overlays) |
| 647 else: | 659 else: |
| 648 Die('CBUILDBOT - One of the slaves has failed!!!') | 660 Die('CBUILDBOT - One of the slaves has failed!!!') |
| 649 | 661 |
| 650 else: | 662 else: |
| 651 # Publish my status to the master if its expecting it. | 663 # Publish my status to the master if its expecting it. |
| 652 if buildconfig['important']: | 664 if buildconfig['important']: |
| 653 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) | 665 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) |
| 654 | 666 |
| 655 except: | 667 except: |
| 656 # Send failure to master bot. | 668 # Send failure to master bot. |
| 657 if not buildconfig['master'] and buildconfig['important']: | 669 if not buildconfig['master'] and buildconfig['important']: |
| 658 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) | 670 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) |
| 659 | 671 |
| 660 raise | 672 raise |
| 661 | 673 |
| 662 | 674 |
| 663 if __name__ == '__main__': | 675 if __name__ == '__main__': |
| 664 main() | 676 main() |
| OLD | NEW |