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 |
11 import subprocess | 11 import subprocess |
12 import time | 12 import time |
13 | 13 |
14 | 14 |
15 def _LogMessage(message): | 15 def _LogMessage(message): |
16 cherrypy.log(message, 'UPDATE') | 16 cherrypy.log(message, 'UPDATE') |
17 | 17 |
18 UPDATE_FILE='update.gz' | 18 UPDATE_FILE='update.gz' |
19 STATEFUL_FILE='stateful.tgz' | 19 STATEFUL_FILE='stateful.tgz' |
20 | 20 |
21 class Autoupdate(BuildObject): | 21 class Autoupdate(BuildObject): |
22 """Class that contains functionality that handles Chrome OS update pings. | 22 """Class that contains functionality that handles Chrome OS update pings. |
23 | 23 |
24 Members: | 24 Members: |
25 serve_only: Serve images from a pre-built image.zip file. static_dir | 25 serve_only: Serve updates from a pre-built image.zip file. If an update.gz |
sosa
2010/11/23 19:50:36
is newer*
| |
26 must be set to the location of the image.zip. | 26 newer than the extracted image exists in the static_dir, it will be |
sosa
2010/11/23 19:50:36
This is a little confusing. Can you make another
| |
27 served instead. static_dir must be set to the location of the image.zip. | |
27 factory_config: Path to the factory config file if handling factory | 28 factory_config: Path to the factory config file if handling factory |
28 requests. | 29 requests. |
29 use_test_image: Use chromiumos_test_image.bin rather than the standard. | 30 use_test_image: Use chromiumos_test_image.bin rather than the standard. |
30 static_url_base: base URL, other than devserver, for update images. | 31 static_url_base: base URL, other than devserver, for update images. |
31 client_prefix: The prefix for the update engine client. | 32 client_prefix: The prefix for the update engine client. |
32 forced_image: Path to an image to use for all updates. | 33 forced_image: Path to an image to use for all updates. |
33 """ | 34 """ |
34 | 35 |
35 def __init__(self, serve_only=None, test_image=False, urlbase=None, | 36 def __init__(self, serve_only=None, test_image=False, urlbase=None, |
36 factory_config_path=None, client_prefix=None, | 37 factory_config_path=None, client_prefix=None, |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 STATEFUL_FILE), | 539 STATEFUL_FILE), |
539 os.path.join(static_image_dir, | 540 os.path.join(static_image_dir, |
540 STATEFUL_FILE)) | 541 STATEFUL_FILE)) |
541 | 542 |
542 return UPDATE_FILE | 543 return UPDATE_FILE |
543 elif self.forced_image: | 544 elif self.forced_image: |
544 return self.GenerateUpdateImageWithCache( | 545 return self.GenerateUpdateImageWithCache( |
545 self.forced_image, | 546 self.forced_image, |
546 static_image_dir=static_image_dir) | 547 static_image_dir=static_image_dir) |
547 elif self.serve_only: | 548 elif self.serve_only: |
549 image_path = os.path.join(static_image_dir, self._GetImageName()) | |
550 update_path = os.path.join(static_image_dir, UPDATE_FILE) | |
551 | |
552 # If a valid update already exists, no need to generate. | |
553 if (os.path.exists(image_path) and os.path.exists(update_path) and | |
554 os.path.getmtime(image_path) < os.path.getmtime(update_path)): | |
sosa
2010/11/23 19:50:36
Can you fold this into GenerateImageFromZip and re
DaleCurtis
2010/11/23 20:11:20
I can if you really want to. I think it's confusin
sosa
2010/11/23 20:45:57
I'm ok with removing the logic but you many want t
DaleCurtis
2010/11/23 21:02:37
Sent, I'll give it until next week before making a
| |
555 _LogMessage('Existing update found to serve.') | |
556 return UPDATE_FILE | |
557 | |
548 return self.GenerateImageFromZip(static_image_dir) | 558 return self.GenerateImageFromZip(static_image_dir) |
549 else: | 559 else: |
550 if board_id: | 560 if board_id: |
551 return self.GenerateLatestUpdateImage(board_id, | 561 return self.GenerateLatestUpdateImage(board_id, |
552 client_version, | 562 client_version, |
553 static_image_dir) | 563 static_image_dir) |
554 | 564 |
555 _LogMessage('You must set --board for pre-generating latest update.') | 565 _LogMessage('You must set --board for pre-generating latest update.') |
556 return None | 566 return None |
557 | 567 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 is_delta_format = self._IsDeltaFormatFile(filename) | 647 is_delta_format = self._IsDeltaFormatFile(filename) |
638 if label: | 648 if label: |
639 url = '%s/%s/%s' % (static_urlbase, label, payload_path) | 649 url = '%s/%s/%s' % (static_urlbase, label, payload_path) |
640 else: | 650 else: |
641 url = '%s/%s' % (static_urlbase, payload_path) | 651 url = '%s/%s' % (static_urlbase, payload_path) |
642 | 652 |
643 _LogMessage('Responding to client to use url %s to get image.' % url) | 653 _LogMessage('Responding to client to use url %s to get image.' % url) |
644 return self.GetUpdatePayload(hash, sha256, size, url, is_delta_format) | 654 return self.GetUpdatePayload(hash, sha256, size, url, is_delta_format) |
645 else: | 655 else: |
646 return self.GetNoUpdatePayload() | 656 return self.GetNoUpdatePayload() |
OLD | NEW |