diff options
author | Doug Zongker <dougz@android.com> | 2013-06-03 12:07:12 -0700 |
---|---|---|
committer | Doug Zongker <dougz@android.com> | 2013-06-03 12:07:12 -0700 |
commit | 0d92f1f13ad89bf8ffbb75764bbe83452612792a (patch) | |
tree | 127501629bde6c208518bc3c13aa95f0e7fa068e /tools/releasetools/edify_generator.py | |
parent | 8216f3228fbe5343b38e19f51fb91584946024cc (diff) | |
download | build-0d92f1f13ad89bf8ffbb75764bbe83452612792a.zip build-0d92f1f13ad89bf8ffbb75764bbe83452612792a.tar.gz build-0d92f1f13ad89bf8ffbb75764bbe83452612792a.tar.bz2 |
improve OTA failure messages
Replace OTA script constructs of the form:
assert(foo);
with
foo || abort("sensible message");
so that the log and the on-screen display is somewhat more accessible
to non-experts. (assert() displays the source code of the false
expression 'foo'.)
Change-Id: Ic99448e4466561d305b167cd4d5c1f0f2dbadcce
Diffstat (limited to 'tools/releasetools/edify_generator.py')
-rw-r--r-- | tools/releasetools/edify_generator.py | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py index 5672b5a..9ef1926 100644 --- a/tools/releasetools/edify_generator.py +++ b/tools/releasetools/edify_generator.py @@ -72,24 +72,31 @@ class EdifyGenerator(object): """Assert that the current system build fingerprint is one of *fp.""" if not fp: raise ValueError("must specify some fingerprints") - cmd = ('assert(' + - ' ||\0'.join([('file_getprop("/system/build.prop", ' + cmd = ( + ' ||\n '.join([('file_getprop("/system/build.prop", ' '"ro.build.fingerprint") == "%s"') % i for i in fp]) + - ');') - self.script.append(self._WordWrap(cmd)) + ' ||\n abort("Package expects build fingerprint of %s; this ' + 'device has " + getprop("ro.build.fingerprint") + ".");' + ) % (" or ".join(fp),) + self.script.append(cmd) - def AssertOlderBuild(self, timestamp): + def AssertOlderBuild(self, timestamp, timestamp_text): """Assert that the build on the device is older (or the same as) the given timestamp.""" - self.script.append(('assert(!less_than_int(%s, ' - 'getprop("ro.build.date.utc")));') % (timestamp,)) + self.script.append( + ('(!less_than_int(%s, getprop("ro.build.date.utc"))) || ' + 'abort("Can\'t install this package (%s) over newer ' + 'build (" + getprop("ro.build.date") + ").");' + ) % (timestamp, timestamp_text)) def AssertDevice(self, device): """Assert that the device identifier is the given string.""" - cmd = ('assert(getprop("ro.product.device") == "%s" ||\0' - 'getprop("ro.build.product") == "%s");' % (device, device)) - self.script.append(self._WordWrap(cmd)) + cmd = ('getprop("ro.product.device") == "%s" || ' + 'abort("This package is for \\"%s\\" devices; ' + 'this is a \\"" + getprop("ro.product.device") + "\\".");' + ) % (device, device) + self.script.append(cmd) def AssertSomeBootloader(self, *bootloaders): """Asert that the bootloader version is one of *bootloaders.""" @@ -115,9 +122,10 @@ class EdifyGenerator(object): """Check that the given file (or MTD reference) has one of the given *sha1 hashes, checking the version saved in cache if the file does not match.""" - self.script.append('assert(apply_patch_check("%s"' % (filename,) + - "".join([', "%s"' % (i,) for i in sha1]) + - '));') + self.script.append( + 'apply_patch_check("%s"' % (filename,) + + "".join([', "%s"' % (i,) for i in sha1]) + + ') || abort("\\"%s\\" has unexpected contents.");' % (filename,)) def FileCheck(self, filename, *sha1): """Check that the given file (or MTD reference) has one of the @@ -129,7 +137,8 @@ class EdifyGenerator(object): def CacheFreeSpaceCheck(self, amount): """Check that there's at least 'amount' space that can be made available on /cache.""" - self.script.append("assert(apply_patch_space(%d));" % (amount,)) + self.script.append(('apply_patch_space(%d) || abort("Not enough free space ' + 'on /system to apply patches.");') % (amount,)) def Mount(self, mount_point): """Mount the partition with the given mount_point.""" |