From 7d945817a31e06389f2e70b4f3295a39692c9d4f Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Wed, 24 Nov 2021 11:02:17 -0800 Subject: [PATCH 1/7] Change version to 0.3.dev1 --- pyproject.toml | 2 +- share/version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b9a2b4c..20cf6f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dangerzone" -version = "0.3" +version = "0.3.dev1" description = "Take potentially dangerous PDFs, office documents, or images and convert them to a safe PDF" authors = ["Micah Lee "] license = "MIT" diff --git a/share/version.txt b/share/version.txt index be58634..f794674 100644 --- a/share/version.txt +++ b/share/version.txt @@ -1 +1 @@ -0.3 +0.3.dev1 From 457292204255a3760043ee6c31028ddf30bc4a34 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Wed, 24 Nov 2021 11:42:02 -0800 Subject: [PATCH 2/7] Update Windows code signing --- BUILD.md | 15 +++++++-------- install/windows/step1-build-exe.bat | 2 +- install/windows/step2-make-symlink.bat | 2 +- install/windows/step3-build-installer.bat | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/BUILD.md b/BUILD.md index 037286c..e21bfe6 100644 --- a/BUILD.md +++ b/BUILD.md @@ -152,21 +152,21 @@ Dangerzone uses PyInstaller to turn the python source code into Windows executab Here's how to compile the PyInstaller bootloader: -Download and install [Microsoft Build Tools for Visual Studio 2019](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2019). I downloaded `vs_buildtools__719988613.1603831511.exe`. In the installer, check the box next to "C++ build tools". Click "Individual components", and under "Compilers, build tools and runtimes", check "Windows Universal CRT SDK". Then click install. When installation is done, you may have to reboot your computer. +Download and install [Microsoft Build Tools for Visual Studio 2022](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022). I downloaded `vs_BuildTools.exe`. In the installer, check the box next to "Desktop development with C++". Click "Individual components", and under "Compilers, build tools and runtimes", check "Windows Universal CRT SDK". Then click install. When installation is done, you may have to reboot your computer. Then, enable the 32-bit Visual C++ Toolset on the Command Line like this: ``` -cd "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build" -vcvars32.bat +cd 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build' +.\vcvars32.bat ``` -Change to a folder where you keep source code, and clone the PyInstaller git repo and checkout the `v4.3` tag: +Change to a folder where you keep source code, and clone the PyInstaller git repo and checkout the `v4.7` tag: ``` git clone https://github.com/pyinstaller/pyinstaller.git cd pyinstaller -git checkout v4.3 +git checkout v4.7 ``` The next step is to compile the bootloader. We should do this all in dangerzone's poetry shell: @@ -180,7 +180,7 @@ cd ..\pyinstaller Then, compile the bootloader: ``` -cd bootloader +cd .\bootloader\ python waf distclean all --target-arch=32bit --msvc_targets=x86 cd .. ``` @@ -202,8 +202,7 @@ Now the next time you use PyInstaller to build dangerzone, the `.exe` file shoul ### If you want to sign binaries with Authenticode -* You'll need a code signing certificate. I got an open source code signing certificate from [Certum](https://www.certum.eu/certum/cert,offer_en_open_source_cs.xml). -* Once you get a code signing key and certificate and covert it to a pfx file, import it into your certificate store. +You'll need a code signing certificate. ## To make a .exe diff --git a/install/windows/step1-build-exe.bat b/install/windows/step1-build-exe.bat index dacc95a..ea22b6a 100644 --- a/install/windows/step1-build-exe.bat +++ b/install/windows/step1-build-exe.bat @@ -6,4 +6,4 @@ REM build the exe with pyinstaller pyinstaller install\pyinstaller\pyinstaller.spec REM code sign dangerzone.exe -signtool.exe sign /v /d "Dangerzone" /a /tr http://time.certum.pl/ dist\dangerzone\dangerzone.exe +signtool.exe sign /v /d "Dangerzone" /sha1 28a4af3b6ba5ed0ef307e1b96a140e1b42450c3b /tr http://timestamp.digicert.com dist\dangerzone\dangerzone.exe diff --git a/install/windows/step2-make-symlink.bat b/install/windows/step2-make-symlink.bat index 1f17c58..2727b03 100644 --- a/install/windows/step2-make-symlink.bat +++ b/install/windows/step2-make-symlink.bat @@ -1,4 +1,4 @@ REM make dangerzone-container.exe symbolic link (as administrator) cd dist\dangerzone -mklink dangerzone-container.exe dangerzone.exe +mklink dangerzone-cli.exe dangerzone.exe cd ..\.. \ No newline at end of file diff --git a/install/windows/step3-build-installer.bat b/install/windows/step3-build-installer.bat index 70463c7..f3667ca 100644 --- a/install/windows/step3-build-installer.bat +++ b/install/windows/step3-build-installer.bat @@ -9,7 +9,7 @@ candle.exe ..\..\install\windows\Dangerzone.wxs light.exe -ext WixUIExtension Dangerzone.wixobj REM code sign dangerzone.msi -signtool.exe sign /v /d "Dangerzone" /a /tr http://time.certum.pl/ Dangerzone.msi +signtool.exe sign /v /d "Dangerzone" /sha1 28a4af3b6ba5ed0ef307e1b96a140e1b42450c3b /tr http://timestamp.digicert.com Dangerzone.msi REM moving Dangerzone.msi to dist cd ..\.. From 61839f5b2448d804e89dfc6dd138fc1bcdfba64e Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Wed, 24 Nov 2021 12:21:38 -0800 Subject: [PATCH 3/7] Change multistep windows build into one step --- BUILD.md | 18 ++---------------- ...step3-build-installer.bat => build-app.bat} | 10 ++++++++++ install/windows/step1-build-exe.bat | 9 --------- install/windows/step2-make-symlink.bat | 4 ---- 4 files changed, 12 insertions(+), 29 deletions(-) rename install/windows/{step3-build-installer.bat => build-app.bat} (58%) delete mode 100644 install/windows/step1-build-exe.bat delete mode 100644 install/windows/step2-make-symlink.bat diff --git a/BUILD.md b/BUILD.md index e21bfe6..7885d8f 100644 --- a/BUILD.md +++ b/BUILD.md @@ -223,24 +223,10 @@ mklink dangerzone-container.exe dangerzone.exe ### To build the installer -Note that you must have a codesigning certificate installed in order to use the `install\windows\build.bat` script, because it codesigns `dangerzone.exe` and `Dangerzone.msi`. - -Open a command prompt, cd to the dangerzone directory, and run: +Note that you must have a codesigning certificate installed in order to use the `install\windows\build-app.bat` script, because it codesigns `dangerzone.exe` and `Dangerzone.msi`. ``` -poetry run install\windows\step1-build-exe.bat -``` - -Open a second command prompt _as an administratror_, cd to the dangerzone directory, and run: - -``` -install\windows\step2-make-symlink.bat -``` - -Then back in the first command prompt, run: - -``` -poetry run install\windows\step3-build-installer.bat +poetry run .\install\windows\build-app.bat ``` When you're done you will have `dist\Dangerzone.msi`. diff --git a/install/windows/step3-build-installer.bat b/install/windows/build-app.bat similarity index 58% rename from install/windows/step3-build-installer.bat rename to install/windows/build-app.bat index f3667ca..a2df1d1 100644 --- a/install/windows/step3-build-installer.bat +++ b/install/windows/build-app.bat @@ -1,3 +1,13 @@ +REM delete old dist and build files +rmdir /s /q dist +rmdir /s /q build + +REM build the exe with pyinstaller +pyinstaller install\pyinstaller\pyinstaller.spec + +REM code sign dangerzone.exe +signtool.exe sign /v /d "Dangerzone" /sha1 28a4af3b6ba5ed0ef307e1b96a140e1b42450c3b /tr http://timestamp.digicert.com dist\dangerzone\dangerzone.exe + REM build the wix file python install\windows\build-wxs.py > install\windows\Dangerzone.wxs diff --git a/install/windows/step1-build-exe.bat b/install/windows/step1-build-exe.bat deleted file mode 100644 index ea22b6a..0000000 --- a/install/windows/step1-build-exe.bat +++ /dev/null @@ -1,9 +0,0 @@ -REM delete old dist and build files -rmdir /s /q dist -rmdir /s /q build - -REM build the exe with pyinstaller -pyinstaller install\pyinstaller\pyinstaller.spec - -REM code sign dangerzone.exe -signtool.exe sign /v /d "Dangerzone" /sha1 28a4af3b6ba5ed0ef307e1b96a140e1b42450c3b /tr http://timestamp.digicert.com dist\dangerzone\dangerzone.exe diff --git a/install/windows/step2-make-symlink.bat b/install/windows/step2-make-symlink.bat deleted file mode 100644 index 2727b03..0000000 --- a/install/windows/step2-make-symlink.bat +++ /dev/null @@ -1,4 +0,0 @@ -REM make dangerzone-container.exe symbolic link (as administrator) -cd dist\dangerzone -mklink dangerzone-cli.exe dangerzone.exe -cd ..\.. \ No newline at end of file From e5da385eef21d7bf1525ad06e981013a5a57f4eb Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Wed, 24 Nov 2021 12:25:45 -0800 Subject: [PATCH 4/7] In Windows, suppress extra window from popping up in subprocess --- dangerzone/global_common.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dangerzone/global_common.py b/dangerzone/global_common.py index e3cea96..438dd56 100644 --- a/dangerzone/global_common.py +++ b/dangerzone/global_common.py @@ -430,7 +430,9 @@ class GlobalCommon(object): print("Installing Dangerzone container image...") p = subprocess.Popen( - [self.get_container_runtime(), "load"], stdin=subprocess.PIPE + [self.get_container_runtime(), "load"], + stdin=subprocess.PIPE, + startupinfo=self.get_subprocess_startupinfo(), ) chunk_size = 1024 @@ -473,6 +475,7 @@ class GlobalCommon(object): self.container_name, ], text=True, + startupinfo=self.get_subprocess_startupinfo(), ) found_image_id = found_image_id.strip() @@ -484,7 +487,8 @@ class GlobalCommon(object): print(f"Deleting old dangerzone container image") subprocess.check_output( - [self.get_container_runtime(), "rmi", found_image_id] + [self.get_container_runtime(), "rmi", found_image_id], + startupinfo=self.get_subprocess_startupinfo(), ) return installed From 6a24b7b364d1def091f53a1e244ce281f48c64a8 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Wed, 24 Nov 2021 12:33:37 -0800 Subject: [PATCH 5/7] Revert "Change version to 0.3.dev1" This reverts commit 7d945817a31e06389f2e70b4f3295a39692c9d4f. --- pyproject.toml | 2 +- share/version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 20cf6f8..b9a2b4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dangerzone" -version = "0.3.dev1" +version = "0.3" description = "Take potentially dangerous PDFs, office documents, or images and convert them to a safe PDF" authors = ["Micah Lee "] license = "MIT" diff --git a/share/version.txt b/share/version.txt index f794674..be58634 100644 --- a/share/version.txt +++ b/share/version.txt @@ -1 +1 @@ -0.3.dev1 +0.3 From e6d90a57297194a00aedf307c338a408de8a2943 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Wed, 24 Nov 2021 12:35:43 -0800 Subject: [PATCH 6/7] Show more details on failure --- dangerzone/gui/main_window.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dangerzone/gui/main_window.py b/dangerzone/gui/main_window.py index 3cea9d0..5cb04d2 100644 --- a/dangerzone/gui/main_window.py +++ b/dangerzone/gui/main_window.py @@ -512,7 +512,9 @@ class ConvertThread(QtCore.QThread): except: print(f"Invalid JSON returned from container: {line}") self.error = True - self.update.emit(True, "Invalid JSON returned from container", 0) + self.update.emit( + True, f"Invalid JSON returned from container:\n\n{line}", 0 + ) return s = Style.BRIGHT + Fore.CYAN + f"{status['percentage']}% " From 65a66b78cda3f294afcd21f43d13bc9cbbd0131d Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Wed, 24 Nov 2021 12:36:18 -0800 Subject: [PATCH 7/7] Remove indent line, this function is deprecated --- install/windows/build-wxs.py | 1 - 1 file changed, 1 deletion(-) diff --git a/install/windows/build-wxs.py b/install/windows/build-wxs.py index 43840e7..0f7c376 100644 --- a/install/windows/build-wxs.py +++ b/install/windows/build-wxs.py @@ -222,7 +222,6 @@ def main(): print(f'') print('') - ET.indent(root_el) ET.dump(root_el)