| 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 re |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 def main(): | 369 def main(): |
| 370 # Parse options | 370 # Parse options |
| 371 usage = "usage: %prog [options] cbuildbot_config" | 371 usage = "usage: %prog [options] cbuildbot_config" |
| 372 parser = optparse.OptionParser(usage=usage) | 372 parser = optparse.OptionParser(usage=usage) |
| 373 parser.add_option('-r', '--buildroot', | 373 parser.add_option('-r', '--buildroot', |
| 374 help='root directory where build occurs', default=".") | 374 help='root directory where build occurs', default=".") |
| 375 parser.add_option('-n', '--buildnumber', | 375 parser.add_option('-n', '--buildnumber', |
| 376 help='build number', type='int', default=0) | 376 help='build number', type='int', default=0) |
| 377 parser.add_option('-f', '--revisionfile', | 377 parser.add_option('-f', '--revisionfile', |
| 378 help='file where new revisions are stored') | 378 help='file where new revisions are stored') |
| 379 parser.add_option('--noclobber', action='store_false', dest='clobber', | 379 parser.add_option('--clobber', action='store_true', dest='clobber', |
| 380 default=True, | 380 default=False, |
| 381 help='Disables clobbering the buildroot on failure') | 381 help='Clobbers an old checkout before syncing') |
| 382 (options, args) = parser.parse_args() | 382 (options, args) = parser.parse_args() |
| 383 | 383 |
| 384 buildroot = options.buildroot | 384 buildroot = options.buildroot |
| 385 revisionfile = options.revisionfile | 385 revisionfile = options.revisionfile |
| 386 clobber = options.clobber | 386 |
| 387 # Passed option to clobber. |
| 388 if options.clobber: |
| 389 RunCommand(['sudo', 'rm', '-rf', buildroot]) |
| 387 | 390 |
| 388 if len(args) == 1: | 391 if len(args) == 1: |
| 389 buildconfig = _GetConfig(args[0]) | 392 buildconfig = _GetConfig(args[0]) |
| 390 else: | 393 else: |
| 391 print >> sys.stderr, "Missing configuration description" | 394 print >> sys.stderr, "Missing configuration description" |
| 392 parser.print_usage() | 395 parser.print_usage() |
| 393 sys.exit(1) | 396 sys.exit(1) |
| 394 | 397 |
| 395 try: | 398 try: |
| 396 if not os.path.isdir(buildroot): | 399 if not os.path.isdir(buildroot): |
| (...skipping 28 matching lines...) Expand all Loading... |
| 425 _UprevCleanup(buildroot) | 428 _UprevCleanup(buildroot) |
| 426 sys.stderr('CBUILDBOT - One of the slaves has failed!!!') | 429 sys.stderr('CBUILDBOT - One of the slaves has failed!!!') |
| 427 sys.exit(1) | 430 sys.exit(1) |
| 428 else: | 431 else: |
| 429 # Publish my status to the master if its expecting it. | 432 # Publish my status to the master if its expecting it. |
| 430 if buildconfig['important']: | 433 if buildconfig['important']: |
| 431 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) | 434 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) |
| 432 | 435 |
| 433 _UprevCleanup(buildroot) | 436 _UprevCleanup(buildroot) |
| 434 except: | 437 except: |
| 435 # Something went wrong, cleanup (being paranoid) for next build. | |
| 436 if clobber: | |
| 437 RunCommand(['sudo', 'rm', '-rf', buildroot], print_cmd=False) | |
| 438 | |
| 439 # Send failure to master bot. | 438 # Send failure to master bot. |
| 440 if not buildconfig['master'] and buildconfig['important']: | 439 if not buildconfig['master'] and buildconfig['important']: |
| 441 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) | 440 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) |
| 442 | 441 |
| 443 raise | 442 raise |
| 444 | 443 |
| 445 | 444 |
| 446 if __name__ == '__main__': | 445 if __name__ == '__main__': |
| 447 main() | 446 main() |
| OLD | NEW |