| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Module containing the various stages that a builder runs.""" | 5 """Module containing the various stages that a builder runs.""" |
| 6 | 6 |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import sys | 9 import sys |
| 10 import tempfile | 10 import tempfile |
| 11 | 11 |
| 12 import chromite.buildbot.cbuildbot_commands as commands | 12 import chromite.buildbot.cbuildbot_commands as commands |
| 13 import chromite.buildbot.manifest_version as manifest_version |
| 13 import chromite.lib.cros_build_lib as cros_lib | 14 import chromite.lib.cros_build_lib as cros_lib |
| 14 | 15 |
| 15 _FULL_BINHOST = 'FULL_BINHOST' | 16 _FULL_BINHOST = 'FULL_BINHOST' |
| 16 PUBLIC_OVERLAY = '%(buildroot)s/src/third_party/chromiumos-overlay' | 17 PUBLIC_OVERLAY = '%(buildroot)s/src/third_party/chromiumos-overlay' |
| 17 _CROS_ARCHIVE_URL = 'CROS_ARCHIVE_URL' | 18 _CROS_ARCHIVE_URL = 'CROS_ARCHIVE_URL' |
| 18 OVERLAY_LIST_CMD = '%(buildroot)s/src/platform/dev/host/cros_overlay_list' | 19 OVERLAY_LIST_CMD = '%(buildroot)s/src/platform/dev/host/cros_overlay_list' |
| 19 | 20 |
| 20 class BuilderStage(): | 21 class BuilderStage(): |
| 21 """Parent class for stages to be performed by a builder.""" | 22 """Parent class for stages to be performed by a builder.""" |
| 22 name_stage_re = re.compile('(\w+)Stage') | 23 name_stage_re = re.compile('(\w+)Stage') |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 self.Results.Record(self._name, e) | 251 self.Results.Record(self._name, e) |
| 251 raise | 252 raise |
| 252 else: | 253 else: |
| 253 self.Results.Record(self._name, self.Results.SUCCESS) | 254 self.Results.Record(self._name, self.Results.SUCCESS) |
| 254 finally: | 255 finally: |
| 255 self._Finish() | 256 self._Finish() |
| 256 | 257 |
| 257 | 258 |
| 258 class SyncStage(BuilderStage): | 259 class SyncStage(BuilderStage): |
| 259 """Stage that performs syncing for the builder.""" | 260 """Stage that performs syncing for the builder.""" |
| 261 |
| 260 def _PerformStage(self): | 262 def _PerformStage(self): |
| 261 if self._options.clobber or not os.path.isdir(os.path.join(self._build_root, | 263 if self._options.clobber or not os.path.isdir(os.path.join(self._build_root, |
| 262 '.repo')): | 264 '.repo')): |
| 263 commands.FullCheckout(self._build_root, self._options.tracking_branch, | 265 commands.FullCheckout(self._build_root, self._options.tracking_branch, |
| 264 url=self._options.url) | 266 url=self._build_config['git_url']) |
| 265 self._ExtractOverlays() | |
| 266 else: | 267 else: |
| 267 commands.PreFlightRinse(self._build_root, self._build_config['board'], | 268 commands.PreFlightRinse(self._build_root, self._build_config['board'], |
| 268 self._options.tracking_branch, | 269 self._options.tracking_branch, |
| 269 BuilderStage.rev_overlays) | 270 BuilderStage.rev_overlays) |
| 270 BuilderStage.old_binhost = self._GetPortageEnvVar(_FULL_BINHOST) | 271 BuilderStage.old_binhost = self._GetPortageEnvVar(_FULL_BINHOST) |
| 271 commands.IncrementalCheckout(self._build_root) | 272 commands.IncrementalCheckout(self._build_root) |
| 272 | 273 |
| 273 # Check that all overlays can be found. | 274 # Check that all overlays can be found. |
| 275 self._ExtractOverlays() # Our list of overlays are from pre-sync, refresh |
| 274 for path in BuilderStage.rev_overlays: | 276 for path in BuilderStage.rev_overlays: |
| 275 assert os.path.isdir(path), 'Missing overlay: %s' % path | 277 assert os.path.isdir(path), 'Missing overlay: %s' % path |
| 276 | 278 |
| 277 | 279 |
| 280 class ManifestVersionedSyncStage(BuilderStage): |
| 281 """Stage that generates a unique manifest file, and sync's to it.""" |
| 282 |
| 283 build_version = None |
| 284 |
| 285 def _PerformStage(self): |
| 286 # Need to determine branch and set a local value here |
| 287 branch_parts = self._options.tracking_branch.split('/') |
| 288 |
| 289 if len(branch_parts) >= 2: |
| 290 branch = branch_parts[1] |
| 291 increment = 'patch' |
| 292 else: |
| 293 branch = 'master' |
| 294 increment = 'branch' |
| 295 |
| 296 next_version = manifest_version.GenerateWorkload( |
| 297 tmp_dir='/tmp/git.root', |
| 298 source_repo=self._build_config['git_url'], |
| 299 manifest_repo=self._build_config['manifest_version'], |
| 300 branch=branch, |
| 301 version_file=os.path.join('src/third_party/chromiumos-overlay', |
| 302 'chromeos/config/chromeos_version.sh'), |
| 303 build_name=self._build_config['board'], |
| 304 incr_type=increment, |
| 305 dry_run=self._options.debug) |
| 306 |
| 307 if not next_version: |
| 308 print 'AUTOREV: Nothing to build!' |
| 309 sys.exit(0); |
| 310 |
| 311 # Store off this value where the Completion stage can find it... |
| 312 ManifestVersionedSyncStage.build_version = next_version |
| 313 |
| 314 commands.ManifestCheckout(self._build_root, |
| 315 self._options.tracking_branch, |
| 316 next_version, |
| 317 url=self._build_config['manifest_version']) |
| 318 |
| 319 # Check that all overlays can be found. |
| 320 self._ExtractOverlays() # Our list of overlays are from pre-sync, refresh |
| 321 for path in BuilderStage.rev_overlays: |
| 322 assert os.path.isdir(path), 'Missing overlay: %s' % path |
| 323 |
| 324 |
| 325 class ManifestVersionedSyncCompletionStage(BuilderStage): |
| 326 """Stage that records board specific results for a unique manifest file.""" |
| 327 |
| 328 def __init__(self, bot_id, options, build_config, success): |
| 329 BuilderStage.__init__(self, bot_id, options, build_config) |
| 330 self.success = success |
| 331 |
| 332 def _PerformStage(self): |
| 333 |
| 334 if not ManifestVersionedSyncStage.build_version: |
| 335 # Nothing to do if ManifestVersionedSyncStage (or an earlier stage) |
| 336 # didn't complete. I don't want an additional error here to mask the |
| 337 # original error. |
| 338 return |
| 339 |
| 340 manifest_version.UpdateStatus( |
| 341 tmp_dir='/tmp/git.root', |
| 342 manifest_repo=self._build_config['manifest_version'], |
| 343 build_name=self._build_config['board'], |
| 344 build_version=ManifestVersionedSyncStage.build_version, |
| 345 success=self.success, |
| 346 dry_run=self._options.debug) |
| 347 |
| 278 class BuildBoardStage(BuilderStage): | 348 class BuildBoardStage(BuilderStage): |
| 279 """Stage that is responsible for building host pkgs and setting up a board.""" | 349 """Stage that is responsible for building host pkgs and setting up a board.""" |
| 280 def _PerformStage(self): | 350 def _PerformStage(self): |
| 281 chroot_path = os.path.join(self._build_root, 'chroot') | 351 chroot_path = os.path.join(self._build_root, 'chroot') |
| 282 board_path = os.path.join(chroot_path, 'build', self._build_config['board']) | 352 board_path = os.path.join(chroot_path, 'build', self._build_config['board']) |
| 283 if not os.path.isdir(chroot_path) or self._build_config['chroot_replace']: | 353 if not os.path.isdir(chroot_path) or self._build_config['chroot_replace']: |
| 284 commands.MakeChroot( | 354 commands.MakeChroot( |
| 285 self._build_root, self._build_config['chroot_replace']) | 355 self._build_root, self._build_config['chroot_replace']) |
| 286 | 356 |
| 287 if not os.path.isdir(board_path): | 357 if not os.path.isdir(board_path): |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 def _PerformStage(self): | 462 def _PerformStage(self): |
| 393 if self._build_type in ('preflight', 'chrome'): | 463 if self._build_type in ('preflight', 'chrome'): |
| 394 commands.UploadPrebuilts( | 464 commands.UploadPrebuilts( |
| 395 self._build_root, self._build_config['board'], | 465 self._build_root, self._build_config['board'], |
| 396 self._build_config['rev_overlays'], [BuilderStage.new_binhost], | 466 self._build_config['rev_overlays'], [BuilderStage.new_binhost], |
| 397 self._build_type, self._options.chrome_rev) | 467 self._build_type, self._options.chrome_rev) |
| 398 | 468 |
| 399 commands.UprevPush(self._build_root, self._options.tracking_branch, | 469 commands.UprevPush(self._build_root, self._options.tracking_branch, |
| 400 self._build_config['board'], BuilderStage.push_overlays, | 470 self._build_config['board'], BuilderStage.push_overlays, |
| 401 self._options.debug) | 471 self._options.debug) |
| OLD | NEW |