From 8bec09ee7264160e4e08973a0efcc6bd2c898925 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 30 Nov 2009 15:37:14 -0800 Subject: [PATCH] add 'extras' mechanism to OTA and signing tools Add the -x option which allows arbitrary key-value pairs to be passed into the device-specific module for doing signing and OTA packaging. --- tools/releasetools/common.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 27264dd79..041daf440 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -35,6 +35,7 @@ OPTIONS.max_image_size = {} OPTIONS.verbose = False OPTIONS.tempfiles = [] OPTIONS.device_specific = None +OPTIONS.extras = {} class ExternalError(RuntimeError): pass @@ -259,6 +260,10 @@ COMMON_DOCSTRING = """ Path to the python module containing device-specific releasetools code. + -x (--extra) + Add a key/value pair to the 'extras' dict, which device-specific + extension code may look at. + -v (--verbose) Show command lines being executed. @@ -283,8 +288,8 @@ def ParseOptions(argv, try: opts, args = getopt.getopt( - argv, "hvp:s:" + extra_opts, - ["help", "verbose", "path=", "device_specific="] + + argv, "hvp:s:x:" + extra_opts, + ["help", "verbose", "path=", "device_specific=", "extra="] + list(extra_long_opts)) except getopt.GetoptError, err: Usage(docstring) @@ -303,6 +308,9 @@ def ParseOptions(argv, OPTIONS.search_path = a elif o in ("-s", "--device_specific"): OPTIONS.device_specific = a + elif o in ("-x" "--extra"): + key, value = a.split("=", 1) + OPTIONS.extras[key] = value else: if extra_option_handler is None or not extra_option_handler(o, a): assert False, "unknown option \"%s\"" % (o,) @@ -437,6 +445,7 @@ class DeviceSpecificParams(object): module.""" for k, v in kwargs.iteritems(): setattr(self, k, v) + self.extras = OPTIONS.extras if self.module is None: path = OPTIONS.device_specific