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/.
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()
14 cert_pairs
= sys
.argv
[4:]
16 if (len(cert_pairs
) % 2) != 0:
17 print("Certs must be provided in pairs")
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
)
28 print("Didn't find {}...".format(find_cert
))
30 if len(updater_data
) != len(new_updater
):
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
: