author Chris AtLee <>
Mon, 01 Apr 2019 17:26:27 +0000
changeset 8471 a41a482b78763e8159c9b3407a2e7dd37ce8d583
parent 8454 b04a81e9c98cdd15f09ad90a8b5d44eed555ba73
permissions -rwxr-xr-x
Bug 1531165: Remove jar signing support, and signscript imports r=aki Differential Revision:

import os.path
import sys

cert_dir = sys.argv[1]
# Read twice, because strings cannot be copied
updater_data = open(sys.argv[2], "rb").read()
new_updater = open(sys.argv[2], "rb").read()
outfile = sys.argv[3]

cert_pairs = sys.argv[4:]

if (len(cert_pairs) % 2) != 0:
    print("Certs must be provided in pairs")

for find_cert, replace_cert in zip(*[iter(cert_pairs)]*2):
    find = open(os.path.join(cert_dir, find_cert), "rb").read()
    replace = open(os.path.join(cert_dir, replace_cert), "rb").read()
    print("Looking for {}...".format(find_cert))
    if find in new_updater:
        print("Replacing {} with {}".format(find_cert, replace_cert))
        new_updater = new_updater.replace(find, replace)
        print("Didn't find {}...".format(find_cert))

if len(updater_data) != len(new_updater):
    print("WARNING: new updater is not the same length as the old one (old: {}, new: {})".format(len(updater_data), len(new_updater)))

if updater_data == new_updater:
    print("WARNING: updater is unchanged")

with open(outfile, 'wb+') as f: