Chromium Code Reviews| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 source_cmd = 'source %s/cros_vm_constants.sh' % cwd | 223 source_cmd = 'source %s/cros_vm_constants.sh' % cwd |
| 224 vdisk_size = RunCommand([ | 224 vdisk_size = RunCommand([ |
| 225 '/bin/bash', '-c', '%s && echo $MIN_VDISK_SIZE_FULL' % source_cmd], | 225 '/bin/bash', '-c', '%s && echo $MIN_VDISK_SIZE_FULL' % source_cmd], |
| 226 redirect_stdout=True) | 226 redirect_stdout=True) |
| 227 statefulfs_size = RunCommand([ | 227 statefulfs_size = RunCommand([ |
| 228 '/bin/bash', '-c', '%s && echo $MIN_STATEFUL_FS_SIZE_FULL' % source_cmd], | 228 '/bin/bash', '-c', '%s && echo $MIN_STATEFUL_FS_SIZE_FULL' % source_cmd], |
| 229 redirect_stdout=True) | 229 redirect_stdout=True) |
| 230 return (vdisk_size.strip(), statefulfs_size.strip()) | 230 return (vdisk_size.strip(), statefulfs_size.strip()) |
| 231 | 231 |
| 232 | 232 |
| 233 def _GitCleanup(buildroot, board, tracking_branch, overlays): | 233 def _GitCleanup(buildroot, board, tracking_branch): |
| 234 """Clean up git branch after previous uprev attempt.""" | 234 """Clean up git branch after previous uprev attempt.""" |
| 235 cwd = os.path.join(buildroot, 'src', 'scripts') | 235 cwd = os.path.join(buildroot, 'src', 'scripts') |
| 236 if os.path.exists(cwd): | 236 if os.path.exists(cwd): |
| 237 RunCommand(['./cros_mark_as_stable', '--srcroot=..', | 237 RunCommand(['./cros_mark_as_stable', '--srcroot=..', |
| 238 '--board=%s' % board, | 238 '--board=%s' % board, |
| 239 '--overlays=%s' % ':'.join(overlays), | |
| 240 '--tracking_branch=%s' % tracking_branch, 'clean'], | 239 '--tracking_branch=%s' % tracking_branch, 'clean'], |
| 241 cwd=cwd, error_ok=True) | 240 cwd=cwd, error_ok=True) |
| 242 | 241 |
| 243 | 242 |
| 244 def _CleanUpMountPoints(buildroot): | 243 def _CleanUpMountPoints(buildroot): |
| 245 """Cleans up any stale mount points from previous runs.""" | 244 """Cleans up any stale mount points from previous runs.""" |
| 246 mount_output = RunCommand(['mount'], redirect_stdout=True) | 245 mount_output = RunCommand(['mount'], redirect_stdout=True) |
| 247 mount_pts_in_buildroot = RunCommand(['grep', buildroot], input=mount_output, | 246 mount_pts_in_buildroot = RunCommand(['grep', buildroot], input=mount_output, |
| 248 redirect_stdout=True, error_ok=True) | 247 redirect_stdout=True, error_ok=True) |
| 249 | 248 |
| 250 for mount_pt_str in mount_pts_in_buildroot.splitlines(): | 249 for mount_pt_str in mount_pts_in_buildroot.splitlines(): |
| 251 mount_pt = mount_pt_str.rpartition(' type ')[0].partition(' on ')[2] | 250 mount_pt = mount_pt_str.rpartition(' type ')[0].partition(' on ')[2] |
| 252 RunCommand(['sudo', 'umount', '-l', mount_pt], error_ok=True) | 251 RunCommand(['sudo', 'umount', '-l', mount_pt], error_ok=True) |
| 253 | 252 |
| 254 | 253 |
| 255 def _WipeOldOutput(buildroot): | 254 def _WipeOldOutput(buildroot): |
| 256 """Wipes out build output directories.""" | 255 """Wipes out build output directories.""" |
| 257 RunCommand(['rm', '-rf', 'src/build/images'], cwd=buildroot) | 256 RunCommand(['rm', '-rf', 'src/build/images'], cwd=buildroot) |
| 258 | 257 |
| 259 | 258 |
| 260 # =========================== Main Commands =================================== | 259 # =========================== Main Commands =================================== |
| 261 | 260 |
| 262 | 261 |
| 263 def _PreFlightRinse(buildroot, board, tracking_branch, overlays): | 262 def _PreFlightRinse(buildroot, board, tracking_branch): |
| 264 """Cleans up any leftover state from previous runs.""" | 263 """Cleans up any leftover state from previous runs.""" |
| 265 _GitCleanup(buildroot, board, tracking_branch, overlays) | 264 _GitCleanup(buildroot, board, tracking_branch) |
|
sosa
2010/11/16 02:37:44
Does this break git cleanup of some overlays?
davidjames
2010/11/16 02:55:41
cros_mark_as_stable defaults to cleaning up all of
| |
| 266 _CleanUpMountPoints(buildroot) | 265 _CleanUpMountPoints(buildroot) |
| 267 RunCommand(['sudo', 'killall', 'kvm'], error_ok=True) | 266 RunCommand(['sudo', 'killall', 'kvm'], error_ok=True) |
| 268 | 267 |
| 269 | 268 |
| 270 def _FullCheckout(buildroot, tracking_branch, rw_checkout=True, | 269 def _FullCheckout(buildroot, tracking_branch, rw_checkout=True, |
| 271 retries=_DEFAULT_RETRIES, | 270 retries=_DEFAULT_RETRIES, |
| 272 url='http://git.chromium.org/git/manifest'): | 271 url='http://git.chromium.org/git/manifest'): |
| 273 """Performs a full checkout and clobbers any previous checkouts.""" | 272 """Performs a full checkout and clobbers any previous checkouts.""" |
| 274 RunCommand(['sudo', 'rm', '-rf', buildroot]) | 273 RunCommand(['sudo', 'rm', '-rf', buildroot]) |
| 275 MakeDir(buildroot, parents=True) | 274 MakeDir(buildroot, parents=True) |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 revisionfile = options.revisionfile | 518 revisionfile = options.revisionfile |
| 520 tracking_branch = options.tracking_branch | 519 tracking_branch = options.tracking_branch |
| 521 | 520 |
| 522 if len(args) >= 1: | 521 if len(args) >= 1: |
| 523 buildconfig = _GetConfig(args[-1]) | 522 buildconfig = _GetConfig(args[-1]) |
| 524 else: | 523 else: |
| 525 Warning('Missing configuration description') | 524 Warning('Missing configuration description') |
| 526 parser.print_usage() | 525 parser.print_usage() |
| 527 sys.exit(1) | 526 sys.exit(1) |
| 528 | 527 |
| 529 # Calculate list of overlay directories. | |
| 530 overlays = _ResolveOverlays(buildroot, buildconfig['overlays']) | |
| 531 | |
| 532 try: | 528 try: |
| 533 _PreFlightRinse(buildroot, buildconfig['board'], tracking_branch, overlays) | 529 _PreFlightRinse(buildroot, buildconfig['board'], tracking_branch) |
| 534 if options.clobber or not os.path.isdir(buildroot): | 530 if options.clobber or not os.path.isdir(buildroot): |
| 535 _FullCheckout(buildroot, tracking_branch, url=options.url) | 531 _FullCheckout(buildroot, tracking_branch, url=options.url) |
| 536 else: | 532 else: |
| 537 _IncrementalCheckout(buildroot) | 533 _IncrementalCheckout(buildroot) |
| 538 | 534 |
| 535 # Calculate list of overlay directories. | |
| 536 overlays = _ResolveOverlays(buildroot, buildconfig['overlays']) | |
| 537 | |
| 539 chroot_path = os.path.join(buildroot, 'chroot') | 538 chroot_path = os.path.join(buildroot, 'chroot') |
| 540 if not os.path.isdir(chroot_path): | 539 if not os.path.isdir(chroot_path): |
| 541 _MakeChroot(buildroot) | 540 _MakeChroot(buildroot) |
| 542 | 541 |
| 543 boardpath = os.path.join(chroot_path, 'build', buildconfig['board']) | 542 boardpath = os.path.join(chroot_path, 'build', buildconfig['board']) |
| 544 if not os.path.isdir(boardpath): | 543 if not os.path.isdir(boardpath): |
| 545 _SetupBoard(buildroot, board=buildconfig['board']) | 544 _SetupBoard(buildroot, board=buildconfig['board']) |
| 546 | 545 |
| 547 if buildconfig['uprev']: | 546 if buildconfig['uprev']: |
| 548 _UprevPackages(buildroot, tracking_branch, revisionfile, | 547 _UprevPackages(buildroot, tracking_branch, revisionfile, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 except: | 583 except: |
| 585 # Send failure to master bot. | 584 # Send failure to master bot. |
| 586 if not buildconfig['master'] and buildconfig['important']: | 585 if not buildconfig['master'] and buildconfig['important']: |
| 587 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) | 586 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) |
| 588 | 587 |
| 589 raise | 588 raise |
| 590 | 589 |
| 591 | 590 |
| 592 if __name__ == '__main__': | 591 if __name__ == '__main__': |
| 593 main() | 592 main() |
| OLD | NEW |