Add --critical_update option to devserver
The option can be used to test auto update in the OOBE screen.
By default, devserver generates non-critical updates, hence
the updates are skipped in the OOBE screen. With this option,
you can force an update in the OOBE screen.
BUG=chromium-os:16564
TEST=cros_workon start cros-devutils --host; sudo emerge cros-devutils; ./start_devserveri --critical_update; update works with and without the option.
Change-Id: I0d3cc3881398d56ebd8c6efa1c6fec00003bf16f
Reviewed-on: https://gerrit.chromium.org/gerrit/11705
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Ready: Satoru Takabayashi <satorux@chromium.org>
Tested-by: Satoru Takabayashi <satorux@chromium.org>
diff --git a/autoupdate.py b/autoupdate.py
index 719d9bf..8e61dab 100644
--- a/autoupdate.py
+++ b/autoupdate.py
@@ -6,6 +6,7 @@
from xml.dom import minidom
import cherrypy
+import datetime
import json
import os
import shutil
@@ -64,6 +65,7 @@
forced_image=None, forced_payload=None,
port=8080, proxy_port=None, src_image='', vm=False, board=None,
copy_to_static_root=True, private_key=None,
+ critical_update=False,
*args, **kwargs):
super(Autoupdate, self).__init__(*args, **kwargs)
self.serve_only = serve_only
@@ -82,6 +84,7 @@
self.board = board
self.copy_to_static_root = copy_to_static_root
self.private_key = private_key
+ self.critical_update = critical_update
# Path to pre-generated file.
self.pregenerated_path = None
@@ -234,12 +237,23 @@
needsadmin="false"
size="%s"
IsDelta="%s"
- status="ok"/>
+ status="ok"
+ %s/>
</app>
</gupdate>
"""
- return payload % (self._GetSecondsSinceMidnight(),
- self.app_id, url, hash, sha256, size, delta)
+ extra_attributes = []
+ if self.critical_update:
+ # The date string looks like '20111115' (2011-11-15). As of writing,
+ # there's no particular format for the deadline value that the
+ # client expects -- it's just empty vs. non-empty.
+ date_str = datetime.date.today().strftime('%Y%m%d')
+ extra_attributes.append('deadline="%s"' % date_str)
+ xml = payload % (self._GetSecondsSinceMidnight(),
+ self.app_id, url, hash, sha256, size, delta,
+ ' '.join(extra_attributes))
+ _LogMessage('Generated update payload: %s' % xml)
+ return xml
def GetNoUpdatePayload(self):
"""Returns a payload to the client corresponding to no update."""