Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / tools / update-verify / release / replace-updater-certs.py
blob9e981fbfe0b282f8bcd4ac14cfefdb617e9eddad
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 # You can obtain one at http://mozilla.org/MPL/2.0/.
5 import os.path
6 import sys
8 cert_dir = sys.argv[1]
9 # Read twice, because strings cannot be copied
10 updater_data = open(sys.argv[2], "rb").read()
11 new_updater = open(sys.argv[2], "rb").read()
12 outfile = sys.argv[3]
14 cert_pairs = sys.argv[4:]
16 if (len(cert_pairs) % 2) != 0:
17 print("Certs must be provided in pairs")
18 sys.exit(1)
20 for find_cert, replace_cert in zip(*[iter(cert_pairs)] * 2):
21 find = open(os.path.join(cert_dir, find_cert), "rb").read()
22 replace = open(os.path.join(cert_dir, replace_cert), "rb").read()
23 print("Looking for {}...".format(find_cert))
24 if find in new_updater:
25 print("Replacing {} with {}".format(find_cert, replace_cert))
26 new_updater = new_updater.replace(find, replace)
27 else:
28 print("Didn't find {}...".format(find_cert))
30 if len(updater_data) != len(new_updater):
31 print(
32 "WARNING: new updater is not the same length as the old one (old: {}, new: {})".format(
33 len(updater_data), len(new_updater)
37 if updater_data == new_updater:
38 print("WARNING: updater is unchanged")
40 with open(outfile, "wb+") as f:
41 f.write(new_updater)