Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2009-2010 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 cherrypy | 8 import cherrypy |
| 9 import os | 9 import os |
| 10 import shutil | 10 import shutil |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 | 41 |
| 42 Members: | 42 Members: |
| 43 serve_only: Serve only pre-built updates. static_dir must contain update.gz | 43 serve_only: Serve only pre-built updates. static_dir must contain update.gz |
| 44 and stateful.tgz. | 44 and stateful.tgz. |
| 45 factory_config: Path to the factory config file if handling factory | 45 factory_config: Path to the factory config file if handling factory |
| 46 requests. | 46 requests. |
| 47 use_test_image: Use chromiumos_test_image.bin rather than the standard. | 47 use_test_image: Use chromiumos_test_image.bin rather than the standard. |
| 48 static_url_base: base URL, other than devserver, for update images. | 48 static_url_base: base URL, other than devserver, for update images. |
| 49 client_prefix: The prefix for the update engine client. | 49 client_prefix: The prefix for the update engine client. |
| 50 forced_image: Path to an image to use for all updates. | 50 forced_image: Path to an image to use for all updates. |
| 51 forced_payload: Path to pre-generated payload to serve. | |
| 52 port: port to host devserver | |
| 53 proxy_port: port of local proxy to tell client to connect to you through. | |
| 54 src_image: If specifies, creates a delta payload from this image. | |
|
petkov
2011/01/19 23:56:04
typoe: specifies
| |
| 55 vm: Set for VM images (doesn't patch kernel) | |
| 56 board: board for the image. Needed for pre-generating of updates. | |
| 57 copy_to_static_root: Copies images generated from the cache to | |
| 58 ~/static. | |
| 51 """ | 59 """ |
| 52 | 60 |
| 53 def __init__(self, serve_only=None, test_image=False, urlbase=None, | 61 def __init__(self, serve_only=None, test_image=False, urlbase=None, |
| 54 factory_config_path=None, client_prefix=None, | 62 factory_config_path=None, client_prefix=None, |
| 55 forced_image=None, forced_payload=None, | 63 forced_image=None, forced_payload=None, |
| 56 port=8080, proxy_port=None, src_image='', vm=False, board=None, | 64 port=8080, proxy_port=None, src_image='', vm=False, board=None, |
| 65 copy_to_static_root=True, | |
| 57 *args, **kwargs): | 66 *args, **kwargs): |
| 58 super(Autoupdate, self).__init__(*args, **kwargs) | 67 super(Autoupdate, self).__init__(*args, **kwargs) |
| 59 self.serve_only = serve_only | 68 self.serve_only = serve_only |
| 60 self.factory_config = factory_config_path | 69 self.factory_config = factory_config_path |
| 61 self.use_test_image = test_image | 70 self.use_test_image = test_image |
| 62 if urlbase: | 71 if urlbase: |
| 63 self.urlbase = urlbase | 72 self.urlbase = urlbase |
| 64 else: | 73 else: |
| 65 self.urlbase = None | 74 self.urlbase = None |
| 66 | 75 |
| 67 self.client_prefix = client_prefix | 76 self.client_prefix = client_prefix |
| 68 self.forced_image = forced_image | 77 self.forced_image = forced_image |
| 69 self.forced_payload = forced_payload | 78 self.forced_payload = forced_payload |
| 70 self.src_image = src_image | 79 self.src_image = src_image |
| 71 self.proxy_port = proxy_port | 80 self.proxy_port = proxy_port |
| 72 self.vm = vm | 81 self.vm = vm |
| 73 self.board = board | 82 self.board = board |
| 83 self.copy_to_static_root = copy_to_static_root | |
| 74 | 84 |
| 75 # Track update pregeneration, so we don't recopy if not needed. | 85 # Track update pregeneration, so we don't recopy if not needed. |
| 76 self.pregenerated = False | 86 self.pregenerated = False |
| 77 | 87 |
| 78 def _GetSecondsSinceMidnight(self): | 88 def _GetSecondsSinceMidnight(self): |
| 79 """Returns the seconds since midnight as a decimal value.""" | 89 """Returns the seconds since midnight as a decimal value.""" |
| 80 now = time.localtime() | 90 now = time.localtime() |
| 81 return now[3] * 3600 + now[4] * 60 + now[5] | 91 return now[3] * 3600 + now[4] * 60 + now[5] |
| 82 | 92 |
| 83 def _GetDefaultBoardID(self): | 93 def _GetDefaultBoardID(self): |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 os.makedirs(full_cache_dir) | 376 os.makedirs(full_cache_dir) |
| 367 | 377 |
| 368 result = self.GenerateUpdateImage(image_path, | 378 result = self.GenerateUpdateImage(image_path, |
| 369 full_cache_dir) | 379 full_cache_dir) |
| 370 | 380 |
| 371 if not result: | 381 if not result: |
| 372 # Clean up cache dir if it's not valid | 382 # Clean up cache dir if it's not valid |
| 373 os.system("rm -rf %s" % os.path.join(static_image_dir, cache_sub_dir)) | 383 os.system("rm -rf %s" % os.path.join(static_image_dir, cache_sub_dir)) |
| 374 return None | 384 return None |
| 375 | 385 |
| 376 # If the generation worked, copy files | 386 # Generation complete, copy if requested. |
| 377 self._Copy(cache_update_payload, update_payload) | 387 if self.copy_to_static_root: |
| 378 self._Copy(cache_stateful_payload, stateful_payload) | 388 self._Copy(cache_update_payload, update_payload) |
| 389 self._Copy(cache_stateful_payload, stateful_payload) | |
| 379 | 390 |
| 380 # Return just the filename in static_image_dir. | 391 # Return just the filename in static_image_dir. |
| 381 return UPDATE_FILE | 392 return UPDATE_FILE |
| 382 | 393 |
| 383 def GenerateLatestUpdateImage(self, board_id, client_version, | 394 def GenerateLatestUpdateImage(self, board_id, client_version, |
| 384 static_image_dir): | 395 static_image_dir): |
| 385 """Generates an update using the latest image that has been built. | 396 """Generates an update using the latest image that has been built. |
| 386 | 397 |
| 387 This will only generate an update if the newest update is newer than that | 398 This will only generate an update if the newest update is newer than that |
| 388 on the client or client_version is 'ForcedUpdate'. | 399 on the client or client_version is 'ForcedUpdate'. |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 646 is_delta_format = self._IsDeltaFormatFile(filename) | 657 is_delta_format = self._IsDeltaFormatFile(filename) |
| 647 if label: | 658 if label: |
| 648 url = '%s/%s/%s' % (static_urlbase, label, payload_path) | 659 url = '%s/%s/%s' % (static_urlbase, label, payload_path) |
| 649 else: | 660 else: |
| 650 url = '%s/%s' % (static_urlbase, payload_path) | 661 url = '%s/%s' % (static_urlbase, payload_path) |
| 651 | 662 |
| 652 _LogMessage('Responding to client to use url %s to get image.' % url) | 663 _LogMessage('Responding to client to use url %s to get image.' % url) |
| 653 return self.GetUpdatePayload(hash, sha256, size, url, is_delta_format) | 664 return self.GetUpdatePayload(hash, sha256, size, url, is_delta_format) |
| 654 else: | 665 else: |
| 655 return self.GetNoUpdatePayload() | 666 return self.GetNoUpdatePayload() |
| OLD | NEW |