OLD | NEW |
1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2009 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 from buildutil import BuildObject | 5 from buildutil import BuildObject |
6 from xml.dom import minidom | 6 from xml.dom import minidom |
7 | 7 |
8 import os | 8 import os |
9 import shutil | 9 import shutil |
10 import sys | 10 import sys |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 config = [ | 187 config = [ |
188 { | 188 { |
189 'qual_ids': set([1, 2, 3, "x86-generic"]), | 189 'qual_ids': set([1, 2, 3, "x86-generic"]), |
190 'factory_image': 'generic-factory.gz', | 190 'factory_image': 'generic-factory.gz', |
191 'factory_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', | 191 'factory_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
192 'release_image': 'generic-release.gz', | 192 'release_image': 'generic-release.gz', |
193 'release_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', | 193 'release_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
194 'oempartitionimg_image': 'generic-oem.gz', | 194 'oempartitionimg_image': 'generic-oem.gz', |
195 'oempartitionimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', | 195 'oempartitionimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
196 'stateimg_image': 'generic-state.gz', | 196 'stateimg_image': 'generic-state.gz', |
197 'stateimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=' | 197 'stateimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
| 198 'systemrom_image': 'generic-systemrom.gz', |
| 199 'systemrom_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
| 200 'ecrom_image': 'generic-ecrom.gz', |
| 201 'ecrom_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
198 }, | 202 }, |
199 { | 203 { |
200 'qual_ids': set([6]), | 204 'qual_ids': set([6]), |
201 'factory_image': '6-factory.gz', | 205 'factory_image': '6-factory.gz', |
202 'factory_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', | 206 'factory_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
203 'release_image': '6-release.gz', | 207 'release_image': '6-release.gz', |
204 'release_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', | 208 'release_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
205 'oempartitionimg_image': '6-oem.gz', | 209 'oempartitionimg_image': '6-oem.gz', |
206 'oempartitionimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', | 210 'oempartitionimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
207 'stateimg_image': '6-state.gz', | 211 'stateimg_image': '6-state.gz', |
208 'stateimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=' | 212 'stateimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
| 213 'systemrom_image': '6-systemrom.gz', |
| 214 'systemrom_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
| 215 'ecrom_image': '6-ecrom.gz', |
| 216 'ecrom_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
209 }, | 217 }, |
210 ] | 218 ] |
211 The server will look for the files by name in the static files | 219 The server will look for the files by name in the static files |
212 directory. | 220 directory. |
213 | 221 |
214 If validate_checksums is True, validates checksums and exits. If | 222 If validate_checksums is True, validates checksums and exits. If |
215 a checksum mismatch is found, it's printed to the screen. | 223 a checksum mismatch is found, it's printed to the screen. |
216 """ | 224 """ |
217 f = open(filename, 'r') | 225 f = open(filename, 'r') |
218 output = {} | 226 output = {} |
219 exec(f.read(), output) | 227 exec(f.read(), output) |
220 self.factory_config = output['config'] | 228 self.factory_config = output['config'] |
221 success = True | 229 success = True |
222 for stanza in self.factory_config: | 230 for stanza in self.factory_config: |
223 for kind in ('factory', 'oempartitionimg', 'release', 'stateimg'): | 231 for key in stanza.copy().iterkeys(): |
224 stanza[kind + '_size'] = \ | 232 suffix = '_image' |
225 os.path.getsize(self.static_dir + '/' + stanza[kind + '_image']) | 233 if key.endswith(suffix): |
226 if validate_checksums: | 234 kind = key[:-len(suffix)] |
227 factory_checksum = self.GetHash(self.static_dir + '/' + | 235 stanza[kind + '_size'] = \ |
228 stanza[kind + '_image']) | 236 os.path.getsize(self.static_dir + '/' + stanza[kind + '_image']) |
229 if factory_checksum != stanza[kind + '_checksum']: | 237 if validate_checksums: |
230 print 'Error: checksum mismatch for %s. Expected "%s" but file ' \ | 238 factory_checksum = self.GetHash(self.static_dir + '/' + |
231 'has checksum "%s".' % (stanza[kind + '_image'], | 239 stanza[kind + '_image']) |
232 stanza[kind + '_checksum'], | 240 if factory_checksum != stanza[kind + '_checksum']: |
233 factory_checksum) | 241 print 'Error: checksum mismatch for %s. Expected "%s" but file ' \ |
234 success = False | 242 'has checksum "%s".' % (stanza[kind + '_image'], |
| 243 stanza[kind + '_checksum'], |
| 244 factory_checksum) |
| 245 success = False |
235 if validate_checksums: | 246 if validate_checksums: |
236 if success is False: | 247 if success is False: |
237 raise Exception('Checksum mismatch in conf file.') | 248 raise Exception('Checksum mismatch in conf file.') |
238 print 'Config file looks good.' | 249 print 'Config file looks good.' |
239 | 250 |
240 def GetFactoryImage(self, board_id, channel): | 251 def GetFactoryImage(self, board_id, channel): |
241 kind = channel.rsplit('-', 1)[0] | 252 kind = channel.rsplit('-', 1)[0] |
242 for stanza in self.factory_config: | 253 for stanza in self.factory_config: |
243 if board_id not in stanza['qual_ids']: | 254 if board_id not in stanza['qual_ids']: |
244 continue | 255 continue |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 ok = self.BuildUpdateImage(latest_image_path) | 322 ok = self.BuildUpdateImage(latest_image_path) |
312 if ok != True: | 323 if ok != True: |
313 web.debug('Failed to build an update image') | 324 web.debug('Failed to build an update image') |
314 return self.GetNoUpdatePayload() | 325 return self.GetNoUpdatePayload() |
315 | 326 |
316 hash = self.GetHash('%s/update.gz' % self.static_dir) | 327 hash = self.GetHash('%s/update.gz' % self.static_dir) |
317 size = self.GetSize('%s/update.gz' % self.static_dir) | 328 size = self.GetSize('%s/update.gz' % self.static_dir) |
318 | 329 |
319 url = 'http://%s/static/update.gz' % hostname | 330 url = 'http://%s/static/update.gz' % hostname |
320 return self.GetUpdatePayload(hash, size, url) | 331 return self.GetUpdatePayload(hash, size, url) |
OLD | NEW |