Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/platform/dev/autoupdate.py

Issue 2392002: Quiet down stateful_update & add timeout for downloads. (Closed) Base URL: ssh://git@chromiumos-git//chromeos
Patch Set: fixes to autoupdate to work with memento_updater and autotest. Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/platform/dev/stateful_update » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 shutil 9 import shutil
10 import sys 10 import sys
11 import web 11 import web
12 12
13 class Autoupdate(BuildObject): 13 class Autoupdate(BuildObject):
14 # Basic functionality of handling ChromeOS autoupdate pings 14 # Basic functionality of handling ChromeOS autoupdate pings
15 # and building/serving update images. 15 # and building/serving update images.
16 # TODO(rtc): Clean this code up and write some tests. 16 # TODO(rtc): Clean this code up and write some tests.
17 17
18 def __init__(self, serve_only=None, test_image=False, urlbase=None, 18 def __init__(self, serve_only=None, test_image=False, urlbase=None,
19 factory_config_path=None, validate_factory_config=None, 19 factory_config_path=None, validate_factory_config=None,
20 *args, **kwargs): 20 *args, **kwargs):
21 super(Autoupdate, self).__init__(*args, **kwargs) 21 super(Autoupdate, self).__init__(*args, **kwargs)
22 self.serve_only = serve_only 22 self.serve_only = serve_only
23 self.factory_config = factory_config_path
23 self.test_image = test_image 24 self.test_image = test_image
24 self.static_urlbase = urlbase 25 self.static_urlbase = urlbase
25 if serve_only: 26 if serve_only:
26 # If we're serving out of an archived build dir (e.g. a 27 # If we're serving out of an archived build dir (e.g. a
27 # buildbot), prepare this webserver's magic 'static/' dir with a 28 # buildbot), prepare this webserver's magic 'static/' dir with a
28 # link to the build archive. 29 # link to the build archive.
29 web.debug('Autoupdate in "serve update images only" mode.') 30 web.debug('Autoupdate in "serve update images only" mode.')
30 if os.path.exists('static/archive'): 31 if os.path.exists('static/archive'):
31 archive_symlink = os.readlink('static/archive') 32 if self.static_dir != os.readlink('static/archive'):
32 if archive_symlink != self.static_dir:
33 web.debug('removing stale symlink to %s' % self.static_dir) 33 web.debug('removing stale symlink to %s' % self.static_dir)
34 os.unlink('static/archive') 34 os.unlink('static/archive')
35 os.symlink(self.static_dir, 'static/archive')
35 else: 36 else:
36 os.symlink(self.static_dir, 'static/archive') 37 os.symlink(self.static_dir, 'static/archive')
37 self.factory_config = None
38 if factory_config_path is not None: 38 if factory_config_path is not None:
39 self.ImportFactoryConfigFile(factory_config_path, validate_factory_config) 39 self.ImportFactoryConfigFile(factory_config_path, validate_factory_config)
40 40
41 def GetUpdatePayload(self, hash, size, url): 41 def GetUpdatePayload(self, hash, size, url):
42 payload = """<?xml version="1.0" encoding="UTF-8"?> 42 payload = """<?xml version="1.0" encoding="UTF-8"?>
43 <gupdate xmlns="http://www.google.com/update2/response" protocol="2.0"> 43 <gupdate xmlns="http://www.google.com/update2/response" protocol="2.0">
44 <app appid="{%s}" status="ok"> 44 <app appid="{%s}" status="ok">
45 <ping status="ok"/> 45 <ping status="ok"/>
46 <updatecheck 46 <updatecheck
47 codebase="%s" 47 codebase="%s"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 shutil.move(os.path.join(image_path, 'part_3'), rootfs_file) 100 shutil.move(os.path.join(image_path, 'part_3'), rootfs_file)
101 os.system('cd %s && rm part_*' % image_path) 101 os.system('cd %s && rm part_*' % image_path)
102 return True 102 return True
103 return False 103 return False
104 104
105 def UnpackZip(self, image_path, image_file): 105 def UnpackZip(self, image_path, image_file):
106 image = os.path.join(image_path, image_file) 106 image = os.path.join(image_path, image_file)
107 if os.path.exists(image): 107 if os.path.exists(image):
108 return True 108 return True
109 else: 109 else:
110 return os.system('cd %s && unzip -o image.zip %s unpack_partitions.sh' % 110 # -n, never clobber an existing file, in case we get invoked
111 # simultaneously by multiple request handlers. This means that
112 # we're assuming each image.zip file lives in a versioned
113 # directory (a la Buildbot).
114 return os.system('cd %s && unzip -n image.zip %s unpack_partitions.sh' %
111 (image_path, image_file)) == 0 115 (image_path, image_file)) == 0
112 116
113 def GetImageBinPath(self, image_path): 117 def GetImageBinPath(self, image_path):
114 if self.test_image: 118 if self.test_image:
115 image_file = 'chromiumos_test_image.bin' 119 image_file = 'chromiumos_test_image.bin'
116 else: 120 else:
117 image_file = 'chromiumos_image.bin' 121 image_file = 'chromiumos_image.bin'
118 return image_file 122 return image_file
119 123
120 def BuildUpdateImage(self, image_path): 124 def BuildUpdateImage(self, image_path):
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 ok = self.BuildUpdateImage(latest_image_path) 335 ok = self.BuildUpdateImage(latest_image_path)
332 if ok != True: 336 if ok != True:
333 web.debug('Failed to build an update image') 337 web.debug('Failed to build an update image')
334 return self.GetNoUpdatePayload() 338 return self.GetNoUpdatePayload()
335 339
336 hash = self.GetHash('%s/update.gz' % self.static_dir) 340 hash = self.GetHash('%s/update.gz' % self.static_dir)
337 size = self.GetSize('%s/update.gz' % self.static_dir) 341 size = self.GetSize('%s/update.gz' % self.static_dir)
338 342
339 url = 'http://%s/static/update.gz' % hostname 343 url = 'http://%s/static/update.gz' % hostname
340 return self.GetUpdatePayload(hash, size, url) 344 return self.GetUpdatePayload(hash, size, url)
OLDNEW
« no previous file with comments | « no previous file | src/platform/dev/stateful_update » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698