diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-02-22 16:07:58 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-02-22 17:20:05 +0100 |
commit | 449fbb94ac9515d6084361c9a3a2e0189249d79a (patch) | |
tree | 0a6fa3c1357f8429649ef14d608a022d5b6e0572 | |
parent | f11cdd0bfe86ab6542dc3e25b15fd7529681e9c0 (diff) | |
download | qutebrowser-449fbb94ac9515d6084361c9a3a2e0189249d79a.tar.gz qutebrowser-449fbb94ac9515d6084361c9a3a2e0189249d79a.zip |
scripts: Fix PE checksum for Windows releases
This should help with virus scanner false positives.
See https://github.com/pyinstaller/pyinstaller/issues/5579
Fixes #6081
Fixes #6194
(cherry picked from commit 2b9108113d93284cbb84879dbf3d768abe513056)
-rwxr-xr-x | scripts/dev/build_release.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index fd26224de..4ab9f499e 100755 --- a/scripts/dev/build_release.py +++ b/scripts/dev/build_release.py @@ -143,6 +143,23 @@ def smoke_test(executable): raise Exception("Unexpected stderr:\n{}".format(stderr)) +def patch_windows_exe(exe_path): + """Make sure the Windows .exe has a correct checksum. + + WORKAROUND for https://github.com/pyinstaller/pyinstaller/issues/5579 + """ + import pefile + pe = pefile.PE(exe_path) + + # If this fails, a PyInstaller upgrade fixed things, and we can remove the + # workaround. Would be a good idea to keep the check, though. + assert not pe.verify_checksum() + + pe.OPTIONAL_HEADER.CheckSum = pe.generate_checksum() + pe.close() + pe.write(exe_path) + + def patch_mac_app(): """Patch .app to use our Info.plist and save some space.""" app_path = os.path.join('dist', 'qutebrowser.app') @@ -279,9 +296,13 @@ def _build_windows_single(*, x64, skip_packaging): out_pyinstaller = os.path.join('dist', 'qutebrowser') shutil.move(out_pyinstaller, outdir) + exe_path = os.path.join(outdir, 'qutebrowser.exe') + + utils.print_title(f"Patching {human_arch} exe") + patch_windows_exe(exe_path) utils.print_title(f"Running {human_arch} smoke test") - smoke_test(os.path.join(outdir, 'qutebrowser.exe')) + smoke_test(exe_path) if skip_packaging: return [] |