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 13 matching lines...) Expand all Loading... |
24 factory_config: Path to the factory config file if handling factory | 24 factory_config: Path to the factory config file if handling factory |
25 requests. | 25 requests. |
26 use_test_image: Use chromiumos_test_image.bin rather than the standard. | 26 use_test_image: Use chromiumos_test_image.bin rather than the standard. |
27 static_url_base: base URL, other than devserver, for update images. | 27 static_url_base: base URL, other than devserver, for update images. |
28 client_prefix: The prefix for the update engine client. | 28 client_prefix: The prefix for the update engine client. |
29 forced_image: Path to an image to use for all updates. | 29 forced_image: Path to an image to use for all updates. |
30 """ | 30 """ |
31 | 31 |
32 def __init__(self, serve_only=None, test_image=False, urlbase=None, | 32 def __init__(self, serve_only=None, test_image=False, urlbase=None, |
33 factory_config_path=None, client_prefix=None, forced_image=None, | 33 factory_config_path=None, client_prefix=None, forced_image=None, |
34 use_cached=False, port=8080, *args, **kwargs): | 34 use_cached=False, port=8080, src_image='', *args, **kwargs): |
35 super(Autoupdate, self).__init__(*args, **kwargs) | 35 super(Autoupdate, self).__init__(*args, **kwargs) |
36 self.serve_only = serve_only | 36 self.serve_only = serve_only |
37 self.factory_config = factory_config_path | 37 self.factory_config = factory_config_path |
38 self.use_test_image = test_image | 38 self.use_test_image = test_image |
39 if urlbase: | 39 if urlbase: |
40 self.urlbase = urlbase | 40 self.urlbase = urlbase |
41 else: | 41 else: |
42 self.urlbase = None | 42 self.urlbase = None |
43 | 43 |
44 self.client_prefix = client_prefix | 44 self.client_prefix = client_prefix |
45 self.forced_image = forced_image | 45 self.forced_image = forced_image |
46 self.use_cached = use_cached | 46 self.use_cached = use_cached |
| 47 self.src_image = src_image |
47 | 48 |
48 def _GetSecondsSinceMidnight(self): | 49 def _GetSecondsSinceMidnight(self): |
49 """Returns the seconds since midnight as a decimal value.""" | 50 """Returns the seconds since midnight as a decimal value.""" |
50 now = time.localtime() | 51 now = time.localtime() |
51 return now[3] * 3600 + now[4] * 60 + now[5] | 52 return now[3] * 3600 + now[4] * 60 + now[5] |
52 | 53 |
53 def _GetDefaultBoardID(self): | 54 def _GetDefaultBoardID(self): |
54 """Returns the default board id stored in .default_board.""" | 55 """Returns the default board id stored in .default_board.""" |
55 board_file = '%s/.default_board' % (self.scripts_dir) | 56 board_file = '%s/.default_board' % (self.scripts_dir) |
56 try: | 57 try: |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 Args: | 214 Args: |
214 image_path: Full path to image. | 215 image_path: Full path to image. |
215 Returns: | 216 Returns: |
216 Path to created update_payload or None on error. | 217 Path to created update_payload or None on error. |
217 """ | 218 """ |
218 image_dir = os.path.dirname(image_path) | 219 image_dir = os.path.dirname(image_path) |
219 update_path = os.path.join(image_dir, 'update.gz') | 220 update_path = os.path.join(image_dir, 'update.gz') |
220 _LogMessage('Generating update image %s' % update_path) | 221 _LogMessage('Generating update image %s' % update_path) |
221 | 222 |
222 mkupdate_command = ( | 223 mkupdate_command = ( |
223 '%s/cros_generate_update_payload --image=%s --output=%s ' | 224 '%s/cros_generate_update_payload --image="%s" --output="%s" ' |
224 '--patch_kernel' % (self.scripts_dir, image_path, update_path)) | 225 '--patch_kernel --noold_style --src_image="%s"' % ( |
| 226 self.scripts_dir, image_path, |
| 227 update_path, self.src_image)) |
| 228 _LogMessage(mkupdate_command) |
225 if os.system(mkupdate_command) != 0: | 229 if os.system(mkupdate_command) != 0: |
226 _LogMessage('Failed to create base update file') | 230 _LogMessage('Failed to create base update file') |
227 return None | 231 return None |
228 | 232 |
229 return update_path | 233 return update_path |
230 | 234 |
231 def GenerateStatefulFile(self, image_path): | 235 def GenerateStatefulFile(self, image_path): |
232 """Generates a stateful update gz given a full path to an image. | 236 """Generates a stateful update gz given a full path to an image. |
233 | 237 |
234 Args: | 238 Args: |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 is_delta_format = self._IsDeltaFormatFile(filename) | 537 is_delta_format = self._IsDeltaFormatFile(filename) |
534 if label: | 538 if label: |
535 url = '%s/%s/update.gz' % (static_urlbase, label) | 539 url = '%s/%s/update.gz' % (static_urlbase, label) |
536 else: | 540 else: |
537 url = '%s/update.gz' % static_urlbase | 541 url = '%s/update.gz' % static_urlbase |
538 | 542 |
539 _LogMessage('Responding to client to use url %s to get image.' % url) | 543 _LogMessage('Responding to client to use url %s to get image.' % url) |
540 return self.GetUpdatePayload(hash, sha256, size, url, is_delta_format) | 544 return self.GetUpdatePayload(hash, sha256, size, url, is_delta_format) |
541 else: | 545 else: |
542 return self.GetNoUpdatePayload() | 546 return self.GetNoUpdatePayload() |
OLD | NEW |