OSDN Git Service

build: clean up otasigcheck
authorPawit Pornkitprasan <p.pawit@gmail.com>
Wed, 19 Nov 2014 16:22:41 +0000 (23:22 +0700)
committerSteve Kondik <steve@cyngn.com>
Sun, 4 Sep 2016 04:47:36 +0000 (21:47 -0700)
- Only mount and unmount /data if it was originally unmounted
- Don't use comparison hack, just check the result of the script

Change-Id: I4a22485d315cf91e95ce578907c49f5fa3a03222

tools/releasetools/edify_generator.py
tools/releasetools/ota_from_target_files.py

index cd82f65..cadc931 100644 (file)
@@ -183,9 +183,7 @@ class EdifyGenerator(object):
         self.script.append('package_extract_file("system/bin/otasigcheck.sh", "/tmp/otasigcheck.sh");')
         self.script.append('package_extract_file("META-INF/org/cyanogenmod/releasekey", "/tmp/releasekey");')
         self.script.append('set_metadata("/tmp/otasigcheck.sh", "uid", 0, "gid", 0, "mode", 0755);')
-        self.script.append('run_program("/tmp/otasigcheck.sh");')
-        ## Hax: a failure from run_program doesn't trigger an abort, so have it change the key value and check for "INVALID"
-        self.script.append('sha1_check(read_file("/tmp/releasekey"),"7241e92725436afc79389d4fc2333a2aa8c20230") && abort("Can\'t install this package on top of incompatible data. Please try another package or run a factory reset");')
+        self.script.append('run_program("/tmp/otasigcheck.sh") == "0" || 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
index a5b9cb7..4ebd19e 100755 (executable)
@@ -661,9 +661,14 @@ else if get_stage("%(bcb_dev)s") == "3/3" then
   if block_based:
     common.ZipWriteStr(output_zip, "system/bin/otasigcheck.sh",
                    ""+input_zip.read("SYSTEM/bin/otasigcheck.sh"))
+
+  script.AppendExtra("if is_mounted(\"/data\") then")
+  script.ValidateSignatures("data")
+  script.AppendExtra("else")
   script.Mount("/data")
   script.ValidateSignatures("data")
   script.Unmount("/data")
+  script.AppendExtra("endif;")
 
   # Place a copy of file_contexts.bin into the OTA package which will be used
   # by the recovery program.