diff options
Diffstat (limited to 'tools/releasetools/edify_generator.py')
-rw-r--r-- | tools/releasetools/edify_generator.py | 64 |
1 files changed, 49 insertions, 15 deletions
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py index a52e328..825a7eb 100644 --- a/tools/releasetools/edify_generator.py +++ b/tools/releasetools/edify_generator.py @@ -117,20 +117,44 @@ class EdifyGenerator(object): def AssertDevice(self, device): """Assert that the device identifier is the given string.""" - cmd = ('getprop("ro.product.device") == "%s" || ' - 'abort("This package is for \\"%s\\" devices; ' - 'this is a \\"" + getprop("ro.product.device") + "\\".");') % ( - device, device) + cmd = ('assert(' + + ' || '.join(['getprop("ro.product.device") == "%s" || getprop("ro.build.product") == "%s"' + % (i, i) for i in device.split(",")]) + + ' || abort("This package is for device: %s; ' + + 'this device is " + getprop("ro.product.device") + ".");' + + ');') % device self.script.append(cmd) def AssertSomeBootloader(self, *bootloaders): - """Asert that the bootloader version is one of *bootloaders.""" + """Assert that the bootloader version is one of *bootloaders.""" cmd = ("assert(" + - " ||\0".join(['getprop("ro.bootloader") == "%s"' % (b,) + " || ".join(['getprop("ro.bootloader") == "%s"' % (b,) for b in bootloaders]) + + ' || abort("This package supports bootloader(s): ' + + ", ".join(["%s" % (b,) for b in bootloaders]) + + '; this device has bootloader " + getprop("ro.bootloader") + ".");' + ");") self.script.append(self.WordWrap(cmd)) + def AssertSomeBaseband(self, *basebands): + """Assert that the baseband version is one of *basebands.""" + cmd = ("assert(" + + " || ".join(['getprop("ro.baseband") == "%s"' % (b,) + for b in basebands]) + + ' || abort("This package supports baseband(s): ' + + ", ".join(["%s" % (b,) for b in basebands]) + + '; this device has baseband " + getprop("ro.baseband") + ".");' + + ");") + self.script.append(self.WordWrap(cmd)) + + def RunBackup(self, command): + self.script.append(('run_program("/tmp/install/bin/backuptool.sh", "%s");' % command)) + + def ValidateSignatures(self, command): + self.script.append('package_extract_file("META-INF/org/cyanogenmod/releasekey", "/tmp/releasekey");') + # Exit code 124 == abort. run_program returns raw, so left-shift 8bit + self.script.append('run_program("/tmp/install/bin/otasigcheck.sh") != "31744" || abort("Can\'t install this package on top of incompatible data. Please try another package or run a factory reset");') + def ShowProgress(self, frac, dur): """Update the progress bar, advancing it over 'frac' over the next 'dur' seconds. 'dur' may be zero to advance it via SetProgress @@ -189,6 +213,12 @@ class EdifyGenerator(object): p.mount_point, mount_flags)) self.mounts.add(p.mount_point) + def Unmount(self, mount_point): + """Unmount the partiiton with the given mount_point.""" + if mount_point in self.mounts: + self.mounts.remove(mount_point) + self.script.append('unmount("%s");' % (mount_point,)) + def UnpackPackageDir(self, src, dst): """Unpack a given directory from the OTA package into the given destination directory.""" @@ -293,6 +323,10 @@ class EdifyGenerator(object): self.script.append( 'write_raw_image(package_extract_file("%(fn)s"), "%(device)s");' % args) + elif partition_type == "OSIP": + self.script.append( + 'write_osip_image(package_extract_file("%(fn)s"), "%(device)s");' + % args) elif partition_type == "EMMC": if mapfn: args["map"] = mapfn @@ -310,10 +344,10 @@ class EdifyGenerator(object): if not self.info.get("use_set_metadata", False): self.script.append('set_perm(%d, %d, 0%o, "%s");' % (uid, gid, mode, fn)) else: - if capabilities is None: - capabilities = "0x0" - cmd = 'set_metadata("%s", "uid", %d, "gid", %d, "mode", 0%o, ' \ - '"capabilities", %s' % (fn, uid, gid, mode, capabilities) + cmd = 'set_metadata("%s", "uid", %d, "gid", %d, "mode", 0%o' \ + % (fn, uid, gid, mode) + if capabilities is not None: + cmd += ', "capabilities", %s' % ( capabilities ) if selabel is not None: cmd += ', "selabel", "%s"' % selabel cmd += ');' @@ -326,11 +360,11 @@ class EdifyGenerator(object): self.script.append('set_perm_recursive(%d, %d, 0%o, 0%o, "%s");' % (uid, gid, dmode, fmode, fn)) else: - if capabilities is None: - capabilities = "0x0" cmd = 'set_metadata_recursive("%s", "uid", %d, "gid", %d, ' \ - '"dmode", 0%o, "fmode", 0%o, "capabilities", %s' \ - % (fn, uid, gid, dmode, fmode, capabilities) + '"dmode", 0%o, "fmode", 0%o' \ + % (fn, uid, gid, dmode, fmode) + if capabilities is not None: + cmd += ', "capabilities", "%s"' % ( capabilities ) if selabel is not None: cmd += ', "selabel", "%s"' % selabel cmd += ');' @@ -342,7 +376,7 @@ class EdifyGenerator(object): for d, l in symlink_list: by_dest.setdefault(d, []).append(l) - for dest, links in sorted(by_dest.iteritems()): + for dest, links in sorted(by_dest.items()): cmd = ('symlink("%s", ' % (dest,) + ",\0".join(['"' + i + '"' for i in sorted(links)]) + ");") self.script.append(self.WordWrap(cmd)) |