Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 1 | # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
rtc@google.com | 6424466 | 2009-11-12 00:52:08 +0000 | [diff] [blame] | 5 | from buildutil import BuildObject |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 6 | from xml.dom import minidom |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 7 | import cherrypy |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 8 | import os |
Darin Petkov | 798fe7d | 2010-03-22 15:18:13 -0700 | [diff] [blame] | 9 | import shutil |
Chris Sosa | 05491b1 | 2010-11-08 17:14:16 -0800 | [diff] [blame] | 10 | import subprocess |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 11 | import tempfile |
Darin Petkov | 2b2ff4b | 2010-07-27 15:02:09 -0700 | [diff] [blame] | 12 | import time |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 13 | |
Chris Sosa | 05491b1 | 2010-11-08 17:14:16 -0800 | [diff] [blame] | 14 | |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 15 | def _LogMessage(message): |
| 16 | cherrypy.log(message, 'UPDATE') |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 17 | |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 18 | |
rtc@google.com | 6424466 | 2009-11-12 00:52:08 +0000 | [diff] [blame] | 19 | class Autoupdate(BuildObject): |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 20 | """Class that contains functionality that handles Chrome OS update pings. |
| 21 | |
| 22 | Members: |
| 23 | serve_only: Serve images from a pre-built image.zip file. static_dir |
| 24 | must be set to the location of the image.zip. |
| 25 | factory_config: Path to the factory config file if handling factory |
| 26 | requests. |
| 27 | use_test_image: Use chromiumos_test_image.bin rather than the standard. |
| 28 | static_url_base: base URL, other than devserver, for update images. |
| 29 | client_prefix: The prefix for the update engine client. |
| 30 | forced_image: Path to an image to use for all updates. |
| 31 | """ |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 32 | |
Sean O'Connor | 1f7fd36 | 2010-04-07 16:34:52 -0700 | [diff] [blame] | 33 | def __init__(self, serve_only=None, test_image=False, urlbase=None, |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 34 | factory_config_path=None, client_prefix=None, forced_image=None, |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 35 | use_cached=False, port=8080, src_image='', vm=False, board=None, |
Chris Sosa | e67b78f | 2010-11-04 17:33:16 -0700 | [diff] [blame] | 36 | *args, **kwargs): |
Sean O'Connor | 14b6a0a | 2010-03-20 23:23:48 -0700 | [diff] [blame] | 37 | super(Autoupdate, self).__init__(*args, **kwargs) |
Sean O'Connor | 1f7fd36 | 2010-04-07 16:34:52 -0700 | [diff] [blame] | 38 | self.serve_only = serve_only |
Sean O'Connor | 1b4b076 | 2010-06-02 17:37:32 -0700 | [diff] [blame] | 39 | self.factory_config = factory_config_path |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 40 | self.use_test_image = test_image |
Chris Sosa | 5d342a2 | 2010-09-28 16:54:41 -0700 | [diff] [blame] | 41 | if urlbase: |
Chris Sosa | 9841e1c | 2010-10-14 10:51:45 -0700 | [diff] [blame] | 42 | self.urlbase = urlbase |
Chris Sosa | 5d342a2 | 2010-09-28 16:54:41 -0700 | [diff] [blame] | 43 | else: |
Chris Sosa | 9841e1c | 2010-10-14 10:51:45 -0700 | [diff] [blame] | 44 | self.urlbase = None |
Chris Sosa | 5d342a2 | 2010-09-28 16:54:41 -0700 | [diff] [blame] | 45 | |
Chris Sosa | b63a928 | 2010-09-02 10:43:23 -0700 | [diff] [blame] | 46 | self.client_prefix = client_prefix |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 47 | self.forced_image = forced_image |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 48 | self.use_cached = use_cached |
Chris Sosa | 62f720b | 2010-10-26 21:39:48 -0700 | [diff] [blame] | 49 | self.src_image = src_image |
Chris Sosa | 4136e69 | 2010-10-28 23:42:37 -0700 | [diff] [blame] | 50 | self.vm = vm |
Chris Sosa | e67b78f | 2010-11-04 17:33:16 -0700 | [diff] [blame] | 51 | self.board = board |
Chris Sosa | 05491b1 | 2010-11-08 17:14:16 -0800 | [diff] [blame] | 52 | self.crosutils = os.path.join(os.path.dirname(__file__), '../../scripts') |
Sean O'Connor | 14b6a0a | 2010-03-20 23:23:48 -0700 | [diff] [blame] | 53 | |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 54 | def _GetSecondsSinceMidnight(self): |
| 55 | """Returns the seconds since midnight as a decimal value.""" |
Darin Petkov | 2b2ff4b | 2010-07-27 15:02:09 -0700 | [diff] [blame] | 56 | now = time.localtime() |
| 57 | return now[3] * 3600 + now[4] * 60 + now[5] |
| 58 | |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 59 | def _GetDefaultBoardID(self): |
| 60 | """Returns the default board id stored in .default_board.""" |
| 61 | board_file = '%s/.default_board' % (self.scripts_dir) |
| 62 | try: |
| 63 | return open(board_file).read() |
| 64 | except IOError: |
| 65 | return 'x86-generic' |
| 66 | |
| 67 | def _GetLatestImageDir(self, board_id): |
| 68 | """Returns the latest image dir based on shell script.""" |
| 69 | cmd = '%s/get_latest_image.sh --board %s' % (self.scripts_dir, board_id) |
| 70 | return os.popen(cmd).read().strip() |
| 71 | |
| 72 | def _GetVersionFromDir(self, image_dir): |
| 73 | """Returns the version of the image based on the name of the directory.""" |
| 74 | latest_version = os.path.basename(image_dir) |
| 75 | return latest_version.split('-')[0] |
| 76 | |
| 77 | def _CanUpdate(self, client_version, latest_version): |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 78 | """Returns true if the latest_version is greater than the client_version.""" |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 79 | client_tokens = client_version.replace('_', '').split('.') |
| 80 | latest_tokens = latest_version.replace('_', '').split('.') |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 81 | _LogMessage('client version %s latest version %s' |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 82 | % (client_version, latest_version)) |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 83 | for i in range(4): |
| 84 | if int(latest_tokens[i]) == int(client_tokens[i]): |
| 85 | continue |
| 86 | return int(latest_tokens[i]) > int(client_tokens[i]) |
| 87 | return False |
| 88 | |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 89 | def _UnpackZip(self, image_dir): |
| 90 | """Unpacks an image.zip into a given directory.""" |
| 91 | image = os.path.join(image_dir, self._GetImageName()) |
| 92 | if os.path.exists(image): |
| 93 | return True |
| 94 | else: |
| 95 | # -n, never clobber an existing file, in case we get invoked |
| 96 | # simultaneously by multiple request handlers. This means that |
| 97 | # we're assuming each image.zip file lives in a versioned |
| 98 | # directory (a la Buildbot). |
| 99 | return os.system('cd %s && unzip -n image.zip' % image_dir) == 0 |
| 100 | |
| 101 | def _GetImageName(self): |
| 102 | """Returns the name of the image that should be used.""" |
| 103 | if self.use_test_image: |
| 104 | image_name = 'chromiumos_test_image.bin' |
| 105 | else: |
| 106 | image_name = 'chromiumos_image.bin' |
| 107 | return image_name |
| 108 | |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 109 | def _IsImageNewerThanCached(self, image_path, cached_file_path): |
| 110 | """Returns true if the image is newer than the cached image.""" |
| 111 | if os.path.exists(cached_file_path) and os.path.exists(image_path): |
| 112 | _LogMessage('Usable cached image found at %s.' % cached_file_path) |
| 113 | return os.path.getmtime(image_path) > os.path.getmtime(cached_file_path) |
| 114 | elif not os.path.exists(cached_file_path) and not os.path.exists(image_path): |
| 115 | raise Exception('Image does not exist and cached image missing') |
| 116 | else: |
| 117 | # Only one is missing, figure out which one. |
| 118 | if os.path.exists(image_path): |
| 119 | _LogMessage('No cached image found - image generation required.') |
| 120 | return True |
| 121 | else: |
| 122 | _LogMessage('Cached image found to serve at %s.' % cached_file_path) |
| 123 | return False |
| 124 | |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 125 | def _GetSize(self, update_path): |
| 126 | """Returns the size of the file given.""" |
| 127 | return os.path.getsize(update_path) |
| 128 | |
| 129 | def _GetHash(self, update_path): |
| 130 | """Returns the sha1 of the file given.""" |
| 131 | cmd = ('cat %s | openssl sha1 -binary | openssl base64 | tr \'\\n\' \' \';' |
| 132 | % update_path) |
| 133 | return os.popen(cmd).read().rstrip() |
| 134 | |
Andrew de los Reyes | 5679b97 | 2010-10-25 17:34:49 -0700 | [diff] [blame] | 135 | def _IsDeltaFormatFile(self, filename): |
| 136 | try: |
| 137 | file_handle = open(filename, 'r') |
| 138 | delta_magic = 'CrAU' |
| 139 | magic = file_handle.read(len(delta_magic)) |
| 140 | return magic == delta_magic |
| 141 | except Exception: |
| 142 | return False |
| 143 | |
Darin Petkov | 91436cb | 2010-09-28 08:52:17 -0700 | [diff] [blame] | 144 | # TODO(petkov): Consider optimizing getting both SHA-1 and SHA-256 so that |
| 145 | # it takes advantage of reduced I/O and multiple processors. Something like: |
| 146 | # % tee < FILE > /dev/null \ |
| 147 | # >( openssl dgst -sha256 -binary | openssl base64 ) \ |
| 148 | # >( openssl sha1 -binary | openssl base64 ) |
| 149 | def _GetSHA256(self, update_path): |
| 150 | """Returns the sha256 of the file given.""" |
| 151 | cmd = ('cat %s | openssl dgst -sha256 -binary | openssl base64' % |
| 152 | update_path) |
| 153 | return os.popen(cmd).read().rstrip() |
| 154 | |
Andrew de los Reyes | 5679b97 | 2010-10-25 17:34:49 -0700 | [diff] [blame] | 155 | def GetUpdatePayload(self, hash, sha256, size, url, is_delta_format): |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 156 | """Returns a payload to the client corresponding to a new update. |
| 157 | |
| 158 | Args: |
| 159 | hash: hash of update blob |
Darin Petkov | 91436cb | 2010-09-28 08:52:17 -0700 | [diff] [blame] | 160 | sha256: SHA-256 hash of update blob |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 161 | size: size of update blob |
| 162 | url: where to find update blob |
| 163 | Returns: |
| 164 | Xml string to be passed back to client. |
| 165 | """ |
Andrew de los Reyes | 5679b97 | 2010-10-25 17:34:49 -0700 | [diff] [blame] | 166 | delta = 'false' |
| 167 | if is_delta_format: |
| 168 | delta = 'true' |
rtc@google.com | 21a5ca3 | 2009-11-04 18:23:23 +0000 | [diff] [blame] | 169 | payload = """<?xml version="1.0" encoding="UTF-8"?> |
| 170 | <gupdate xmlns="http://www.google.com/update2/response" protocol="2.0"> |
Darin Petkov | 2b2ff4b | 2010-07-27 15:02:09 -0700 | [diff] [blame] | 171 | <daystart elapsed_seconds="%s"/> |
rtc@google.com | 21a5ca3 | 2009-11-04 18:23:23 +0000 | [diff] [blame] | 172 | <app appid="{%s}" status="ok"> |
| 173 | <ping status="ok"/> |
Sean O'Connor | 14b6a0a | 2010-03-20 23:23:48 -0700 | [diff] [blame] | 174 | <updatecheck |
| 175 | codebase="%s" |
| 176 | hash="%s" |
Darin Petkov | 91436cb | 2010-09-28 08:52:17 -0700 | [diff] [blame] | 177 | sha256="%s" |
Sean O'Connor | 14b6a0a | 2010-03-20 23:23:48 -0700 | [diff] [blame] | 178 | needsadmin="false" |
| 179 | size="%s" |
Andrew de los Reyes | 5679b97 | 2010-10-25 17:34:49 -0700 | [diff] [blame] | 180 | IsDelta="%s" |
rtc@google.com | 21a5ca3 | 2009-11-04 18:23:23 +0000 | [diff] [blame] | 181 | status="ok"/> |
| 182 | </app> |
| 183 | </gupdate> |
| 184 | """ |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 185 | return payload % (self._GetSecondsSinceMidnight(), |
Andrew de los Reyes | 5679b97 | 2010-10-25 17:34:49 -0700 | [diff] [blame] | 186 | self.app_id, url, hash, sha256, size, delta) |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 187 | |
rtc@google.com | 21a5ca3 | 2009-11-04 18:23:23 +0000 | [diff] [blame] | 188 | def GetNoUpdatePayload(self): |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 189 | """Returns a payload to the client corresponding to no update.""" |
| 190 | payload = """ < ?xml version = "1.0" encoding = "UTF-8"? > |
| 191 | < gupdate xmlns = "http://www.google.com/update2/response" protocol = "2.0" > |
| 192 | < daystart elapsed_seconds = "%s" /> |
| 193 | < app appid = "{%s}" status = "ok" > |
| 194 | < ping status = "ok" /> |
| 195 | < updatecheck status = "noupdate" /> |
| 196 | </ app > |
| 197 | </ gupdate > |
rtc@google.com | 21a5ca3 | 2009-11-04 18:23:23 +0000 | [diff] [blame] | 198 | """ |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 199 | return payload % (self._GetSecondsSinceMidnight(), self.app_id) |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 200 | |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 201 | def GenerateUpdateFile(self, image_path): |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 202 | """Generates an update gz given a full path to an image. |
| 203 | |
| 204 | Args: |
| 205 | image_path: Full path to image. |
| 206 | Returns: |
| 207 | Path to created update_payload or None on error. |
| 208 | """ |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 209 | image_dir = os.path.dirname(image_path) |
| 210 | update_path = os.path.join(image_dir, 'update.gz') |
Chris Sosa | 4136e69 | 2010-10-28 23:42:37 -0700 | [diff] [blame] | 211 | patch_kernel_flag = '--patch_kernel' |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 212 | _LogMessage('Generating update image %s' % update_path) |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 213 | |
Chris Sosa | 4136e69 | 2010-10-28 23:42:37 -0700 | [diff] [blame] | 214 | # Don't patch the kernel for vm images as they don't need the patch. |
| 215 | if self.vm: |
| 216 | patch_kernel_flag = '' |
| 217 | |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 218 | mkupdate_command = ( |
Chris Sosa | 62f720b | 2010-10-26 21:39:48 -0700 | [diff] [blame] | 219 | '%s/cros_generate_update_payload --image="%s" --output="%s" ' |
Chris Sosa | 4136e69 | 2010-10-28 23:42:37 -0700 | [diff] [blame] | 220 | '%s --noold_style --src_image="%s"' % ( |
| 221 | self.scripts_dir, image_path, update_path, patch_kernel_flag, |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 222 | self.src_image)) |
Chris Sosa | 62f720b | 2010-10-26 21:39:48 -0700 | [diff] [blame] | 223 | _LogMessage(mkupdate_command) |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 224 | if os.system(mkupdate_command) != 0: |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 225 | _LogMessage('Failed to create base update file') |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 226 | return None |
| 227 | |
| 228 | return update_path |
| 229 | |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 230 | def GenerateStatefulFile(self, image_path): |
| 231 | """Generates a stateful update given a full path to an image. |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 232 | |
| 233 | Args: |
| 234 | image_path: Full path to image. |
| 235 | Returns: |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 236 | Path to created stateful update_payload. |
Chris Sosa | 908fd6f | 2010-11-10 17:31:18 -0800 | [diff] [blame] | 237 | Raises: |
| 238 | A subprocess exception if the update generator fails to generate a |
| 239 | stateful payload. |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 240 | """ |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 241 | work_dir = os.path.dirname(image_path) |
| 242 | output_gz = os.path.join(work_dir, 'stateful.tgz') |
Chris Sosa | 908fd6f | 2010-11-10 17:31:18 -0800 | [diff] [blame] | 243 | subprocess.check_call( |
| 244 | ['%s/cros_generate_stateful_update_payload' % self.crosutils, |
| 245 | '--image=%s' % image_path, |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 246 | '--output_dir=%s' % work_dir, |
Chris Sosa | 908fd6f | 2010-11-10 17:31:18 -0800 | [diff] [blame] | 247 | ]) |
Chris Sosa | 05491b1 | 2010-11-08 17:14:16 -0800 | [diff] [blame] | 248 | return output_gz |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 249 | |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 250 | def MoveImagesToStaticDir(self, update_path, stateful_update_path, |
| 251 | static_image_dir): |
| 252 | """Moves gz files from their directories to serving directories. |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 253 | |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 254 | Args: |
| 255 | update_path: full path to main update gz. |
| 256 | stateful_update_path: full path to stateful partition gz. |
| 257 | static_image_dir: where to put files. |
| 258 | Returns: |
| 259 | Returns True if the files were moved over successfully. |
| 260 | """ |
| 261 | try: |
| 262 | shutil.copy(update_path, static_image_dir) |
| 263 | shutil.copy(stateful_update_path, static_image_dir) |
| 264 | os.remove(update_path) |
| 265 | os.remove(stateful_update_path) |
| 266 | except Exception: |
| 267 | _LogMessage('Failed to move %s and %s to %s' % (update_path, |
| 268 | stateful_update_path, |
| 269 | static_image_dir)) |
| 270 | return False |
Andrew de los Reyes | 9a52871 | 2010-06-30 10:29:43 -0700 | [diff] [blame] | 271 | |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 272 | return True |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 273 | |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 274 | def GenerateUpdateImage(self, image_path, move_to_static_dir=False, |
| 275 | static_image_dir=None): |
| 276 | """Generates an update payload based on the given image_path. |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 277 | |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 278 | Args: |
| 279 | image_path: full path to the image. |
| 280 | move_to_static_dir: Moves the files from their dir to the static dir. |
| 281 | static_image_dir: the directory to move images to after generating. |
| 282 | Returns: |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 283 | True if the update payload was created successfully. |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 284 | """ |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 285 | _LogMessage('Generating update for image %s' % image_path) |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 286 | update_path = self.GenerateUpdateFile(image_path) |
| 287 | if update_path: |
| 288 | stateful_update_path = self.GenerateStatefulFile(image_path) |
| 289 | if move_to_static_dir: |
| 290 | return self.MoveImagesToStaticDir(update_path, stateful_update_path, |
Chris Sosa | 908fd6f | 2010-11-10 17:31:18 -0800 | [diff] [blame] | 291 | static_image_dir) |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 292 | return True |
Chris Sosa | e67b78f | 2010-11-04 17:33:16 -0700 | [diff] [blame] | 293 | |
| 294 | _LogMessage('Failed to generate update') |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 295 | return False |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 296 | |
| 297 | def GenerateLatestUpdateImage(self, board_id, client_version, |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 298 | static_image_dir=None): |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 299 | """Generates an update using the latest image that has been built. |
| 300 | |
| 301 | This will only generate an update if the newest update is newer than that |
| 302 | on the client or client_version is 'ForcedUpdate'. |
| 303 | |
| 304 | Args: |
| 305 | board_id: Name of the board. |
| 306 | client_version: Current version of the client or 'ForcedUpdate' |
| 307 | static_image_dir: the directory to move images to after generating. |
| 308 | Returns: |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 309 | True if the update payload was created successfully. |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 310 | """ |
| 311 | latest_image_dir = self._GetLatestImageDir(board_id) |
| 312 | latest_version = self._GetVersionFromDir(latest_image_dir) |
| 313 | latest_image_path = os.path.join(latest_image_dir, self._GetImageName()) |
| 314 | |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 315 | _LogMessage('Preparing to generate update from latest built image %s.' % |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 316 | latest_image_path) |
| 317 | |
| 318 | # Check to see whether or not we should update. |
| 319 | if client_version != 'ForcedUpdate' and not self._CanUpdate( |
| 320 | client_version, latest_version): |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 321 | _LogMessage('no update') |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 322 | return False |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 323 | |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 324 | cached_file_path = os.path.join(static_image_dir, 'update.gz') |
| 325 | if (os.path.exists(cached_file_path) and |
| 326 | not self._IsImageNewerThanCached(latest_image_path, cached_file_path)): |
| 327 | return True |
| 328 | |
| 329 | return self.GenerateUpdateImage(latest_image_path, move_to_static_dir=True, |
| 330 | static_image_dir=static_image_dir) |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 331 | |
| 332 | def GenerateImageFromZip(self, static_image_dir): |
| 333 | """Generates an update from an image zip file. |
| 334 | |
| 335 | This method assumes you have an image.zip in directory you are serving |
| 336 | from. If this file is newer than a previously cached file, it will unzip |
| 337 | this file, create a payload and serve it. |
| 338 | |
| 339 | Args: |
| 340 | static_image_dir: Directory where the zip file exists. |
| 341 | Returns: |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 342 | True if the update payload was created successfully. |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 343 | """ |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 344 | _LogMessage('Preparing to generate update from zip in %s.' % static_image_dir) |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 345 | image_path = os.path.join(static_image_dir, self._GetImageName()) |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 346 | cached_file_path = os.path.join(static_image_dir, 'update.gz') |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 347 | zip_file_path = os.path.join(static_image_dir, 'image.zip') |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 348 | if not self._IsImageNewerThanCached(zip_file_path, cached_file_path): |
| 349 | return True |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 350 | |
| 351 | if not self._UnpackZip(static_image_dir): |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 352 | _LogMessage('unzip image.zip failed.') |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 353 | return False |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 354 | |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 355 | return self.GenerateUpdateImage(image_path, move_to_static_dir=False, |
| 356 | static_image_dir=None) |
Darin Petkov | 8ef8345 | 2010-03-23 16:52:29 -0700 | [diff] [blame] | 357 | |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 358 | def ImportFactoryConfigFile(self, filename, validate_checksums=False): |
| 359 | """Imports a factory-floor server configuration file. The file should |
| 360 | be in this format: |
| 361 | config = [ |
| 362 | { |
| 363 | 'qual_ids': set([1, 2, 3, "x86-generic"]), |
| 364 | 'factory_image': 'generic-factory.gz', |
| 365 | 'factory_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
| 366 | 'release_image': 'generic-release.gz', |
| 367 | 'release_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
| 368 | 'oempartitionimg_image': 'generic-oem.gz', |
| 369 | 'oempartitionimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
Nick Sanders | e1eea92 | 2010-05-19 22:17:08 -0700 | [diff] [blame] | 370 | 'efipartitionimg_image': 'generic-efi.gz', |
| 371 | 'efipartitionimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 372 | 'stateimg_image': 'generic-state.gz', |
Tom Wai-Hong Tam | 65fc607 | 2010-05-20 11:44:26 +0800 | [diff] [blame] | 373 | 'stateimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
Tom Wai-Hong Tam | dac3df1 | 2010-06-14 09:56:15 +0800 | [diff] [blame] | 374 | 'firmware_image': 'generic-firmware.gz', |
| 375 | 'firmware_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 376 | }, |
| 377 | { |
| 378 | 'qual_ids': set([6]), |
| 379 | 'factory_image': '6-factory.gz', |
| 380 | 'factory_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
| 381 | 'release_image': '6-release.gz', |
| 382 | 'release_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
| 383 | 'oempartitionimg_image': '6-oem.gz', |
| 384 | 'oempartitionimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
Nick Sanders | e1eea92 | 2010-05-19 22:17:08 -0700 | [diff] [blame] | 385 | 'efipartitionimg_image': '6-efi.gz', |
| 386 | 'efipartitionimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 387 | 'stateimg_image': '6-state.gz', |
Tom Wai-Hong Tam | 65fc607 | 2010-05-20 11:44:26 +0800 | [diff] [blame] | 388 | 'stateimg_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
Tom Wai-Hong Tam | dac3df1 | 2010-06-14 09:56:15 +0800 | [diff] [blame] | 389 | 'firmware_image': '6-firmware.gz', |
| 390 | 'firmware_checksum': 'AtiI8B64agHVN+yeBAyiNMX3+HM=', |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 391 | }, |
| 392 | ] |
| 393 | The server will look for the files by name in the static files |
| 394 | directory. |
Chris Sosa | a73ec16 | 2010-05-03 20:18:02 -0700 | [diff] [blame] | 395 | |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 396 | If validate_checksums is True, validates checksums and exits. If |
| 397 | a checksum mismatch is found, it's printed to the screen. |
| 398 | """ |
| 399 | f = open(filename, 'r') |
| 400 | output = {} |
| 401 | exec(f.read(), output) |
| 402 | self.factory_config = output['config'] |
| 403 | success = True |
| 404 | for stanza in self.factory_config: |
Tom Wai-Hong Tam | 65fc607 | 2010-05-20 11:44:26 +0800 | [diff] [blame] | 405 | for key in stanza.copy().iterkeys(): |
| 406 | suffix = '_image' |
| 407 | if key.endswith(suffix): |
| 408 | kind = key[:-len(suffix)] |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 409 | stanza[kind + '_size'] = self._GetSize(os.path.join( |
| 410 | self.static_dir, stanza[kind + '_image'])) |
Tom Wai-Hong Tam | 65fc607 | 2010-05-20 11:44:26 +0800 | [diff] [blame] | 411 | if validate_checksums: |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 412 | factory_checksum = self._GetHash(os.path.join(self.static_dir, |
| 413 | stanza[kind + '_image'])) |
Tom Wai-Hong Tam | 65fc607 | 2010-05-20 11:44:26 +0800 | [diff] [blame] | 414 | if factory_checksum != stanza[kind + '_checksum']: |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 415 | print ('Error: checksum mismatch for %s. Expected "%s" but file ' |
| 416 | 'has checksum "%s".' % (stanza[kind + '_image'], |
| 417 | stanza[kind + '_checksum'], |
| 418 | factory_checksum)) |
Tom Wai-Hong Tam | 65fc607 | 2010-05-20 11:44:26 +0800 | [diff] [blame] | 419 | success = False |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 420 | |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 421 | if validate_checksums: |
| 422 | if success is False: |
| 423 | raise Exception('Checksum mismatch in conf file.') |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 424 | |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 425 | print 'Config file looks good.' |
| 426 | |
| 427 | def GetFactoryImage(self, board_id, channel): |
Nick Sanders | 723f326 | 2010-09-16 05:18:41 -0700 | [diff] [blame] | 428 | kind = channel.rsplit('-', 1)[0] |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 429 | for stanza in self.factory_config: |
| 430 | if board_id not in stanza['qual_ids']: |
| 431 | continue |
Nick Sanders | 15cd6ae | 2010-06-30 12:30:56 -0700 | [diff] [blame] | 432 | if kind + '_image' not in stanza: |
| 433 | break |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 434 | return (stanza[kind + '_image'], |
| 435 | stanza[kind + '_checksum'], |
| 436 | stanza[kind + '_size']) |
Nick Sanders | 15cd6ae | 2010-06-30 12:30:56 -0700 | [diff] [blame] | 437 | return (None, None, None) |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 438 | |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 439 | def HandleFactoryRequest(self, board_id, channel): |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 440 | (filename, checksum, size) = self.GetFactoryImage(board_id, channel) |
| 441 | if filename is None: |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 442 | _LogMessage('unable to find image for board %s' % board_id) |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 443 | return self.GetNoUpdatePayload() |
Chris Sosa | 05f9516 | 2010-10-14 18:01:52 -0700 | [diff] [blame] | 444 | url = '%s/static/%s' % (self.hostname, filename) |
Andrew de los Reyes | 5679b97 | 2010-10-25 17:34:49 -0700 | [diff] [blame] | 445 | is_delta_format = self._IsDeltaFormatFile(filename) |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 446 | _LogMessage('returning update payload ' + url) |
Darin Petkov | 91436cb | 2010-09-28 08:52:17 -0700 | [diff] [blame] | 447 | # Factory install is using memento updater which is using the sha-1 hash so |
| 448 | # setting sha-256 to an empty string. |
Andrew de los Reyes | 5679b97 | 2010-10-25 17:34:49 -0700 | [diff] [blame] | 449 | return self.GetUpdatePayload(checksum, '', size, url, is_delta_format) |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 450 | |
Chris Sosa | 151643e | 2010-10-28 14:40:57 -0700 | [diff] [blame] | 451 | def GenerateUpdatePayloadForNonFactory(self, board_id, client_version, |
| 452 | static_image_dir): |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 453 | """Generates an update for non-factory and returns True on success.""" |
| 454 | if self.use_cached and os.path.exists(os.path.join(static_image_dir, |
| 455 | 'update.gz')): |
| 456 | _LogMessage('Using cached image regardless of timestamps.') |
| 457 | return True |
Don Garrett | 710470d | 2010-11-15 17:43:44 -0800 | [diff] [blame] | 458 | else: |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 459 | if self.forced_image: |
| 460 | has_built_image = self.GenerateUpdateImage( |
| 461 | self.forced_image, move_to_static_dir=True, |
| 462 | static_image_dir=static_image_dir) |
| 463 | return has_built_image |
| 464 | elif self.serve_only: |
| 465 | return self.GenerateImageFromZip(static_image_dir) |
| 466 | else: |
| 467 | if board_id: |
| 468 | return self.GenerateLatestUpdateImage(board_id, |
| 469 | client_version, |
| 470 | static_image_dir) |
Don Garrett | 710470d | 2010-11-15 17:43:44 -0800 | [diff] [blame] | 471 | |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 472 | _LogMessage('You must set --board for pre-generating latest update.') |
| 473 | return False |
Chris Sosa | 2c048f1 | 2010-10-27 16:05:27 -0700 | [diff] [blame] | 474 | |
| 475 | def PreGenerateUpdate(self): |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 476 | """Pre-generates an update. Returns True on success.""" |
Chris Sosa | 2c048f1 | 2010-10-27 16:05:27 -0700 | [diff] [blame] | 477 | # Does not work with factory config. |
| 478 | assert(not self.factory_config) |
| 479 | _LogMessage('Pre-generating the update payload.') |
| 480 | # Does not work with labels so just use static dir. |
Chris Sosa | e67b78f | 2010-11-04 17:33:16 -0700 | [diff] [blame] | 481 | if self.GenerateUpdatePayloadForNonFactory(self.board, '0.0.0.0', |
| 482 | self.static_dir): |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 483 | # Force the devserver to use the pre-generated payload. |
| 484 | self.use_cached = True |
Chris Sosa | e67b78f | 2010-11-04 17:33:16 -0700 | [diff] [blame] | 485 | _LogMessage('Pre-generated update successfully.') |
| 486 | return True |
Chris Sosa | 2c048f1 | 2010-10-27 16:05:27 -0700 | [diff] [blame] | 487 | else: |
| 488 | _LogMessage('Failed to pre-generate update.') |
Chris Sosa | e67b78f | 2010-11-04 17:33:16 -0700 | [diff] [blame] | 489 | return False |
Chris Sosa | 2c048f1 | 2010-10-27 16:05:27 -0700 | [diff] [blame] | 490 | |
Sean O'Connor | 14b6a0a | 2010-03-20 23:23:48 -0700 | [diff] [blame] | 491 | def HandleUpdatePing(self, data, label=None): |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 492 | """Handles an update ping from an update client. |
| 493 | |
| 494 | Args: |
| 495 | data: xml blob from client. |
| 496 | label: optional label for the update. |
| 497 | Returns: |
| 498 | Update payload message for client. |
| 499 | """ |
Chris Sosa | 9841e1c | 2010-10-14 10:51:45 -0700 | [diff] [blame] | 500 | # Set hostname as the hostname that the client is calling to and set up |
| 501 | # the url base. |
| 502 | self.hostname = cherrypy.request.base |
| 503 | if self.urlbase: |
| 504 | static_urlbase = self.urlbase |
| 505 | elif self.serve_only: |
| 506 | static_urlbase = '%s/static/archive' % self.hostname |
| 507 | else: |
| 508 | static_urlbase = '%s/static' % self.hostname |
| 509 | |
| 510 | _LogMessage('Using static url base %s' % static_urlbase) |
| 511 | _LogMessage('Handling update ping as %s: %s' % (self.hostname, data)) |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 512 | |
| 513 | # Check the client prefix to make sure you can support this type of update. |
Chris Sosa | 9841e1c | 2010-10-14 10:51:45 -0700 | [diff] [blame] | 514 | update_dom = minidom.parseString(data) |
| 515 | root = update_dom.firstChild |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 516 | if (root.hasAttribute('updaterversion') and |
| 517 | not root.getAttribute('updaterversion').startswith(self.client_prefix)): |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 518 | _LogMessage('Got update from unsupported updater:' + |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 519 | root.getAttribute('updaterversion')) |
Andrew de los Reyes | 9223f13 | 2010-05-07 17:08:17 -0700 | [diff] [blame] | 520 | return self.GetNoUpdatePayload() |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 521 | |
| 522 | # We only generate update payloads for updatecheck requests. |
| 523 | update_check = root.getElementsByTagName('o:updatecheck') |
| 524 | if not update_check: |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 525 | _LogMessage('Non-update check received. Returning blank payload.') |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 526 | # TODO(sosa): Generate correct non-updatecheck payload to better test |
| 527 | # update clients. |
| 528 | return self.GetNoUpdatePayload() |
| 529 | |
| 530 | # Since this is an updatecheck, get information about the requester. |
Sean O'Connor | 14b6a0a | 2010-03-20 23:23:48 -0700 | [diff] [blame] | 531 | query = root.getElementsByTagName('o:app')[0] |
Charlie Lee | 8c99308 | 2010-02-24 13:27:37 -0800 | [diff] [blame] | 532 | client_version = query.getAttribute('version') |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 533 | channel = query.getAttribute('track') |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 534 | board_id = (query.hasAttribute('board') and query.getAttribute('board') |
| 535 | or self._GetDefaultBoardID()) |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 536 | |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 537 | # Separate logic as Factory requests have static url's that override |
| 538 | # other options. |
Andrew de los Reyes | 5262080 | 2010-04-12 13:40:07 -0700 | [diff] [blame] | 539 | if self.factory_config: |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 540 | return self.HandleFactoryRequest(board_id, channel) |
Nick Sanders | 723f326 | 2010-09-16 05:18:41 -0700 | [diff] [blame] | 541 | else: |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 542 | static_image_dir = self.static_dir |
| 543 | if label: |
| 544 | static_image_dir = os.path.join(static_image_dir, label) |
| 545 | |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 546 | if self.GenerateUpdatePayloadForNonFactory(board_id, client_version, |
| 547 | static_image_dir): |
| 548 | filename = os.path.join(static_image_dir, 'update.gz') |
Andrew de los Reyes | 5679b97 | 2010-10-25 17:34:49 -0700 | [diff] [blame] | 549 | hash = self._GetHash(filename) |
| 550 | sha256 = self._GetSHA256(filename) |
| 551 | size = self._GetSize(filename) |
| 552 | is_delta_format = self._IsDeltaFormatFile(filename) |
Chris Sosa | 5d342a2 | 2010-09-28 16:54:41 -0700 | [diff] [blame] | 553 | if label: |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 554 | url = '%s/%s/update.gz' % (static_urlbase, label) |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 555 | else: |
Chris Sosa | de91f67 | 2010-11-16 10:05:44 -0800 | [diff] [blame^] | 556 | url = '%s/update.gz' % static_urlbase |
Chris Sosa | 5d342a2 | 2010-09-28 16:54:41 -0700 | [diff] [blame] | 557 | |
Chris Sosa | 7c93136 | 2010-10-11 19:49:01 -0700 | [diff] [blame] | 558 | _LogMessage('Responding to client to use url %s to get image.' % url) |
Andrew de los Reyes | 5679b97 | 2010-10-25 17:34:49 -0700 | [diff] [blame] | 559 | return self.GetUpdatePayload(hash, sha256, size, url, is_delta_format) |
Chris Sosa | 0356d3b | 2010-09-16 15:46:22 -0700 | [diff] [blame] | 560 | else: |
Nick Sanders | 723f326 | 2010-09-16 05:18:41 -0700 | [diff] [blame] | 561 | return self.GetNoUpdatePayload() |