Chromium Code Reviews| 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.lib.cros_build_lib as cros_lib | 13 import chromite.lib.cros_build_lib as cros_lib |
| 14 import chromite.buildbot.manifest_version as manifest_version | |
|
sosa
2011/04/11 19:03:54
alphabetical order is incorrect here.
dgarrett
2011/04/11 20:53:13
Done.
| |
| 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') |
| 23 | 24 |
| (...skipping 226 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 = self._options.tracking_branch.split('/') | |
| 288 increment = 'patch' | |
| 289 | |
| 290 if not branch[1]: | |
| 291 branch[1] = 'master' | |
| 292 increment = 'branch' # TODO Is this right? | |
| 293 | |
| 294 next_version = manifest_version.GenerateWorkload( | |
| 295 tmp_dir='/tmp/git.root', | |
| 296 source_repo=self._build_config['git_url'], | |
| 297 manifest_repo=self._build_config['manifest_version'], | |
| 298 branch=branch[1], | |
| 299 version_file='src/third_party/chromiumos-overlay/chromeos/config' | |
| 300 '/chromeos_version.sh', | |
| 301 board=self._build_config['board'], | |
| 302 incr_type= increment) | |
| 303 | |
| 304 if not next_version: | |
| 305 print "AUTOREV: Nothing to build!" | |
| 306 sys.exit(0); | |
| 307 | |
| 308 # Store off this value where the Completion stage can find it... | |
| 309 ManifestVersionedSyncStage.build_version = next_version | |
| 310 | |
| 311 commands.ManifestCheckout(self._build_root, | |
| 312 self._options.tracking_branch, | |
| 313 next_version, | |
| 314 url=self._build_config['manifest_version']) | |
| 315 | |
| 316 # Check that all overlays can be found. | |
| 317 self._ExtractOverlays() # Our list of overlays are from pre-sync, refresh | |
| 318 for path in BuilderStage.rev_overlays: | |
| 319 assert os.path.isdir(path), 'Missing overlay: %s' % path | |
| 320 | |
| 321 | |
| 322 class ManifestVersionedSyncCompletionStage(BuilderStage): | |
| 323 """Stage that records board specific results for a unique manifest file.""" | |
| 324 | |
| 325 def __init__(self, bot_id, options, build_config, success): | |
| 326 BuilderStage.__init__(self, bot_id, options, build_config) | |
| 327 self.success = success | |
| 328 | |
| 329 def _PerformStage(self): | |
| 330 | |
| 331 if not ManifestVersionedSyncStage.build_version: | |
| 332 # Nothing to do if ManifestVersionedSyncStage didn't complete | |
| 333 return | |
| 334 | |
| 335 manifest_version.UpdateStatus( | |
| 336 tmp_dir='/tmp/git.root', | |
| 337 manifest_repo=self._build_config['manifest_version'], | |
| 338 board=self._build_config['board'], | |
| 339 build_version=ManifestVersionedSyncStage.build_version, | |
| 340 success=self.success) | |
| 341 | |
| 278 class BuildBoardStage(BuilderStage): | 342 class BuildBoardStage(BuilderStage): |
| 279 """Stage that is responsible for building host pkgs and setting up a board.""" | 343 """Stage that is responsible for building host pkgs and setting up a board.""" |
| 280 def _PerformStage(self): | 344 def _PerformStage(self): |
| 281 chroot_path = os.path.join(self._build_root, 'chroot') | 345 chroot_path = os.path.join(self._build_root, 'chroot') |
| 282 board_path = os.path.join(chroot_path, 'build', self._build_config['board']) | 346 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']: | 347 if not os.path.isdir(chroot_path) or self._build_config['chroot_replace']: |
| 284 commands.MakeChroot( | 348 commands.MakeChroot( |
| 285 self._build_root, self._build_config['chroot_replace']) | 349 self._build_root, self._build_config['chroot_replace']) |
| 286 | 350 |
| 287 if not os.path.isdir(board_path): | 351 if not os.path.isdir(board_path): |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 def _PerformStage(self): | 456 def _PerformStage(self): |
| 393 if self._build_type in ('preflight', 'chrome'): | 457 if self._build_type in ('preflight', 'chrome'): |
| 394 commands.UploadPrebuilts( | 458 commands.UploadPrebuilts( |
| 395 self._build_root, self._build_config['board'], | 459 self._build_root, self._build_config['board'], |
| 396 self._build_config['rev_overlays'], [BuilderStage.new_binhost], | 460 self._build_config['rev_overlays'], [BuilderStage.new_binhost], |
| 397 self._build_type, self._options.chrome_rev) | 461 self._build_type, self._options.chrome_rev) |
| 398 | 462 |
| 399 commands.UprevPush(self._build_root, self._options.tracking_branch, | 463 commands.UprevPush(self._build_root, self._options.tracking_branch, |
| 400 self._build_config['board'], BuilderStage.push_overlays, | 464 self._build_config['board'], BuilderStage.push_overlays, |
| 401 self._options.debug) | 465 self._options.debug) |
| OLD | NEW |