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 |
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 debug=self._options.debug) |
| 304 |
| 305 if not next_version: |
| 306 print "AUTOREV: Nothing to build!" |
| 307 sys.exit(0); |
| 308 |
| 309 # Store off this value where the Completion stage can find it... |
| 310 ManifestVersionedSyncStage.build_version = next_version |
| 311 |
| 312 commands.ManifestCheckout(self._build_root, |
| 313 self._options.tracking_branch, |
| 314 next_version, |
| 315 url=self._build_config['manifest_version']) |
| 316 |
| 317 # Check that all overlays can be found. |
| 318 self._ExtractOverlays() # Our list of overlays are from pre-sync, refresh |
| 319 for path in BuilderStage.rev_overlays: |
| 320 assert os.path.isdir(path), 'Missing overlay: %s' % path |
| 321 |
| 322 |
| 323 class ManifestVersionedSyncCompletionStage(BuilderStage): |
| 324 """Stage that records board specific results for a unique manifest file.""" |
| 325 |
| 326 def __init__(self, bot_id, options, build_config, success): |
| 327 BuilderStage.__init__(self, bot_id, options, build_config) |
| 328 self.success = success |
| 329 |
| 330 def _PerformStage(self): |
| 331 |
| 332 if not ManifestVersionedSyncStage.build_version: |
| 333 # Nothing to do if ManifestVersionedSyncStage didn't complete |
| 334 return |
| 335 |
| 336 manifest_version.UpdateStatus( |
| 337 tmp_dir='/tmp/git.root', |
| 338 manifest_repo=self._build_config['manifest_version'], |
| 339 board=self._build_config['board'], |
| 340 build_version=ManifestVersionedSyncStage.build_version, |
| 341 success=self.success, |
| 342 debug=self._options.debug) |
| 343 |
278 class BuildBoardStage(BuilderStage): | 344 class BuildBoardStage(BuilderStage): |
279 """Stage that is responsible for building host pkgs and setting up a board.""" | 345 """Stage that is responsible for building host pkgs and setting up a board.""" |
280 def _PerformStage(self): | 346 def _PerformStage(self): |
281 chroot_path = os.path.join(self._build_root, 'chroot') | 347 chroot_path = os.path.join(self._build_root, 'chroot') |
282 board_path = os.path.join(chroot_path, 'build', self._build_config['board']) | 348 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']: | 349 if not os.path.isdir(chroot_path) or self._build_config['chroot_replace']: |
284 commands.MakeChroot( | 350 commands.MakeChroot( |
285 self._build_root, self._build_config['chroot_replace']) | 351 self._build_root, self._build_config['chroot_replace']) |
286 | 352 |
287 if not os.path.isdir(board_path): | 353 if not os.path.isdir(board_path): |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 def _PerformStage(self): | 458 def _PerformStage(self): |
393 if self._build_type in ('preflight', 'chrome'): | 459 if self._build_type in ('preflight', 'chrome'): |
394 commands.UploadPrebuilts( | 460 commands.UploadPrebuilts( |
395 self._build_root, self._build_config['board'], | 461 self._build_root, self._build_config['board'], |
396 self._build_config['rev_overlays'], [BuilderStage.new_binhost], | 462 self._build_config['rev_overlays'], [BuilderStage.new_binhost], |
397 self._build_type, self._options.chrome_rev) | 463 self._build_type, self._options.chrome_rev) |
398 | 464 |
399 commands.UprevPush(self._build_root, self._options.tracking_branch, | 465 commands.UprevPush(self._build_root, self._options.tracking_branch, |
400 self._build_config['board'], BuilderStage.push_overlays, | 466 self._build_config['board'], BuilderStage.push_overlays, |
401 self._options.debug) | 467 self._options.debug) |
OLD | NEW |