Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: bin/cbuildbot.py

Issue 5344002: Update cbuildbot.py and prebuilt.py to deduplicate preflight prebuilts. (Closed) Base URL: None@preflight_upload
Patch Set: Address feedback by dianders. Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | bin/cbuildbot_unittest.py » ('j') | prebuilt.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 """Wrapper around make_chroot.""" 310 """Wrapper around make_chroot."""
311 cwd = os.path.join(buildroot, 'src', 'scripts') 311 cwd = os.path.join(buildroot, 'src', 'scripts')
312 RunCommand(['./make_chroot', '--fast'], cwd=cwd) 312 RunCommand(['./make_chroot', '--fast'], cwd=cwd)
313 313
314 314
315 def _GetPortageEnvVar(buildroot, board, envvar): 315 def _GetPortageEnvVar(buildroot, board, envvar):
316 """Get a portage environment variable for the specified board, if any. 316 """Get a portage environment variable for the specified board, if any.
317 317
318 buildroot: The root directory where the build occurs. Must be an absolute 318 buildroot: The root directory where the build occurs. Must be an absolute
319 path. 319 path.
320 board: Board type that was built on this machine. E.g. x86-generic. 320 board: Board type that was built on this machine. E.g. x86-generic. If this
321 envvar: The environment variable to get. E.g. "PORTAGE_BINHOST". 321 is None, get the env var from the host.
322 envvar: The environment variable to get. E.g. 'PORTAGE_BINHOST'.
322 323
323 Returns: 324 Returns:
324 The value of the environment variable, as a string. If no such variable 325 The value of the environment variable, as a string. If no such variable
325 can be found, return the empty string. 326 can be found, return the empty string.
326 """ 327 """
327 cwd = os.path.join(buildroot, 'src', 'scripts') 328 cwd = os.path.join(buildroot, 'src', 'scripts')
328 binhost = RunCommand(['portageq-%s' % board, 'envvar', envvar], 329 portageq = 'portageq'
329 cwd=cwd, redirect_stdout=True, enter_chroot=True, 330 if board:
330 error_ok=True) 331 portageq += '-%s' % board
332 binhost = RunCommand([portageq, 'envvar', envvar], cwd=cwd,
333 redirect_stdout=True, enter_chroot=True, error_ok=True)
331 return binhost.rstrip('\n') 334 return binhost.rstrip('\n')
332 335
333 336
334 def _SetupBoard(buildroot, board='x86-generic'): 337 def _SetupBoard(buildroot, board='x86-generic'):
335 """Wrapper around setup_board.""" 338 """Wrapper around setup_board."""
336 cwd = os.path.join(buildroot, 'src', 'scripts') 339 cwd = os.path.join(buildroot, 'src', 'scripts')
337 RunCommand(['./setup_board', '--fast', '--default', '--board=%s' % board], 340 RunCommand(['./setup_board', '--fast', '--default', '--board=%s' % board],
338 cwd=cwd, enter_chroot=True) 341 cwd=cwd, enter_chroot=True)
339 342
340 343
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 paths = [private_overlay] 529 paths = [private_overlay]
527 elif overlays == 'public': 530 elif overlays == 'public':
528 paths = [public_overlay] 531 paths = [public_overlay]
529 elif overlays == 'both': 532 elif overlays == 'both':
530 paths = [public_overlay, private_overlay] 533 paths = [public_overlay, private_overlay]
531 else: 534 else:
532 Die('Incorrect overlay configuration: %s' % overlays) 535 Die('Incorrect overlay configuration: %s' % overlays)
533 return paths 536 return paths
534 537
535 538
536 def _UploadPrebuilts(buildroot, board, overlay_config): 539 def _UploadPrebuilts(buildroot, board, overlay_config, binhosts):
537 """Upload prebuilts. 540 """Upload prebuilts.
538 541
539 Args: 542 Args:
540 buildroot: The root directory where the build occurs. 543 buildroot: The root directory where the build occurs.
541 board: Board type that was built on this machine 544 board: Board type that was built on this machine
542 overlay_config: A string describing which overlays you want. 545 overlay_config: A string describing which overlays you want.
543 'private': Just the private overlay. 546 'private': Just the private overlay.
544 'public': Just the public overlay. 547 'public': Just the public overlay.
545 'both': Both the public and private overlays. 548 'both': Both the public and private overlays.
549 binhosts: The URLs of the current binhosts. Binaries that are already
550 present will not be uploaded twice. Empty URLs will be ignored.
546 """ 551 """
547 552
548 cwd = os.path.join(buildroot, 'src', 'scripts') 553 cwd = os.path.join(buildroot, 'src', 'scripts')
549 cmd = [os.path.join(cwd, 'prebuilt.py'), 554 cmd = [os.path.join(cwd, 'prebuilt.py'),
550 '--sync-binhost-conf', 555 '--sync-binhost-conf',
551 '--build-path', buildroot, 556 '--build-path', buildroot,
552 '--board', board, 557 '--board', board,
553 '--prepend-version', 'preflight', 558 '--prepend-version', 'preflight',
554 '--key', _PREFLIGHT_BINHOST] 559 '--key', _PREFLIGHT_BINHOST]
560 for binhost in binhosts:
561 if binhost:
562 cmd.extend(['--previous-binhost-url', binhost])
555 if overlay_config == 'public': 563 if overlay_config == 'public':
556 cmd.extend(['--upload', 'gs://chromeos-prebuilt']) 564 cmd.extend(['--upload', 'gs://chromeos-prebuilt'])
557 else: 565 else:
558 assert overlay_config in ('private', 'both') 566 assert overlay_config in ('private', 'both')
559 cmd.extend(['--upload', 'chromeos-images:/var/www/prebuilt/', 567 cmd.extend(['--upload', 'chromeos-images:/var/www/prebuilt/',
560 '--binhost-base-url', 'http://chromeos-prebuilt']) 568 '--binhost-base-url', 'http://chromeos-prebuilt'])
561 569
562 RunCommand(cmd, cwd=cwd) 570 RunCommand(cmd, cwd=cwd)
563 571
564 572
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 buildconfig = _GetConfig(args[-1]) 618 buildconfig = _GetConfig(args[-1])
611 else: 619 else:
612 Warning('Missing configuration description') 620 Warning('Missing configuration description')
613 parser.print_usage() 621 parser.print_usage()
614 sys.exit(1) 622 sys.exit(1)
615 623
616 try: 624 try:
617 # Calculate list of overlay directories. 625 # Calculate list of overlay directories.
618 overlays = _ResolveOverlays(buildroot, buildconfig['overlays']) 626 overlays = _ResolveOverlays(buildroot, buildconfig['overlays'])
619 board = buildconfig['board'] 627 board = buildconfig['board']
628 new_binhost = None
620 629
621 _PreFlightRinse(buildroot, buildconfig['board'], tracking_branch, overlays) 630 _PreFlightRinse(buildroot, buildconfig['board'], tracking_branch, overlays)
622 chroot_path = os.path.join(buildroot, 'chroot') 631 chroot_path = os.path.join(buildroot, 'chroot')
623 boardpath = os.path.join(chroot_path, 'build', board) 632 boardpath = os.path.join(chroot_path, 'build', board)
624 if options.sync: 633 if options.sync:
625 if options.clobber or not os.path.isdir(buildroot): 634 if options.clobber or not os.path.isdir(buildroot):
626 _FullCheckout(buildroot, tracking_branch, url=options.url) 635 _FullCheckout(buildroot, tracking_branch, url=options.url)
627 else: 636 else:
628 old_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST) 637 old_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST)
629 _IncrementalCheckout(buildroot) 638 _IncrementalCheckout(buildroot)
630 new_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST) 639 new_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST)
631 if old_binhost != new_binhost: 640 if old_binhost != new_binhost:
632 RunCommand(['sudo', 'rm', '-rf', boardpath]) 641 RunCommand(['sudo', 'rm', '-rf', boardpath])
633 642
634 # Check that all overlays can be found. 643 # Check that all overlays can be found.
635 for path in overlays: 644 for path in overlays:
636 assert ':' not in path, 'Overlay must not contain colons: %s' % path 645 assert ':' not in path, 'Overlay must not contain colons: %s' % path
637 if not os.path.isdir(path): 646 if not os.path.isdir(path):
638 Die('Missing overlay: %s' % path) 647 Die('Missing overlay: %s' % path)
639 648
640 if not os.path.isdir(chroot_path): 649 if not os.path.isdir(chroot_path):
641 _MakeChroot(buildroot) 650 _MakeChroot(buildroot)
642 651
643 if not os.path.isdir(boardpath): 652 if not os.path.isdir(boardpath):
644 _SetupBoard(buildroot, board=buildconfig['board']) 653 _SetupBoard(buildroot, board=buildconfig['board'])
645 654
655 if not new_binhost:
sosa 2010/11/30 00:54:15 Why not just set it before you use it?
davidjames 2010/11/30 02:28:52 Done.
656 new_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST)
657
646 # Perform uprev. If chrome_uprev is set, rev Chrome ebuilds. 658 # Perform uprev. If chrome_uprev is set, rev Chrome ebuilds.
647 if options.chrome_rev: 659 if options.chrome_rev:
648 chrome_atom_to_build = _MarkChromeAsStable(buildroot, tracking_branch, 660 chrome_atom_to_build = _MarkChromeAsStable(buildroot, tracking_branch,
649 options.chrome_rev) 661 options.chrome_rev)
650 elif buildconfig['uprev']: 662 elif buildconfig['uprev']:
651 _UprevPackages(buildroot, tracking_branch, revisionfile, 663 _UprevPackages(buildroot, tracking_branch, revisionfile,
652 buildconfig['board'], overlays) 664 buildconfig['board'], overlays)
653 665
654 _EnableLocalAccount(buildroot) 666 _EnableLocalAccount(buildroot)
655 # Doesn't rebuild without acquiring more source. 667 # Doesn't rebuild without acquiring more source.
(...skipping 21 matching lines...) Expand all
677 test_results_dir=test_results_dir, 689 test_results_dir=test_results_dir,
678 gsutil=options.gsutil, 690 gsutil=options.gsutil,
679 archive_dir=archive_full_path, 691 archive_dir=archive_full_path,
680 acl=options.acl) 692 acl=options.acl)
681 693
682 if buildconfig['uprev']: 694 if buildconfig['uprev']:
683 # Don't push changes for developers. 695 # Don't push changes for developers.
684 if buildconfig['master']: 696 if buildconfig['master']:
685 # Master bot needs to check if the other slaves completed. 697 # Master bot needs to check if the other slaves completed.
686 if cbuildbot_comm.HaveSlavesCompleted(config): 698 if cbuildbot_comm.HaveSlavesCompleted(config):
687 _UploadPrebuilts(buildroot, board, buildconfig['overlays']) 699 _UploadPrebuilts(buildroot, board, buildconfig['overlays'],
700 [new_binhost])
688 _UprevPush(buildroot, tracking_branch, buildconfig['board'], 701 _UprevPush(buildroot, tracking_branch, buildconfig['board'],
689 overlays, options.debug) 702 overlays, options.debug)
690 else: 703 else:
691 Die('CBUILDBOT - One of the slaves has failed!!!') 704 Die('CBUILDBOT - One of the slaves has failed!!!')
692 705
693 else: 706 else:
694 # Publish my status to the master if its expecting it. 707 # Publish my status to the master if its expecting it.
695 if buildconfig['important'] and not options.debug: 708 if buildconfig['important'] and not options.debug:
696 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) 709 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE)
697 710
698 except: 711 except:
699 # Send failure to master bot. 712 # Send failure to master bot.
700 if not buildconfig['master'] and buildconfig['important']: 713 if not buildconfig['master'] and buildconfig['important']:
701 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) 714 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED)
702 715
703 raise 716 raise
704 717
705 718
706 if __name__ == '__main__': 719 if __name__ == '__main__':
707 main() 720 main()
OLDNEW
« no previous file with comments | « no previous file | bin/cbuildbot_unittest.py » ('j') | prebuilt.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698