OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2011 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 """Main builder code for Chromium OS. | 7 """Main builder code for Chromium OS. |
8 | 8 |
9 Used by Chromium OS buildbot configuration for all Chromium OS builds including | 9 Used by Chromium OS buildbot configuration for all Chromium OS builds including |
10 full and pre-flight-queue builds. | 10 full and pre-flight-queue builds. |
11 """ | 11 """ |
12 | 12 |
13 import errno | 13 import errno |
14 import optparse | 14 import optparse |
15 import os | 15 import os |
16 import sys | 16 import sys |
17 import traceback | 17 import traceback |
18 | 18 |
19 if __name__ == '__main__': | 19 if __name__ == '__main__': |
20 import constants | 20 import constants |
21 sys.path.append(constants.SOURCE_ROOT) | 21 sys.path.append(constants.SOURCE_ROOT) |
22 | 22 |
23 import chromite.buildbot.cbuildbot_comm as cbuildbot_comm | 23 import chromite.buildbot.cbuildbot_comm as cbuildbot_comm |
24 import chromite.buildbot.cbuildbot_config as cbuildbot_config | 24 import chromite.buildbot.cbuildbot_config as cbuildbot_config |
25 import chromite.buildbot.cbuildbot_stages as stages | 25 import chromite.buildbot.cbuildbot_stages as stages |
26 import chromite.lib.cros_build_lib as cros_lib | 26 import chromite.lib.cros_build_lib as cros_lib |
27 | 27 |
28 | 28 |
29 def _GetConfig(config_name): | 29 def _GetConfig(config_name, options): |
30 """Gets the configuration for the build""" | 30 """Gets the configuration for the build""" |
31 build_config = {} | 31 build_config = {} |
32 if not cbuildbot_config.config.has_key(config_name): | 32 if not cbuildbot_config.config.has_key(config_name): |
33 Warning('Non-existent configuration specified.') | 33 Warning('Non-existent configuration specified.') |
34 Warning('Please specify one of:') | 34 Warning('Please specify one of:') |
35 config_names = config.keys() | 35 config_names = config.keys() |
36 config_names.sort() | 36 config_names.sort() |
37 for name in config_names: | 37 for name in config_names: |
38 Warning(' %s' % name) | 38 Warning(' %s' % name) |
39 sys.exit(1) | 39 sys.exit(1) |
40 | 40 |
41 return cbuildbot_config.config[config_name] | 41 result = cbuildbot_config.config[config_name] |
| 42 |
| 43 # Use the config specific url, if not given on command line. |
| 44 if options.url: |
| 45 result['git_url'] = options.url |
| 46 |
| 47 return result |
42 | 48 |
43 | 49 |
44 def RunBuildStages(bot_id, options, build_config): | 50 def RunBuildStages(bot_id, options, build_config): |
45 """Run the requested build stages.""" | 51 """Run the requested build stages.""" |
46 try: | 52 try: |
47 if options.sync: | 53 if options.sync: |
48 stages.SyncStage(bot_id, options, build_config).Run() | 54 if build_config['manifest_version']: |
| 55 stages.ManifestVersionedSyncStage(bot_id, options, build_config).Run() |
| 56 else: |
| 57 stages.SyncStage(bot_id, options, build_config).Run() |
49 | 58 |
50 if options.build: | 59 if options.build: |
51 stages.BuildBoardStage(bot_id, options, build_config).Run() | 60 stages.BuildBoardStage(bot_id, options, build_config).Run() |
52 | 61 |
53 if options.uprev: | 62 if options.uprev: |
54 stages.UprevStage(bot_id, options, build_config).Run() | 63 stages.UprevStage(bot_id, options, build_config).Run() |
55 | 64 |
56 if options.build: | 65 if options.build: |
57 stages.BuildTargetStage(bot_id, options, build_config).Run() | 66 stages.BuildTargetStage(bot_id, options, build_config).Run() |
58 | 67 |
59 # TODO(sosa): We only want to archive artifacts if we have artifacts to | 68 # TODO(sosa): We only want to archive artifacts if we have artifacts to |
60 # archive. Today this means we have at least built an image. We should | 69 # archive. Today this means we have at least built an image. We should |
61 # make this more general and have dependencies within stages themselves ... | 70 # make this more general and have dependencies within stages themselves ... |
62 # i.e. archive -> build_target ... however someday it might be | 71 # i.e. archive -> build_target ... however someday it might be |
63 # archive->sync. | 72 # archive->sync. |
64 try: | 73 try: |
65 if options.tests: | 74 if options.tests: |
66 stages.TestStage(bot_id, options, build_config).Run() | 75 stages.TestStage(bot_id, options, build_config).Run() |
67 | 76 |
68 # Control master / slave logic here. | 77 # Control master / slave logic here. |
69 if build_config['master']: | 78 if build_config['master']: |
70 if cbuildbot_comm.HaveSlavesCompleted(cbuildbot_config.config): | 79 if cbuildbot_comm.HaveSlavesCompleted(cbuildbot_config.config): |
71 stages.PushChangesStage(bot_id, options, build_config).Run() | 80 stages.PushChangesStage(bot_id, options, build_config).Run() |
72 else: | 81 else: |
73 cros_lib.Die('One of the other slaves failed.') | 82 cros_lib.Die('One of the other slaves failed.') |
74 | 83 |
75 elif build_config['important']: | 84 elif build_config['important']: |
76 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) | 85 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_COMPLETE) |
77 | 86 |
| 87 if options.sync and build_config['manifest_version']: |
| 88 stages.ManifestVersionedSyncCompletionStage(bot_id, |
| 89 options, |
| 90 build_config, |
| 91 success=True).Run() |
| 92 |
78 finally: | 93 finally: |
79 if options.archive: | 94 if options.archive: |
80 stages.ArchiveStage(bot_id, options, build_config).Run() | 95 stages.ArchiveStage(bot_id, options, build_config).Run() |
81 cros_lib.Info('BUILD ARTIFACTS FOR THIS BUILD CAN BE FOUND AT:') | 96 cros_lib.Info('BUILD ARTIFACTS FOR THIS BUILD CAN BE FOUND AT:') |
82 cros_lib.Info(stages.BuilderStage.archive_url) | 97 cros_lib.Info(stages.BuilderStage.archive_url) |
83 | 98 |
84 except: | 99 except: |
85 # Send failure to master. | 100 # Send failure to master. |
86 if not build_config['master'] and build_config['important']: | 101 if not build_config['master'] and build_config['important']: |
87 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) | 102 cbuildbot_comm.PublishStatus(cbuildbot_comm.STATUS_BUILD_FAILED) |
88 | 103 |
| 104 if options.sync and build_config['manifest_version']: |
| 105 stages.ManifestVersionedSyncCompletionStage(bot_id, |
| 106 options, |
| 107 build_config, |
| 108 success=False).Run() |
89 raise | 109 raise |
90 | 110 |
91 | 111 |
92 def RunEverything(bot_id, options, build_config): | 112 def RunEverything(bot_id, options, build_config): |
93 """Pull out the meat of main() in a unittest friendly manner""" | 113 """Pull out the meat of main() in a unittest friendly manner""" |
94 | 114 |
95 completed_stages_file = os.path.join(options.buildroot, '.completed_stages') | 115 completed_stages_file = os.path.join(options.buildroot, '.completed_stages') |
96 | 116 |
97 if options.resume and os.path.exists(completed_stages_file): | 117 if options.resume and os.path.exists(completed_stages_file): |
98 with open(completed_stages_file, 'r') as load_file: | 118 with open(completed_stages_file, 'r') as load_file: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 default=False, | 179 default=False, |
160 help='Skip stages already successfully completed.') | 180 help='Skip stages already successfully completed.') |
161 parser.add_option('-f', '--revisionfile', | 181 parser.add_option('-f', '--revisionfile', |
162 help='file where new revisions are stored') | 182 help='file where new revisions are stored') |
163 parser.add_option('-t', '--tracking-branch', dest='tracking_branch', | 183 parser.add_option('-t', '--tracking-branch', dest='tracking_branch', |
164 default='cros/master', help='Run the buildbot on a branch') | 184 default='cros/master', help='Run the buildbot on a branch') |
165 parser.add_option('--nouprev', action='store_false', dest='uprev', | 185 parser.add_option('--nouprev', action='store_false', dest='uprev', |
166 default=True, | 186 default=True, |
167 help='Override values from buildconfig and never uprev.') | 187 help='Override values from buildconfig and never uprev.') |
168 parser.add_option('-u', '--url', dest='url', | 188 parser.add_option('-u', '--url', dest='url', |
169 default='http://git.chromium.org/git/manifest', | 189 default=None, |
170 help='Run the buildbot on internal manifest') | 190 help='Override the GIT repo URL from the build config.') |
171 | 191 |
172 (options, args) = parser.parse_args() | 192 (options, args) = parser.parse_args() |
173 | 193 |
174 if len(args) >= 1: | 194 if len(args) >= 1: |
175 bot_id = args[-1] | 195 bot_id = args[-1] |
176 build_config = _GetConfig(bot_id) | 196 build_config = _GetConfig(bot_id, options) |
177 else: | 197 else: |
178 parser.error('Invalid usage. Use -h to see usage.') | 198 parser.error('Invalid usage. Use -h to see usage.') |
179 | 199 |
180 RunEverything(bot_id, options, build_config) | 200 RunEverything(bot_id, options, build_config) |
181 | 201 |
182 | 202 |
183 if __name__ == '__main__': | 203 if __name__ == '__main__': |
184 main() | 204 main() |
OLD | NEW |