Loading tools/releasetools/sign_target_files_apks.py +9 −15 Original line number Diff line number Diff line Loading @@ -449,7 +449,7 @@ def SignApk(data, keyname, pw, platform_api_level, codename_to_api_level_map, if apk_name in ("Browser.apk", "BrowserWebView.apk"): new_apk = tempfile.NamedTemporaryFile(suffix='_' + apk_name) ReplaceTrichromeLibraryFingerprint(unsigned.name, new_apk.name, keyname, apk_name) ReplaceTrichromeLibraryFingerprint(unsigned.name, new_apk.name, apk_name) unsigned.close() unsigned = new_apk Loading Loading @@ -793,7 +793,7 @@ def ReplaceCerts(data): return data def ReplaceTrichromeLibraryFingerprint(unsigned, new_apk, keyname, apk_name): def ReplaceTrichromeLibraryFingerprint(unsigned, new_apk, apk_name): """Replaces all the occurences of X.509 cert fingerprints with the new ones. The mapping info is read from OPTIONS.key_map. Non-existent certificate will Loading @@ -802,29 +802,23 @@ def ReplaceTrichromeLibraryFingerprint(unsigned, new_apk, keyname, apk_name): Args: unsigned: Path of unsigned apk new_apk: Path of new temporary file keyname: Key used to sign apk apk_name: Name of Trichrome apk Raises: AssertionError: On non-zero return from 'chromium_trichrome_patcher'. """ for old, new in OPTIONS.key_map.items(): # Skip any keys we don't care about if (new != keyname): continue for new in OPTIONS.key_map.items(): if OPTIONS.verbose: print(" Replacing %s.x509.pem with %s.x509.pem" % (old, new)) print(" Replacing with %s.x509.pem" % (new)) try: with open(old + ".x509.pem") as old_fp: old_sha256 = common.ExtractFingerprint(old + ".x509.pem").lower().rstrip() old_sha256 = "32a2fc74d731105859e5a85df16d95f102d85b22099b8064c5d8915c61dad1e0" with open(new + ".x509.pem") as new_fp: new_sha256 = common.ExtractFingerprint(new + ".x509.pem").lower().rstrip() except IOError as e: if OPTIONS.verbose or e.errno != errno.ENOENT: print(" Error accessing %s: %s.\nSkip replacing %s.x509.pem with " "%s.x509.pem." % (e.filename, e.strerror, old, new)) print(" Error accessing %s: %s.\nSkip replacing with " "%s.x509.pem." % (e.filename, e.strerror, new)) continue patched_apk = tempfile.NamedTemporaryFile(suffix='_' + apk_name) Loading @@ -843,8 +837,8 @@ def ReplaceTrichromeLibraryFingerprint(unsigned, new_apk, keyname, apk_name): 'Failed to zipalign Trichrome APK %s\n%s' % (patched_apk, stderrdata) if OPTIONS.verbose: print(" Replaced %s.x509.pem's fingerprint: %s with %s.x509.pem's fingerprint: %s" % (old, old_sha256, new, new_sha256)) print(" Replaced %s with %s.x509.pem's fingerprint: %s" % (old_sha256, new, new_sha256)) def EditTags(tags): """Applies the edits to the tag string as specified in OPTIONS.tag_changes. Loading Loading
tools/releasetools/sign_target_files_apks.py +9 −15 Original line number Diff line number Diff line Loading @@ -449,7 +449,7 @@ def SignApk(data, keyname, pw, platform_api_level, codename_to_api_level_map, if apk_name in ("Browser.apk", "BrowserWebView.apk"): new_apk = tempfile.NamedTemporaryFile(suffix='_' + apk_name) ReplaceTrichromeLibraryFingerprint(unsigned.name, new_apk.name, keyname, apk_name) ReplaceTrichromeLibraryFingerprint(unsigned.name, new_apk.name, apk_name) unsigned.close() unsigned = new_apk Loading Loading @@ -793,7 +793,7 @@ def ReplaceCerts(data): return data def ReplaceTrichromeLibraryFingerprint(unsigned, new_apk, keyname, apk_name): def ReplaceTrichromeLibraryFingerprint(unsigned, new_apk, apk_name): """Replaces all the occurences of X.509 cert fingerprints with the new ones. The mapping info is read from OPTIONS.key_map. Non-existent certificate will Loading @@ -802,29 +802,23 @@ def ReplaceTrichromeLibraryFingerprint(unsigned, new_apk, keyname, apk_name): Args: unsigned: Path of unsigned apk new_apk: Path of new temporary file keyname: Key used to sign apk apk_name: Name of Trichrome apk Raises: AssertionError: On non-zero return from 'chromium_trichrome_patcher'. """ for old, new in OPTIONS.key_map.items(): # Skip any keys we don't care about if (new != keyname): continue for new in OPTIONS.key_map.items(): if OPTIONS.verbose: print(" Replacing %s.x509.pem with %s.x509.pem" % (old, new)) print(" Replacing with %s.x509.pem" % (new)) try: with open(old + ".x509.pem") as old_fp: old_sha256 = common.ExtractFingerprint(old + ".x509.pem").lower().rstrip() old_sha256 = "32a2fc74d731105859e5a85df16d95f102d85b22099b8064c5d8915c61dad1e0" with open(new + ".x509.pem") as new_fp: new_sha256 = common.ExtractFingerprint(new + ".x509.pem").lower().rstrip() except IOError as e: if OPTIONS.verbose or e.errno != errno.ENOENT: print(" Error accessing %s: %s.\nSkip replacing %s.x509.pem with " "%s.x509.pem." % (e.filename, e.strerror, old, new)) print(" Error accessing %s: %s.\nSkip replacing with " "%s.x509.pem." % (e.filename, e.strerror, new)) continue patched_apk = tempfile.NamedTemporaryFile(suffix='_' + apk_name) Loading @@ -843,8 +837,8 @@ def ReplaceTrichromeLibraryFingerprint(unsigned, new_apk, keyname, apk_name): 'Failed to zipalign Trichrome APK %s\n%s' % (patched_apk, stderrdata) if OPTIONS.verbose: print(" Replaced %s.x509.pem's fingerprint: %s with %s.x509.pem's fingerprint: %s" % (old, old_sha256, new, new_sha256)) print(" Replaced %s with %s.x509.pem's fingerprint: %s" % (old_sha256, new, new_sha256)) def EditTags(tags): """Applies the edits to the tag string as specified in OPTIONS.tag_changes. Loading