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 |
11 import re | 11 import re |
12 import optparse | 12 import optparse |
13 import os | 13 import os |
14 import shutil | 14 import shutil |
15 import sys | 15 import sys |
16 | 16 |
17 import cbuildbot_comm | 17 import cbuildbot_comm |
18 from cbuildbot_config import config | 18 from cbuildbot_config import config |
19 | 19 |
20 sys.path.append(os.path.join(os.path.dirname(__file__), '../lib')) | 20 sys.path.append(os.path.join(os.path.dirname(__file__), '../lib')) |
21 from cros_build_lib import (Die, Info, ReinterpretPathForChroot, RunCommand, | 21 from cros_build_lib import (Die, Info, ReinterpretPathForChroot, RunCommand, |
22 Warning) | 22 Warning) |
23 | 23 |
24 _DEFAULT_RETRIES = 3 | 24 _DEFAULT_RETRIES = 3 |
| 25 _PACKAGE_FILE = '%(buildroot)s/src/scripts/cbuildbot_package.list' |
25 ARCHIVE_BASE = '/var/www/archive' | 26 ARCHIVE_BASE = '/var/www/archive' |
26 ARCHIVE_COUNT = 10 | 27 ARCHIVE_COUNT = 10 |
27 | 28 |
28 # ======================== Utility functions ================================ | 29 # ======================== Utility functions ================================ |
29 | 30 |
30 def MakeDir(path, parents=False): | 31 def MakeDir(path, parents=False): |
31 """Basic wrapper around os.mkdirs. | 32 """Basic wrapper around os.mkdirs. |
32 | 33 |
33 Keyword arguments: | 34 Keyword arguments: |
34 path -- Path to create. | 35 path -- Path to create. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 packages.append(package) | 196 packages.append(package) |
196 | 197 |
197 chroot_overlays = [ReinterpretPathForChroot(path) for path in overlays] | 198 chroot_overlays = [ReinterpretPathForChroot(path) for path in overlays] |
198 | 199 |
199 cwd = os.path.join(buildroot, 'src', 'scripts') | 200 cwd = os.path.join(buildroot, 'src', 'scripts') |
200 RunCommand(['./cros_mark_as_stable', | 201 RunCommand(['./cros_mark_as_stable', |
201 '--board=%s' % board, | 202 '--board=%s' % board, |
202 '--tracking_branch=%s' % tracking_branch, | 203 '--tracking_branch=%s' % tracking_branch, |
203 '--overlays=%s' % ':'.join(chroot_overlays), | 204 '--overlays=%s' % ':'.join(chroot_overlays), |
204 '--packages=%s' % ':'.join(packages), | 205 '--packages=%s' % ':'.join(packages), |
| 206 '--drop_file=%s' % ReinterpretPathForChroot(_PACKAGE_FILE % |
| 207 {'buildroot': buildroot}), |
205 'commit'], | 208 'commit'], |
206 cwd=cwd, enter_chroot=True) | 209 cwd=cwd, enter_chroot=True) |
207 | 210 |
208 | 211 |
209 def _UprevAllPackages(buildroot, tracking_branch, board, overlays): | 212 def _UprevAllPackages(buildroot, tracking_branch, board, overlays): |
210 """Uprevs all packages that have been updated since last uprev.""" | 213 """Uprevs all packages that have been updated since last uprev.""" |
211 cwd = os.path.join(buildroot, 'src', 'scripts') | 214 cwd = os.path.join(buildroot, 'src', 'scripts') |
212 chroot_overlays = [ReinterpretPathForChroot(path) for path in overlays] | 215 chroot_overlays = [ReinterpretPathForChroot(path) for path in overlays] |
213 RunCommand(['./cros_mark_as_stable', '--all', | 216 RunCommand(['./cros_mark_as_stable', '--all', |
214 '--board=%s' % board, | 217 '--board=%s' % board, |
215 '--overlays=%s' % ':'.join(chroot_overlays), | 218 '--overlays=%s' % ':'.join(chroot_overlays), |
216 '--tracking_branch=%s' % tracking_branch, 'commit'], | 219 '--tracking_branch=%s' % tracking_branch, |
| 220 '--drop_file=%s' % ReinterpretPathForChroot(_PACKAGE_FILE % |
| 221 {'buildroot': buildroot}), |
| 222 'commit'], |
217 cwd=cwd, enter_chroot=True) | 223 cwd=cwd, enter_chroot=True) |
218 | 224 |
219 | 225 |
220 def _GetVMConstants(buildroot): | 226 def _GetVMConstants(buildroot): |
221 """Returns minimum (vdisk_size, statefulfs_size) recommended for VM's.""" | 227 """Returns minimum (vdisk_size, statefulfs_size) recommended for VM's.""" |
222 cwd = os.path.join(buildroot, 'src', 'scripts', 'lib') | 228 cwd = os.path.join(buildroot, 'src', 'scripts', 'lib') |
223 source_cmd = 'source %s/cros_vm_constants.sh' % cwd | 229 source_cmd = 'source %s/cros_vm_constants.sh' % cwd |
224 vdisk_size = RunCommand([ | 230 vdisk_size = RunCommand([ |
225 '/bin/bash', '-c', '%s && echo $MIN_VDISK_SIZE_FULL' % source_cmd], | 231 '/bin/bash', '-c', '%s && echo $MIN_VDISK_SIZE_FULL' % source_cmd], |
226 redirect_stdout=True) | 232 redirect_stdout=True) |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 RunCommand(['./image_to_vm.sh', | 332 RunCommand(['./image_to_vm.sh', |
327 '--test_image', | 333 '--test_image', |
328 '--full', | 334 '--full', |
329 '--vdisk_size=%s' % vdisk_size, | 335 '--vdisk_size=%s' % vdisk_size, |
330 '--statefulfs_size=%s' % statefulfs_size, | 336 '--statefulfs_size=%s' % statefulfs_size, |
331 ], cwd=cwd, enter_chroot=True) | 337 ], cwd=cwd, enter_chroot=True) |
332 | 338 |
333 | 339 |
334 def _RunUnitTests(buildroot): | 340 def _RunUnitTests(buildroot): |
335 cwd = os.path.join(buildroot, 'src', 'scripts') | 341 cwd = os.path.join(buildroot, 'src', 'scripts') |
336 RunCommand(['./cros_run_unit_tests'], cwd=cwd, enter_chroot=True) | 342 RunCommand(['./cros_run_unit_tests', |
| 343 '--package_file=%s' % ReinterpretPathForChroot(_PACKAGE_FILE % |
| 344 {'buildroot': buildroot}), |
| 345 ], cwd=cwd, enter_chroot=True) |
337 | 346 |
338 | 347 |
339 def _RunSmokeSuite(buildroot, results_dir): | 348 def _RunSmokeSuite(buildroot, results_dir): |
340 results_dir_in_chroot = os.path.join(buildroot, 'chroot', | 349 results_dir_in_chroot = os.path.join(buildroot, 'chroot', |
341 results_dir.lstrip('/')) | 350 results_dir.lstrip('/')) |
342 if os.path.exists(results_dir_in_chroot): | 351 if os.path.exists(results_dir_in_chroot): |
343 shutil.rmtree(results_dir_in_chroot) | 352 shutil.rmtree(results_dir_in_chroot) |
344 | 353 |
345 cwd = os.path.join(buildroot, 'src', 'scripts') | 354 cwd = os.path.join(buildroot, 'src', 'scripts') |
346 RunCommand(['bin/cros_run_vm_test', | 355 RunCommand(['bin/cros_run_vm_test', |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 except: | 595 except: |
587 # Send failure to master bot. | 596 # Send failure to master bot. |
588 if not buildconfig['master'] and buildconfig['important']: | 597 if not buildconfig['master'] and buildconfig['important']: |
589 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) | 598 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) |
590 | 599 |
591 raise | 600 raise |
592 | 601 |
593 | 602 |
594 if __name__ == '__main__': | 603 if __name__ == '__main__': |
595 main() | 604 main() |
OLD | NEW |