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, src_image='', *args, **kwargs): | 34 use_cached=False, port=8080, src_image='', vm=False, *args, |
| 35 **kwargs): |
35 super(Autoupdate, self).__init__(*args, **kwargs) | 36 super(Autoupdate, self).__init__(*args, **kwargs) |
36 self.serve_only = serve_only | 37 self.serve_only = serve_only |
37 self.factory_config = factory_config_path | 38 self.factory_config = factory_config_path |
38 self.use_test_image = test_image | 39 self.use_test_image = test_image |
39 if urlbase: | 40 if urlbase: |
40 self.urlbase = urlbase | 41 self.urlbase = urlbase |
41 else: | 42 else: |
42 self.urlbase = None | 43 self.urlbase = None |
43 | 44 |
44 self.client_prefix = client_prefix | 45 self.client_prefix = client_prefix |
45 self.forced_image = forced_image | 46 self.forced_image = forced_image |
46 self.use_cached = use_cached | 47 self.use_cached = use_cached |
47 self.src_image = src_image | 48 self.src_image = src_image |
| 49 self.vm = vm |
48 | 50 |
49 def _GetSecondsSinceMidnight(self): | 51 def _GetSecondsSinceMidnight(self): |
50 """Returns the seconds since midnight as a decimal value.""" | 52 """Returns the seconds since midnight as a decimal value.""" |
51 now = time.localtime() | 53 now = time.localtime() |
52 return now[3] * 3600 + now[4] * 60 + now[5] | 54 return now[3] * 3600 + now[4] * 60 + now[5] |
53 | 55 |
54 def _GetDefaultBoardID(self): | 56 def _GetDefaultBoardID(self): |
55 """Returns the default board id stored in .default_board.""" | 57 """Returns the default board id stored in .default_board.""" |
56 board_file = '%s/.default_board' % (self.scripts_dir) | 58 board_file = '%s/.default_board' % (self.scripts_dir) |
57 try: | 59 try: |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 def GenerateUpdateFile(self, image_path): | 213 def GenerateUpdateFile(self, image_path): |
212 """Generates an update gz given a full path to an image. | 214 """Generates an update gz given a full path to an image. |
213 | 215 |
214 Args: | 216 Args: |
215 image_path: Full path to image. | 217 image_path: Full path to image. |
216 Returns: | 218 Returns: |
217 Path to created update_payload or None on error. | 219 Path to created update_payload or None on error. |
218 """ | 220 """ |
219 image_dir = os.path.dirname(image_path) | 221 image_dir = os.path.dirname(image_path) |
220 update_path = os.path.join(image_dir, 'update.gz') | 222 update_path = os.path.join(image_dir, 'update.gz') |
| 223 patch_kernel_flag = '--patch_kernel' |
221 _LogMessage('Generating update image %s' % update_path) | 224 _LogMessage('Generating update image %s' % update_path) |
222 | 225 |
| 226 # Don't patch the kernel for vm images as they don't need the patch. |
| 227 if self.vm: |
| 228 patch_kernel_flag = '' |
| 229 |
223 mkupdate_command = ( | 230 mkupdate_command = ( |
224 '%s/cros_generate_update_payload --image="%s" --output="%s" ' | 231 '%s/cros_generate_update_payload --image="%s" --output="%s" ' |
225 '--patch_kernel --noold_style --src_image="%s"' % ( | 232 '%s --noold_style --src_image="%s"' % ( |
226 self.scripts_dir, image_path, | 233 self.scripts_dir, image_path, update_path, patch_kernel_flag, |
227 update_path, self.src_image)) | 234 self.src_image)) |
228 _LogMessage(mkupdate_command) | 235 _LogMessage(mkupdate_command) |
229 if os.system(mkupdate_command) != 0: | 236 if os.system(mkupdate_command) != 0: |
230 _LogMessage('Failed to create base update file') | 237 _LogMessage('Failed to create base update file') |
231 return None | 238 return None |
232 | 239 |
233 return update_path | 240 return update_path |
234 | 241 |
235 def GenerateStatefulFile(self, image_path): | 242 def GenerateStatefulFile(self, image_path): |
236 """Generates a stateful update gz given a full path to an image. | 243 """Generates a stateful update gz given a full path to an image. |
237 | 244 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 is_delta_format = self._IsDeltaFormatFile(filename) | 560 is_delta_format = self._IsDeltaFormatFile(filename) |
554 if label: | 561 if label: |
555 url = '%s/%s/update.gz' % (static_urlbase, label) | 562 url = '%s/%s/update.gz' % (static_urlbase, label) |
556 else: | 563 else: |
557 url = '%s/update.gz' % static_urlbase | 564 url = '%s/update.gz' % static_urlbase |
558 | 565 |
559 _LogMessage('Responding to client to use url %s to get image.' % url) | 566 _LogMessage('Responding to client to use url %s to get image.' % url) |
560 return self.GetUpdatePayload(hash, sha256, size, url, is_delta_format) | 567 return self.GetUpdatePayload(hash, sha256, size, url, is_delta_format) |
561 else: | 568 else: |
562 return self.GetNoUpdatePayload() | 569 return self.GetNoUpdatePayload() |
OLD | NEW |