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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 cwd = os.path.join(buildroot, 'src', 'scripts') | 199 cwd = os.path.join(buildroot, 'src', 'scripts') |
200 RunCommand(['./cros_mark_as_stable', | 200 RunCommand(['./cros_mark_as_stable', |
201 '--board=%s' % board, | 201 '--board=%s' % board, |
202 '--tracking_branch=%s' % tracking_branch, | 202 '--tracking_branch=%s' % tracking_branch, |
203 '--overlays=%s' % ':'.join(chroot_overlays), | 203 '--overlays=%s' % ':'.join(chroot_overlays), |
204 '--packages=%s' % ':'.join(packages), | 204 '--packages=%s' % ':'.join(packages), |
205 'commit'], | 205 'commit'], |
206 cwd=cwd, enter_chroot=True) | 206 cwd=cwd, enter_chroot=True) |
207 | 207 |
208 | 208 |
209 def _MarkChromeAsStable(buildroot, tracking_branch, chrome_rev): | |
210 """Returns the atom for the newly revved chrome ebuild.""" | |
scottz
2010/11/23 02:44:40
I know you are going to love me for this.
Time to
sosa
2010/11/23 21:09:19
I don't agree. According to PEP-8 and our own sty
scottz
2010/11/24 04:21:53
That is entirely up to you, I like to error on the
sosa
2010/11/24 21:18:02
I generally agree but there are a few special case
| |
211 cwd = os.path.join(buildroot, 'src', 'scripts') | |
212 portage_atom = RunCommand(['bin/cros_mark_chrome_as_stable', | |
213 '--tracking_branch=%s' % tracking_branch, | |
214 chrome_rev], cwd=cwd, redirect_stdout=True, | |
215 enter_chroot=True).rstrip() | |
216 if not portage_atom: | |
217 Info('Found nothing to rev.') | |
218 return None | |
219 else: | |
220 return portage_atom | |
221 | |
222 | |
209 def _UprevAllPackages(buildroot, tracking_branch, board, overlays): | 223 def _UprevAllPackages(buildroot, tracking_branch, board, overlays): |
210 """Uprevs all packages that have been updated since last uprev.""" | 224 """Uprevs all packages that have been updated since last uprev.""" |
211 cwd = os.path.join(buildroot, 'src', 'scripts') | 225 cwd = os.path.join(buildroot, 'src', 'scripts') |
212 chroot_overlays = [ReinterpretPathForChroot(path) for path in overlays] | 226 chroot_overlays = [ReinterpretPathForChroot(path) for path in overlays] |
213 RunCommand(['./cros_mark_as_stable', '--all', | 227 RunCommand(['./cros_mark_as_stable', '--all', |
214 '--board=%s' % board, | 228 '--board=%s' % board, |
215 '--overlays=%s' % ':'.join(chroot_overlays), | 229 '--overlays=%s' % ':'.join(chroot_overlays), |
216 '--tracking_branch=%s' % tracking_branch, 'commit'], | 230 '--tracking_branch=%s' % tracking_branch, 'commit'], |
217 cwd=cwd, enter_chroot=True) | 231 cwd=cwd, enter_chroot=True) |
218 | 232 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 RunCommand(['./setup_board', '--fast', '--default', '--board=%s' % board], | 312 RunCommand(['./setup_board', '--fast', '--default', '--board=%s' % board], |
299 cwd=cwd, enter_chroot=True) | 313 cwd=cwd, enter_chroot=True) |
300 | 314 |
301 | 315 |
302 def _Build(buildroot): | 316 def _Build(buildroot): |
303 """Wrapper around build_packages.""" | 317 """Wrapper around build_packages.""" |
304 cwd = os.path.join(buildroot, 'src', 'scripts') | 318 cwd = os.path.join(buildroot, 'src', 'scripts') |
305 RunCommand(['./build_packages'], cwd=cwd, enter_chroot=True) | 319 RunCommand(['./build_packages'], cwd=cwd, enter_chroot=True) |
306 | 320 |
307 | 321 |
322 def _BuildChrome(buildroot, board, chrome_atom_to_build): | |
323 """Wrapper for emerge call to build Chrome.""" | |
324 cwd = os.path.join(buildroot, 'src', 'scripts') | |
325 RunCommand(['emerge-%s =%s' % (board, chrome_atom_to_build)], | |
scottz
2010/11/23 02:44:40
Why do we not want this to be individual list elem
sosa
2010/11/23 21:09:19
Done.
| |
326 cwd=cwd, enter_chroot=True) | |
327 | |
328 | |
308 def _EnableLocalAccount(buildroot): | 329 def _EnableLocalAccount(buildroot): |
309 cwd = os.path.join(buildroot, 'src', 'scripts') | 330 cwd = os.path.join(buildroot, 'src', 'scripts') |
310 # Set local account for test images. | 331 # Set local account for test images. |
311 RunCommand(['./enable_localaccount.sh', | 332 RunCommand(['./enable_localaccount.sh', |
312 'chronos'], | 333 'chronos'], |
313 print_cmd=False, cwd=cwd) | 334 print_cmd=False, cwd=cwd) |
314 | 335 |
315 | 336 |
316 def _BuildImage(buildroot): | 337 def _BuildImage(buildroot): |
317 _WipeOldOutput(buildroot) | 338 _WipeOldOutput(buildroot) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 # print >> sys.stderr, 'CBUILDBOT Revision list found %s' % revisions | 400 # print >> sys.stderr, 'CBUILDBOT Revision list found %s' % revisions |
380 # revision_list = _ParseRevisionString(revisions, | 401 # revision_list = _ParseRevisionString(revisions, |
381 # _CreateRepoDictionary(buildroot, board)) | 402 # _CreateRepoDictionary(buildroot, board)) |
382 # _UprevFromRevisionList(buildroot, tracking_branch, revision_list, board, | 403 # _UprevFromRevisionList(buildroot, tracking_branch, revision_list, board, |
383 # overlays) | 404 # overlays) |
384 #else: | 405 #else: |
385 Info('CBUILDBOT Revving all') | 406 Info('CBUILDBOT Revving all') |
386 _UprevAllPackages(buildroot, tracking_branch, board, overlays) | 407 _UprevAllPackages(buildroot, tracking_branch, board, overlays) |
387 | 408 |
388 | 409 |
389 def _UprevPush(buildroot, tracking_branch, board, overlays): | 410 def _UprevPush(buildroot, tracking_branch, board, overlays, dryrun): |
scottz
2010/11/23 02:44:40
dryrun=False or should this always be passed?
doc
sosa
2010/11/23 21:09:19
Prefer not have a default as it is a private funct
| |
390 """Pushes uprev changes to the main line.""" | 411 """Pushes uprev changes to the main line.""" |
391 cwd = os.path.join(buildroot, 'src', 'scripts') | 412 cwd = os.path.join(buildroot, 'src', 'scripts') |
392 RunCommand(['./cros_mark_as_stable', '--srcroot=..', | 413 cmd = ['./cros_mark_as_stable', |
393 '--board=%s' % board, | 414 '--srcroot=%s' % os.path.join(buildroot, 'src'), |
394 '--overlays=%s' % ':'.join(overlays), | 415 '--board=%s' % board, |
395 '--tracking_branch=%s' % tracking_branch, | 416 '--overlays=%s' % ':'.join(overlays), |
396 '--push_options=--bypass-hooks -f', 'push'], | 417 '--tracking_branch=%s' % tracking_branch |
397 cwd=cwd) | 418 ] |
419 if dryrun: | |
420 cmd.append('--dryrun') | |
421 | |
422 cmd.append('push') | |
scottz
2010/11/23 02:44:40
Is there a reason why push has to come after a pot
sosa
2010/11/23 21:09:19
I believe gflags will not correctly parse a flag a
scottz
2010/11/24 04:21:53
Ah right I forgot we are using gflags in cros_mark
sosa
2010/11/24 21:18:02
Yeah there's an issue to fix that :(
On 2010/11/2
| |
423 RunCommand(cmd, cwd=cwd) | |
398 | 424 |
399 | 425 |
400 def _ArchiveTestResults(buildroot, board, archive_dir, test_results_dir): | 426 def _ArchiveTestResults(buildroot, board, archive_dir, test_results_dir): |
401 """Archives the test results into the www dir for later use. | 427 """Archives the test results into the www dir for later use. |
402 | 428 |
403 Takes the results from the test_results_dir and dumps them into the archive | 429 Takes the results from the test_results_dir and dumps them into the archive |
404 dir specified. This also archives the last qemu image. | 430 dir specified. This also archives the last qemu image. |
405 | 431 |
406 board: Board to find the qemu image. | 432 board: Board to find the qemu image. |
407 archive_dir: Path from ARCHIVE_BASE to store image. | 433 archive_dir: Path from ARCHIVE_BASE to store image. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 | 514 |
489 | 515 |
490 def main(): | 516 def main(): |
491 # Parse options | 517 # Parse options |
492 usage = "usage: %prog [options] cbuildbot_config" | 518 usage = "usage: %prog [options] cbuildbot_config" |
493 parser = optparse.OptionParser(usage=usage) | 519 parser = optparse.OptionParser(usage=usage) |
494 parser.add_option('-r', '--buildroot', | 520 parser.add_option('-r', '--buildroot', |
495 help='root directory where build occurs', default=".") | 521 help='root directory where build occurs', default=".") |
496 parser.add_option('-n', '--buildnumber', | 522 parser.add_option('-n', '--buildnumber', |
497 help='build number', type='int', default=0) | 523 help='build number', type='int', default=0) |
524 parser.add_option( | |
525 '-c', '--chrome_rev', default=None, type='string', | |
scottz
2010/11/23 02:44:40
please align as the others are.
add a dest=chrome_
sosa
2010/11/23 21:09:19
Ok. I don't particuraly like adding unnecessary t
scottz
2010/11/24 04:21:53
I am fine with them either all being removed or ad
| |
526 help='Chrome_rev of type [tot|latest_release|sticky_release]') | |
498 parser.add_option('-f', '--revisionfile', | 527 parser.add_option('-f', '--revisionfile', |
499 help='file where new revisions are stored') | 528 help='file where new revisions are stored') |
500 parser.add_option('--clobber', action='store_true', dest='clobber', | 529 parser.add_option('--clobber', action='store_true', dest='clobber', |
501 default=False, | 530 default=False, |
502 help='Clobbers an old checkout before syncing') | 531 help='Clobbers an old checkout before syncing') |
503 parser.add_option('--debug', action='store_true', dest='debug', | 532 parser.add_option('--debug', action='store_true', dest='debug', |
504 default=False, | 533 default=False, |
505 help='Override some options to run as a developer.') | 534 help='Override some options to run as a developer.') |
535 parser.add_option('--nosync', action='store_false', dest='sync', | |
536 default=True, | |
537 help='Don\'t sync before building.') | |
scottz
2010/11/23 02:44:40
use double quotes instead of escaping the apostrop
sosa
2010/11/23 21:09:19
I believe this breaks style guidelines and will en
scottz
2010/11/24 04:21:53
Where do you see this breaking the style guide? Th
sosa
2010/11/24 21:18:02
Done.
| |
538 parser.add_option('--notests', action='store_false', dest='tests', | |
539 default=True, | |
540 help='Override values from buildconfig and run no tests.') | |
506 parser.add_option('-t', '--tracking-branch', dest='tracking_branch', | 541 parser.add_option('-t', '--tracking-branch', dest='tracking_branch', |
507 default='cros/master', help='Run the buildbot on a branch') | 542 default='cros/master', help='Run the buildbot on a branch') |
508 parser.add_option('-u', '--url', dest='url', | 543 parser.add_option('-u', '--url', dest='url', |
509 default='http://git.chromium.org/git/manifest', | 544 default='http://git.chromium.org/git/manifest', |
510 help='Run the buildbot on internal manifest') | 545 help='Run the buildbot on internal manifest') |
511 | 546 |
512 (options, args) = parser.parse_args() | 547 (options, args) = parser.parse_args() |
513 | 548 |
514 buildroot = os.path.abspath(options.buildroot) | 549 buildroot = os.path.abspath(options.buildroot) |
515 revisionfile = options.revisionfile | 550 revisionfile = options.revisionfile |
516 tracking_branch = options.tracking_branch | 551 tracking_branch = options.tracking_branch |
552 chrome_atom_to_build = None | |
517 | 553 |
518 if len(args) >= 1: | 554 if len(args) >= 1: |
519 buildconfig = _GetConfig(args[-1]) | 555 buildconfig = _GetConfig(args[-1]) |
520 else: | 556 else: |
521 Warning('Missing configuration description') | 557 Warning('Missing configuration description') |
522 parser.print_usage() | 558 parser.print_usage() |
523 sys.exit(1) | 559 sys.exit(1) |
524 | 560 |
525 # Calculate list of overlay directories. | 561 # Calculate list of overlay directories. |
526 overlays = _ResolveOverlays(buildroot, buildconfig['overlays']) | 562 overlays = _ResolveOverlays(buildroot, buildconfig['overlays']) |
527 | 563 |
528 try: | 564 try: |
529 _PreFlightRinse(buildroot, buildconfig['board'], tracking_branch, overlays) | 565 _PreFlightRinse(buildroot, buildconfig['board'], tracking_branch, overlays) |
530 if options.clobber or not os.path.isdir(buildroot): | 566 if options.sync: |
531 _FullCheckout(buildroot, tracking_branch, url=options.url) | 567 if options.clobber or not os.path.isdir(buildroot): |
532 else: | 568 _FullCheckout(buildroot, tracking_branch, url=options.url) |
533 _IncrementalCheckout(buildroot) | 569 else: |
570 _IncrementalCheckout(buildroot) | |
534 | 571 |
535 # Check that all overlays can be found. | 572 # Check that all overlays can be found. |
536 for path in overlays: | 573 for path in overlays: |
537 assert ':' not in path, 'Overlay must not contain colons: %s' % path | 574 assert ':' not in path, 'Overlay must not contain colons: %s' % path |
538 if not os.path.isdir(path): | 575 if not os.path.isdir(path): |
539 Die('Missing overlay: %s' % path) | 576 Die('Missing overlay: %s' % path) |
540 | 577 |
541 chroot_path = os.path.join(buildroot, 'chroot') | 578 chroot_path = os.path.join(buildroot, 'chroot') |
542 if not os.path.isdir(chroot_path): | 579 if not os.path.isdir(chroot_path): |
543 _MakeChroot(buildroot) | 580 _MakeChroot(buildroot) |
544 | 581 |
545 boardpath = os.path.join(chroot_path, 'build', buildconfig['board']) | 582 boardpath = os.path.join(chroot_path, 'build', buildconfig['board']) |
546 if not os.path.isdir(boardpath): | 583 if not os.path.isdir(boardpath): |
547 _SetupBoard(buildroot, board=buildconfig['board']) | 584 _SetupBoard(buildroot, board=buildconfig['board']) |
548 | 585 |
549 if buildconfig['uprev']: | 586 # Perform uprev. If chrome_uprev is set, rev Chrome ebuilds. |
587 if options.chrome_rev: | |
588 chrome_atom_to_build = _MarkChromeAsStable(buildroot, tracking_branch, | |
589 options.chrome_rev) | |
590 elif buildconfig['uprev']: | |
550 _UprevPackages(buildroot, tracking_branch, revisionfile, | 591 _UprevPackages(buildroot, tracking_branch, revisionfile, |
551 buildconfig['board'], overlays) | 592 buildconfig['board'], overlays) |
552 | 593 |
553 _EnableLocalAccount(buildroot) | 594 _EnableLocalAccount(buildroot) |
554 _Build(buildroot) | 595 # Doesn't rebuild without acquiring more source. |
555 if buildconfig['unittests']: | 596 if options.sync: |
597 _Build(buildroot) | |
598 | |
599 if chrome_atom_to_build: | |
600 _BuildChrome(buildroot, buildconfig['board'], chrome_atom_to_build) | |
601 | |
602 if buildconfig['unittests'] and options.tests: | |
556 _RunUnitTests(buildroot) | 603 _RunUnitTests(buildroot) |
557 | 604 |
558 _BuildImage(buildroot) | 605 _BuildImage(buildroot) |
559 | 606 |
560 if buildconfig['smoke_bvt']: | 607 if buildconfig['smoke_bvt'] and options.tests: |
561 _BuildVMImageForTesting(buildroot) | 608 _BuildVMImageForTesting(buildroot) |
562 test_results_dir = '/tmp/run_remote_tests.%s' % options.buildnumber | 609 test_results_dir = '/tmp/run_remote_tests.%s' % options.buildnumber |
563 try: | 610 try: |
564 _RunSmokeSuite(buildroot, test_results_dir) | 611 _RunSmokeSuite(buildroot, test_results_dir) |
565 finally: | 612 finally: |
566 _ArchiveTestResults(buildroot, buildconfig['board'], | 613 _ArchiveTestResults(buildroot, buildconfig['board'], |
567 archive_dir=options.buildnumber, | 614 archive_dir=options.buildnumber, |
568 test_results_dir=test_results_dir) | 615 test_results_dir=test_results_dir) |
569 | 616 |
570 if buildconfig['uprev']: | 617 if buildconfig['uprev']: |
571 # Don't push changes for developers. | 618 # Don't push changes for developers. |
572 if not options.debug: | 619 if buildconfig['master']: |
573 if buildconfig['master']: | 620 # Master bot needs to check if the other slaves completed. |
574 # Master bot needs to check if the other slaves completed. | 621 if cbuildbot_comm.HaveSlavesCompleted(config): |
575 if cbuildbot_comm.HaveSlavesCompleted(config): | 622 _UprevPush(buildroot, tracking_branch, buildconfig['board'], |
576 _UprevPush(buildroot, tracking_branch, buildconfig['board'], | 623 overlays, options.debug) |
577 overlays) | 624 else: |
578 else: | 625 Die('CBUILDBOT - One of the slaves has failed!!!') |
579 Die('CBUILDBOT - One of the slaves has failed!!!') | |
580 | 626 |
581 else: | 627 else: |
582 # Publish my status to the master if its expecting it. | 628 # Publish my status to the master if its expecting it. |
583 if buildconfig['important']: | 629 if buildconfig['important'] and not options.debug: |
584 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) | 630 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) |
585 | 631 |
586 except: | 632 except: |
587 # Send failure to master bot. | 633 # Send failure to master bot. |
588 if not buildconfig['master'] and buildconfig['important']: | 634 if not buildconfig['master'] and buildconfig['important']: |
589 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) | 635 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) |
590 | 636 |
591 raise | 637 raise |
592 | 638 |
593 | 639 |
594 if __name__ == '__main__': | 640 if __name__ == '__main__': |
595 main() | 641 main() |
OLD | NEW |