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

Side by Side Diff: bin/cbuildbot.py

Issue 6245013: Add more cbuild options, revise configs (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Fix problems from review. Created 9 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | bin/cbuildbot_config.py » ('j') | no next file with comments »
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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 url, '-b', 316 url, '-b',
317 '%s' % branch[-1]], cwd=buildroot, input='\n\ny\n') 317 '%s' % branch[-1]], cwd=buildroot, input='\n\ny\n')
318 RepoSync(buildroot, retries) 318 RepoSync(buildroot, retries)
319 319
320 320
321 def _IncrementalCheckout(buildroot, retries=_DEFAULT_RETRIES): 321 def _IncrementalCheckout(buildroot, retries=_DEFAULT_RETRIES):
322 """Performs a checkout without clobbering previous checkout.""" 322 """Performs a checkout without clobbering previous checkout."""
323 RepoSync(buildroot, retries) 323 RepoSync(buildroot, retries)
324 324
325 325
326 def _MakeChroot(buildroot): 326 def _MakeChroot(buildroot, replace=False):
327 """Wrapper around make_chroot.""" 327 """Wrapper around make_chroot."""
328 cwd = os.path.join(buildroot, 'src', 'scripts') 328 cwd = os.path.join(buildroot, 'src', 'scripts')
329 RunCommand(['./make_chroot', '--fast'], cwd=cwd) 329
330 cmd = ['./make_chroot', '--fast']
331
332 if replace:
333 cmd.append('--replace')
334
335 RunCommand(cmd, cwd=cwd)
330 336
331 337
332 def _GetPortageEnvVar(buildroot, board, envvar): 338 def _GetPortageEnvVar(buildroot, board, envvar):
333 """Get a portage environment variable for the specified board, if any. 339 """Get a portage environment variable for the specified board, if any.
334 340
335 buildroot: The root directory where the build occurs. Must be an absolute 341 buildroot: The root directory where the build occurs. Must be an absolute
336 path. 342 path.
337 board: Board type that was built on this machine. E.g. x86-generic. If this 343 board: Board type that was built on this machine. E.g. x86-generic. If this
338 is None, get the env var from the host. 344 is None, get the env var from the host.
339 envvar: The environment variable to get. E.g. 'PORTAGE_BINHOST'. 345 envvar: The environment variable to get. E.g. 'PORTAGE_BINHOST'.
(...skipping 11 matching lines...) Expand all
351 return binhost.rstrip('\n') 357 return binhost.rstrip('\n')
352 358
353 359
354 def _SetupBoard(buildroot, board='x86-generic'): 360 def _SetupBoard(buildroot, board='x86-generic'):
355 """Wrapper around setup_board.""" 361 """Wrapper around setup_board."""
356 cwd = os.path.join(buildroot, 'src', 'scripts') 362 cwd = os.path.join(buildroot, 'src', 'scripts')
357 RunCommand(['./setup_board', '--fast', '--default', '--board=%s' % board], 363 RunCommand(['./setup_board', '--fast', '--default', '--board=%s' % board],
358 cwd=cwd, enter_chroot=True) 364 cwd=cwd, enter_chroot=True)
359 365
360 366
361 def _Build(buildroot, emptytree): 367 def _Build(buildroot, emptytree, build_autotest=True, usepkg=True):
362 """Wrapper around build_packages.""" 368 """Wrapper around build_packages."""
363 cwd = os.path.join(buildroot, 'src', 'scripts') 369 cwd = os.path.join(buildroot, 'src', 'scripts')
364 if emptytree: 370 if emptytree:
365 cmd = ['sh', '-c', 'EXTRA_BOARD_FLAGS=--emptytree ./build_packages'] 371 cmd = ['sh', '-c', 'EXTRA_BOARD_FLAGS=--emptytree ./build_packages']
366 else: 372 else:
367 cmd = ['./build_packages'] 373 cmd = ['./build_packages']
368 374
375 if not build_autotest:
376 cmd.append('--nowithautotest')
377
378 if not usepkg:
379 cmd.append('--nousepkg')
380
369 RunCommand(cmd, cwd=cwd, enter_chroot=True) 381 RunCommand(cmd, cwd=cwd, enter_chroot=True)
370 382
371 383
372 def _EnableLocalAccount(buildroot): 384 def _EnableLocalAccount(buildroot):
373 cwd = os.path.join(buildroot, 'src', 'scripts') 385 cwd = os.path.join(buildroot, 'src', 'scripts')
374 # Set local account for test images. 386 # Set local account for test images.
375 RunCommand(['./enable_localaccount.sh', 387 RunCommand(['./enable_localaccount.sh',
376 'chronos'], 388 'chronos'],
377 print_cmd=False, cwd=cwd) 389 print_cmd=False, cwd=cwd)
378 390
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 'latest', image_name) 564 'latest', image_name)
553 RunCommand(['gzip', '-f', '--fast', image_path]) 565 RunCommand(['gzip', '-f', '--fast', image_path])
554 RunCommand([gsutil, 'cp', image_path + '.gz', archive_dir], 566 RunCommand([gsutil, 'cp', image_path + '.gz', archive_dir],
555 num_retries=num_gsutil_retries) 567 num_retries=num_gsutil_retries)
556 except Exception, e: 568 except Exception, e:
557 Warning('Could not archive test results (error=%s)' % str(e)) 569 Warning('Could not archive test results (error=%s)' % str(e))
558 570
559 571
560 def _GetConfig(config_name): 572 def _GetConfig(config_name):
561 """Gets the configuration for the build""" 573 """Gets the configuration for the build"""
562 default = config['default']
563 buildconfig = {} 574 buildconfig = {}
564 if not config.has_key(config_name): 575 if not config.has_key(config_name):
565 Warning('Non-existent configuration specified.') 576 Warning('Non-existent configuration specified.')
566 Warning('Please specify one of:') 577 Warning('Please specify one of:')
567 config_names = config.keys() 578 config_names = config.keys()
568 config_names.sort() 579 config_names.sort()
569 for name in config_names: 580 for name in config_names:
570 Warning(' %s' % name) 581 Warning(' %s' % name)
571 sys.exit(1) 582 sys.exit(1)
572 583
573 buildconfig = config[config_name] 584 return config[config_name]
574
575 for key in default.iterkeys():
576 if not buildconfig.has_key(key):
577 buildconfig[key] = default[key]
578
579 return buildconfig
580 585
581 586
582 def _ResolveOverlays(buildroot, overlays): 587 def _ResolveOverlays(buildroot, overlays):
583 """Return the list of overlays to use for a given buildbot. 588 """Return the list of overlays to use for a given buildbot.
584 589
585 Args: 590 Args:
586 buildroot: The root directory where the build occurs. Must be an absolute 591 buildroot: The root directory where the build occurs. Must be an absolute
587 path. 592 path.
588 overlays: A string describing which overlays you want. 593 overlays: A string describing which overlays you want.
589 'private': Just the private overlay. 594 'private': Just the private overlay.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 642
638 RunCommand(cmd, cwd=cwd) 643 RunCommand(cmd, cwd=cwd)
639 644
640 645
641 def main(): 646 def main():
642 # Parse options 647 # Parse options
643 usage = "usage: %prog [options] cbuildbot_config" 648 usage = "usage: %prog [options] cbuildbot_config"
644 parser = optparse.OptionParser(usage=usage) 649 parser = optparse.OptionParser(usage=usage)
645 parser.add_option('-a', '--acl', default='private', 650 parser.add_option('-a', '--acl', default='private',
646 help='ACL to set on GSD archives') 651 help='ACL to set on GSD archives')
647 parser.add_option('--archive_build', action='store_true', default=False,
648 help='Run the archive_build script.')
649 parser.add_option('-r', '--buildroot', 652 parser.add_option('-r', '--buildroot',
650 help='root directory where build occurs', default=".") 653 help='root directory where build occurs', default=".")
651 parser.add_option('-n', '--buildnumber', 654 parser.add_option('-n', '--buildnumber',
652 help='build number', type='int', default=0) 655 help='build number', type='int', default=0)
653 parser.add_option('--chrome_rev', default=None, type='string', 656 parser.add_option('--chrome_rev', default=None, type='string',
654 dest='chrome_rev', 657 dest='chrome_rev',
655 help=('Chrome_rev of type [tot|latest_release|' 658 help=('Chrome_rev of type [tot|latest_release|'
656 'sticky_release]')) 659 'sticky_release]'))
657 parser.add_option('-g', '--gsutil', default='', help='Location of gsutil') 660 parser.add_option('-g', '--gsutil', default='', help='Location of gsutil')
658 parser.add_option('-c', '--gsutil_archive', default='', 661 parser.add_option('-c', '--gsutil_archive', default='',
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 726
724 new_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST) 727 new_binhost = _GetPortageEnvVar(buildroot, board, _FULL_BINHOST)
725 emptytree = (old_binhost and old_binhost != new_binhost) 728 emptytree = (old_binhost and old_binhost != new_binhost)
726 729
727 # Check that all overlays can be found. 730 # Check that all overlays can be found.
728 for path in rev_overlays: 731 for path in rev_overlays:
729 if not os.path.isdir(path): 732 if not os.path.isdir(path):
730 Die('Missing overlay: %s' % path) 733 Die('Missing overlay: %s' % path)
731 734
732 if not os.path.isdir(chroot_path): 735 if not os.path.isdir(chroot_path):
733 _MakeChroot(buildroot) 736 _MakeChroot(buildroot, buildconfig['chroot_replace'])
734 737
735 if not os.path.isdir(boardpath): 738 if not os.path.isdir(boardpath):
736 _SetupBoard(buildroot, board=buildconfig['board']) 739 _SetupBoard(buildroot, board=buildconfig['board'])
737 740
738 # Perform uprev. If chrome_uprev is set, rev Chrome ebuilds. 741 # Perform uprev. If chrome_uprev is set, rev Chrome ebuilds.
739 if options.chrome_rev: 742 if options.chrome_rev:
740 chrome_atom_to_build = _MarkChromeAsStable(buildroot, tracking_branch, 743 chrome_atom_to_build = _MarkChromeAsStable(buildroot, tracking_branch,
741 options.chrome_rev, board) 744 options.chrome_rev, board)
742 # If we found nothing to rev, we're done here. 745 # If we found nothing to rev, we're done here.
743 if not chrome_atom_to_build: 746 if not chrome_atom_to_build:
744 return 747 return
745 748
746 elif buildconfig['uprev']: 749 elif buildconfig['uprev']:
747 _UprevPackages(buildroot, tracking_branch, revisionfile, 750 _UprevPackages(buildroot, tracking_branch, revisionfile,
748 buildconfig['board'], rev_overlays) 751 buildconfig['board'], rev_overlays)
749 752
750 _EnableLocalAccount(buildroot) 753 _EnableLocalAccount(buildroot)
751 754
752 if options.build: 755 if options.build:
753 _Build(buildroot, emptytree) 756 _Build(buildroot,
757 emptytree,
758 build_autotest=(buildconfig['vm_tests'] and options.tests),
759 usepkg=buildconfig['usepkg'])
754 760
755 if buildconfig['unittests'] and options.tests: 761 if buildconfig['unittests'] and options.tests:
756 _RunUnitTests(buildroot) 762 _RunUnitTests(buildroot)
757 763
758 _BuildImage(buildroot) 764 _BuildImage(buildroot)
759 765
760 if buildconfig['tests'] and options.tests: 766 if buildconfig['vm_tests'] and options.tests:
761 _BuildVMImageForTesting(buildroot) 767 _BuildVMImageForTesting(buildroot)
762 test_results_dir = '/tmp/run_remote_tests.%s' % options.buildnumber 768 test_results_dir = '/tmp/run_remote_tests.%s' % options.buildnumber
763 try: 769 try:
764 _RunSmokeSuite(buildroot, test_results_dir) 770 _RunSmokeSuite(buildroot, test_results_dir)
765 _RunAUTest(buildroot, buildconfig['board']) 771 _RunAUTest(buildroot, buildconfig['board'])
766 finally: 772 finally:
767 if not options.debug: 773 if not options.debug:
768 archive_full_path = os.path.join(options.gsutil_archive, 774 archive_full_path = os.path.join(options.gsutil_archive,
769 str(options.buildnumber)) 775 str(options.buildnumber))
770 _ArchiveTestResults(buildroot, buildconfig['board'], 776 _ArchiveTestResults(buildroot, buildconfig['board'],
(...skipping 13 matching lines...) Expand all
784 _UprevPush(buildroot, tracking_branch, buildconfig['board'], 790 _UprevPush(buildroot, tracking_branch, buildconfig['board'],
785 push_overlays, options.debug) 791 push_overlays, options.debug)
786 else: 792 else:
787 Die('CBUILDBOT - One of the slaves has failed!!!') 793 Die('CBUILDBOT - One of the slaves has failed!!!')
788 794
789 else: 795 else:
790 # Publish my status to the master if its expecting it. 796 # Publish my status to the master if its expecting it.
791 if buildconfig['important'] and not options.debug: 797 if buildconfig['important'] and not options.debug:
792 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) 798 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE)
793 799
794 if options.archive_build: 800 if buildconfig['archive_build']:
795 _LegacyArchiveBuild(bot_id, 801 _LegacyArchiveBuild(bot_id,
796 buildconfig, 802 buildconfig,
797 options.buildnumber, 803 options.buildnumber,
798 options.debug) 804 options.debug)
799 except: 805 except:
800 # Send failure to master bot. 806 # Send failure to master bot.
801 if not buildconfig['master'] and buildconfig['important']: 807 if not buildconfig['master'] and buildconfig['important']:
802 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) 808 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED)
803 809
804 raise 810 raise
805 811
806 812
807 if __name__ == '__main__': 813 if __name__ == '__main__':
808 main() 814 main()
OLDNEW
« no previous file with comments | « no previous file | bin/cbuildbot_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698