From 4ac0fd8ecfa1bf0aa394c38d5b7f4f60ca23842b Mon Sep 17 00:00:00 2001
From: kali <kali@win>
Date: Thu, 15 Oct 2020 18:12:46 +0200
Subject: [PATCH] [pkg] install tap driver on windows

---
 Makefile                                                     | 4 ++++
 .../qtinstaller/packages/bitmaskvpn/meta/install.js          | 5 ++++-
 docs/build.windows.rst                                       | 4 ++--
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 9faf55ca..5de5d441 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,8 @@ MACDEPLOYQT_OPTS = -appstore-compliant -qmldir=gui/qml -always-overwrite
 SCRIPTS = branding/scripts
 TEMPLATES = branding/templates
 
+TAP_WINDOWS = https://build.openvpn.net/downloads/releases/tap-windows-9.24.2-I601-Win10.exe 
+
 ifeq ($(PLATFORM), windows)
 HAS_QTIFW := $(shell which binarycreator.exe)
 else
@@ -131,6 +133,8 @@ ifeq (${PLATFORM}, windows)
 	@cp "/c/Program Files/OpenVPN/bin/"*.dll ${INST_DATA}
 	# XXX add sign options
 	@windeployqt --qmldir gui/qml ${INST_DATA}${TARGET}.exe
+	# TODO stage it to save time
+	@wget ${TAP_WINDOWS} -O ${INST_DATA}/tap-windows.exe
 endif
 ifeq (${PLATFORM}, linux)
 	@VERSION=${VERSION} ${SCRIPTS}/gen-qtinstaller linux ${INSTALLER}
diff --git a/branding/templates/qtinstaller/packages/bitmaskvpn/meta/install.js b/branding/templates/qtinstaller/packages/bitmaskvpn/meta/install.js
index d69f2628..63ba10d5 100644
--- a/branding/templates/qtinstaller/packages/bitmaskvpn/meta/install.js
+++ b/branding/templates/qtinstaller/packages/bitmaskvpn/meta/install.js
@@ -91,9 +91,12 @@ Component.prototype.installationFinished = function()
 }
 
 function postInstallWindows() {
+    console.log("Trying to install OpenVPN tap driver");
+    component.addElevatedOperation("Execute", "@TargetDir@/tap-windows.exe");  /* TODO uninstall? */
+    console.log("Now trying to installer our helper");
     component.addElevatedOperation("Execute", "@TargetDir@/helper.exe", "install", "UNDOEXECUTE", "@TargetDir@/helper.exe", "remove");
     component.addElevatedOperation("Execute", "@TargetDir@/helper.exe", "start", "UNDOEXECUTE", "@TargetDir@/helper.exe", "stop");
-    console.log("Adding shortcut entries");
+    console.log("Adding shortcut entries/...");
     component.addElevatedOperation("Mkdir", "@StartMenuDir@");
     component.addElevatedOperation("CreateShortcut", "@TargetDir@/$BINNAME.exe", "@StartMenuDir@/$APPNAME.lnk", "workingDirectory=@TargetDir@", "iconPath=@TargetDir@/icon.ico", "description=Start $APPNAME");
 
diff --git a/docs/build.windows.rst b/docs/build.windows.rst
index 1e8364dd..818f813f 100644
--- a/docs/build.windows.rst
+++ b/docs/build.windows.rst
@@ -2,9 +2,9 @@ windows build
 =============
 
 The build currently expects MINGW64 environment, on a native windows host.
-A cross-compiling procedure (at least for the application binaries) should be possible in the near future, using mxe.
+A cross-compiling procedure (at least for the application binaries) should be possible in the near future, using mxe. (There's already some support for it in `gui/build.sh`).
 
-You should install make, as well as a recent Qt5 version (for instance, with chocolatey: choco install make).
+You should instal: make, wget, as well as a recent Qt5 version (for instance, with chocolatey: choco install make && choco install wget).
 
 (In order to avoid makefiles, you are welcome to submit a port of the build scripts using powershell or cscript - see the build.wsf script in openvpn-build for inspiration).
 
-- 
GitLab