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 web | 9 import web |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 </gupdate> | 40 </gupdate> |
41 """ | 41 """ |
42 return payload % self.app_id | 42 return payload % self.app_id |
43 | 43 |
44 def GetLatestImagePath(self): | 44 def GetLatestImagePath(self): |
45 cmd = "%s/get_latest_image.sh" % self.scripts_dir | 45 cmd = "%s/get_latest_image.sh" % self.scripts_dir |
46 return os.popen(cmd).read().strip() | 46 return os.popen(cmd).read().strip() |
47 | 47 |
48 def GetLatestVersion(self, latest_image_path): | 48 def GetLatestVersion(self, latest_image_path): |
49 latest_version = latest_image_path.split('/')[-1] | 49 latest_version = latest_image_path.split('/')[-1] |
| 50 |
| 51 # Removes the portage build prefix. |
| 52 latest_version = latest_version.lstrip("g-") |
50 return latest_version.split('-')[0] | 53 return latest_version.split('-')[0] |
51 | 54 |
52 def CanUpdate(self, client_version, latest_version): | 55 def CanUpdate(self, client_version, latest_version): |
53 """ | 56 """ |
54 Returns true iff the latest_version is greater than the client_version. | 57 Returns true iff the latest_version is greater than the client_version. |
55 """ | 58 """ |
56 client_tokens = client_version.split('.') | 59 client_tokens = client_version.split('.') |
57 latest_tokens = latest_version.split('.') | 60 latest_tokens = latest_version.split('.') |
58 web.debug("client version %s latest version %s" % (client_version, latest_ve
rsion)) | 61 web.debug("client version %s latest version %s" % (client_version, latest_ve
rsion)) |
59 for i in range(0,4): | 62 for i in range(0,4): |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 if ok != True: | 107 if ok != True: |
105 web.debug("Failed to build an update image") | 108 web.debug("Failed to build an update image") |
106 return self.GetNoUpdatePayload() | 109 return self.GetNoUpdatePayload() |
107 | 110 |
108 hash = self.GetHash("%s/update.gz" % self.static_dir) | 111 hash = self.GetHash("%s/update.gz" % self.static_dir) |
109 size = self.GetSize("%s/update.gz" % self.static_dir) | 112 size = self.GetSize("%s/update.gz" % self.static_dir) |
110 hostname = web.ctx.host | 113 hostname = web.ctx.host |
111 url = "http://%s/static/update.gz" % hostname | 114 url = "http://%s/static/update.gz" % hostname |
112 return self.GetUpdatePayload(hash, size, url) | 115 return self.GetUpdatePayload(hash, size, url) |
113 | 116 |
OLD | NEW |