autoupdate.py: Fix the base URL path sent to nebraska
It seems like we're not sending the correct base URL to nebraska after
last few changes in autoupate and xbuddy modules. This CL should fix the
issue with properly handling build ids and paths.
BUG=chromium:1149703
TEST=started devsever with:
$ ./devserver.py --static_dir=/mnt/host/source/src/platform/dev/static/
Then requested for update with:
$ curl -X POST -d @/mnt/host/source/images/request.xml 'http://localhost:8080/update/reef-release/R88-13591.0.0?full_payload=False&critical_update=True'
The response was:
<?xml version="1.0" encoding="UTF-8"?>
<response protocol="3.0" server="nebraska">
<daystart elapsed_days="5086" elapsed_seconds="39234"/>
<app appid="{8396029B-FCEF-9EEC-C684-3BCB8E3E9429}" status="ok">
<event status="ok"/>
<updatecheck status="ok">
<urls>
<url codebase="http://localhost:8080/static/reef-release/R88-13591.0.0/"/>
</urls>
<manifest version="99999.0.0">
<actions>
<action event="update" run="chromeos_R88-13591.0.0_R88-13591.0.0_reef_delta_dev.bin"/>
<action ChromeOSVersion="99999.0.0" ChromeVersion="1.0.0.0" DisablePayloadBackoff="false" IsDeltaPayload="true" MaxDaysToScatter="14" MetadataSignatureRsa="" MetadataSize="193398" deadline="now" event="postinstall" sha256="/uBojSmGb+pp0/p3qccJEOHCjN5ZAu6NEMWyBl4pggg="/>
</actions>
<packages>
<package fp="1.FEE0688D29866FEA69D3FA77A9C70910E1C28CDE5902EE8D10C5B2065E298208" hash_sha256="FEE0688D29866FEA69D3FA77A9C70910E1C28CDE5902EE8D10C5B2065E298208" name="chromeos_R88-13591.0.0_R88-13591.0.0_reef_delta_dev.bin" required="true" size="193398"/>
</packages>
</manifest>
</updatecheck>
</app>
</response>
which has the correct codebase in the <url> tag.
Then downloaded the image with:
$ wget http://localhost:8080/static/reef-release/R88-13591.0.0/chromeos_R88-13591.0.0_R88-13591.0.0_reef_delta_dev.bin
Change-Id: I3d96223257ee04e8d47cf52d0364138116070bff
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2575496
Tested-by: Amin Hassani <ahassani@chromium.org>
Auto-Submit: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Keith Haddow <haddowk@chromium.org>
diff --git a/autoupdate.py b/autoupdate.py
index b567e11..001959b 100644
--- a/autoupdate.py
+++ b/autoupdate.py
@@ -91,31 +91,26 @@
_Log('Using static url base %s', static_urlbase)
return static_urlbase
- def GetPathToPayload(self, label, board):
- """Find a payload locally.
-
- See devserver's update rpc for documentation.
+ def GetBuildID(self, label, board):
+ """Find the build id of the given lable and board.
Args:
label: from update request
board: from update request
Returns:
- The relative path to an update from the static_dir
+ The build id of given label and board. e.g. reef-release/R88-13591.0.0
Raises:
AutoupdateError: If the update could not be found.
"""
label = label or ''
label_list = label.split('/')
- # There was no update found in the directory. Let XBuddy find the
- # payloads.
if label_list[0] == 'xbuddy':
# If path explicitly calls xbuddy, pop off the tag.
label_list.pop()
x_label, _ = self.xbuddy.Translate(label_list, board=board)
- # Path has been resolved, try to get the payload.
- return _NonePathJoin(self.static_dir, x_label)
+ return x_label
def HandleUpdatePing(self, data, label='', **kwargs):
"""Handles an update ping from an update client.
@@ -128,9 +123,6 @@
Returns:
Update payload message for client.
"""
- # Get the static url base that will form that base of our update url e.g.
- # http://hostname:8080/static/update.gz.
- static_urlbase = self.GetStaticUrl()
# Change the URL's string query dictionary provided by cherrypy to a valid
# dictionary that has proper values for its keys. e.g. True instead of
# 'True'.
@@ -146,9 +138,9 @@
_Log('Update Check Received.')
try:
- path_to_payload = self.GetPathToPayload(label, request.board)
- base_url = _NonePathJoin(static_urlbase, path_to_payload)
- local_payload_dir = _NonePathJoin(self.static_dir, path_to_payload)
+ build_id = self.GetBuildID(label, request.board)
+ base_url = '/'.join((self.GetStaticUrl(), build_id))
+ local_payload_dir = _NonePathJoin(self.static_dir, build_id)
except AutoupdateError as e:
# Raised if we fail to generate an update payload.
_Log('Failed to process an update request, but we will defer to '