summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-02-22 16:07:58 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-02-22 17:18:07 +0100
commit2b9108113d93284cbb84879dbf3d768abe513056 (patch)
treeff81cea63fe72a65a38b27ff7efed1ab236cd083 /scripts
parent2f5ecc979c10239516ac9f9f372310df2a67be82 (diff)
downloadqutebrowser-2b9108113d93284cbb84879dbf3d768abe513056.tar.gz
qutebrowser-2b9108113d93284cbb84879dbf3d768abe513056.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
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dev/build_release.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py
index 060e9ba59..5f739a4dd 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')
@@ -280,9 +297,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 []