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

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

Issue 633001: fixup autoupdate for new build system (Closed)
Patch Set: per review comments Created 10 years, 10 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/memento_softwareupdate/ping_omaha.sh » ('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 web 9 import web
10 10
(...skipping 23 matching lines...) Expand all
34 payload = """<?xml version="1.0" encoding="UTF-8"?> 34 payload = """<?xml version="1.0" encoding="UTF-8"?>
35 <gupdate xmlns="http://www.google.com/update2/response" protocol="2.0"> 35 <gupdate xmlns="http://www.google.com/update2/response" protocol="2.0">
36 <app appid="{%s}" status="ok"> 36 <app appid="{%s}" status="ok">
37 <ping status="ok"/> 37 <ping status="ok"/>
38 <updatecheck status="noupdate"/> 38 <updatecheck status="noupdate"/>
39 </app> 39 </app>
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, board_id):
45 cmd = "%s/get_latest_image.sh" % self.scripts_dir 45 cmd = "%s/get_latest_image.sh --board %s" % (self.scripts_dir, board_id)
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 50
51 # Removes the portage build prefix. 51 # Removes the portage build prefix.
52 latest_version = latest_version.lstrip("g-") 52 latest_version = latest_version.lstrip("g-")
53 return latest_version.split('-')[0] 53 return latest_version.split('-')[0]
54 54
55 def CanUpdate(self, client_version, latest_version): 55 def CanUpdate(self, client_version, latest_version):
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 def GetHash(self, update_path): 89 def GetHash(self, update_path):
90 cmd = "cat %s | openssl sha1 -binary | openssl base64 | tr \'\\n\' \' \';" % update_path 90 cmd = "cat %s | openssl sha1 -binary | openssl base64 | tr \'\\n\' \' \';" % update_path
91 web.debug(cmd) 91 web.debug(cmd)
92 return os.popen(cmd).read() 92 return os.popen(cmd).read()
93 93
94 def HandleUpdatePing(self, data): 94 def HandleUpdatePing(self, data):
95 update_dom = minidom.parseString(data) 95 update_dom = minidom.parseString(data)
96 root = update_dom.firstChild 96 root = update_dom.firstChild
97 query = root.getElementsByTagName("o:app")[0] 97 query = root.getElementsByTagName("o:app")[0]
98 client_version = query.attributes['version'].value 98 client_version = query.attributes['version'].value
99 latest_image_path = self.GetLatestImagePath(); 99 board_id = query.attributes['board'].value
100 latest_image_path = self.GetLatestImagePath(board_id);
100 latest_version = self.GetLatestVersion(latest_image_path); 101 latest_version = self.GetLatestVersion(latest_image_path);
101 if client_version != "ForcedUpdate" and not self.CanUpdate(client_version, l atest_version): 102 if client_version != "ForcedUpdate" and not self.CanUpdate(client_version, l atest_version):
102 web.debug("no update") 103 web.debug("no update")
103 return self.GetNoUpdatePayload() 104 return self.GetNoUpdatePayload()
104 105
105 web.debug("update found %s " % latest_version) 106 web.debug("update found %s " % latest_version)
106 ok = self.BuildUpdateImage(latest_image_path) 107 ok = self.BuildUpdateImage(latest_image_path)
107 if ok != True: 108 if ok != True:
108 web.debug("Failed to build an update image") 109 web.debug("Failed to build an update image")
109 return self.GetNoUpdatePayload() 110 return self.GetNoUpdatePayload()
110 111
111 hash = self.GetHash("%s/update.gz" % self.static_dir) 112 hash = self.GetHash("%s/update.gz" % self.static_dir)
112 size = self.GetSize("%s/update.gz" % self.static_dir) 113 size = self.GetSize("%s/update.gz" % self.static_dir)
113 hostname = web.ctx.host 114 hostname = web.ctx.host
114 url = "http://%s/static/update.gz" % hostname 115 url = "http://%s/static/update.gz" % hostname
115 return self.GetUpdatePayload(hash, size, url) 116 return self.GetUpdatePayload(hash, size, url)
116 117
OLDNEW
« no previous file with comments | « no previous file | src/platform/memento_softwareupdate/ping_omaha.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698