summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.cargo/config5
-rw-r--r--.gitattributes5
-rwxr-xr-xbuild.sh28
m---------dist-assets/binaries0
-rw-r--r--dist-assets/windows/installer.nsh236
-rw-r--r--electron-builder.yml15
6 files changed, 277 insertions, 12 deletions
diff --git a/.cargo/config b/.cargo/config
new file mode 100644
index 0000000000..ba321231fc
--- /dev/null
+++ b/.cargo/config
@@ -0,0 +1,5 @@
+[target.x86_64-pc-windows-msvc]
+rustflags = ["-Ctarget-feature=+crt-static"]
+
+[target.i686-pc-windows-msvc]
+rustflags = ["-Ctarget-feature=+crt-static"]
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000000..64584601b1
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,5 @@
+# Set the default behavior
+* text=auto
+
+# Do not break script files on Windows (Cygwin gets upset with CRLF)
+*.sh text eol=lf
diff --git a/build.sh b/build.sh
index 5f967f035a..7b0e791731 100755
--- a/build.sh
+++ b/build.sh
@@ -44,23 +44,28 @@ if [[ "$(uname -s)" = "Darwin" ]]; then
fi
fi
-
# Remove binaries. To make sure it is rebuilt with the stable toolchain and the latest changes.
cargo +stable clean
+if [[ "$(uname -s)" == "MINGW"* ]]; then
+ ./build_winfw.sh
+fi
+
echo "Compiling mullvad-daemon in release mode with $RUSTC_VERSION..."
cargo +stable build --release
-
-binaries=(
- ./target/release/mullvad-daemon
- ./target/release/mullvad
- ./target/release/problem-report
-)
-for binary in ${binaries[*]}; do
- echo "Stripping debugging symbols from $binary"
- strip $binary
-done
+# Only strip binaries on platforms other than Windows.
+if [[ "$(uname -s)" != "MINGW"* ]]; then
+ binaries=(
+ ./target/release/mullvad-daemon
+ ./target/release/mullvad
+ ./target/release/problem-report
+ )
+ for binary in ${binaries[*]}; do
+ echo "Stripping debugging symbols from $binary"
+ strip $binary
+ done
+fi
echo "Updating relay list..."
./target/release/list-relays > dist-assets/relays.json
@@ -72,6 +77,7 @@ echo "Packing final release artifact..."
case "$(uname -s)" in
Linux*) yarn pack:linux;;
Darwin*) yarn pack:mac;;
+ MINGW*) yarn pack:win;;
esac
RELEASE_VERSION=`./target/release/mullvad-daemon --version | cut -f2 -d' '`
diff --git a/dist-assets/binaries b/dist-assets/binaries
-Subproject 2e4068687389a085588558d1edc0a887250fe64
+Subproject 29d6d19ee6ea8ada8a61dc67b79343fed9a0cb8
diff --git a/dist-assets/windows/installer.nsh b/dist-assets/windows/installer.nsh
new file mode 100644
index 0000000000..4b29fe1df3
--- /dev/null
+++ b/dist-assets/windows/installer.nsh
@@ -0,0 +1,236 @@
+!include stdutils.nsh
+!include winver.nsh
+#!include strcontains.nsh
+
+#
+# NOTES
+#
+# Do not include certain default header files - results in random errors
+# Do not define and use functions - broken
+# Do not use DetailPrint - any message sent to DetailPrint is lost
+# Do not compare variables using the <> operator - broken
+#
+
+# TAP device hardware ID
+!define TAP_HARDWARE_ID "tap0901"
+
+# "sc" exit code
+!define SERVICE_STARTED 0
+!define SERVICE_START_PENDING 2
+
+#
+# BreakInstallation
+#
+# Aborting the customization step does not undo previous steps taken
+# by the installer (copy files, create shortcut, etc)
+#
+# Therefore we have to break the installed application to
+# prevent users from running a half-installed product
+#
+!macro BreakInstallation
+
+ Delete "$INSTDIR\mullvadvpn.exe"
+
+!macroend
+
+!define BreakInstallation '!insertmacro "BreakInstallation"'
+
+#
+# ExtractDriver
+#
+# Extract the correct driver for the current platform
+# placing it into $TEMP\driver
+#
+!macro ExtractDriver
+
+ SetOutPath "$TEMP\driver"
+ File "${PROJECT_DIR}\dist-assets\binaries\windows\driver\*"
+
+ ${If} ${IsWin7}
+ File "${PROJECT_DIR}\dist-assets\binaries\windows\driver\ndis5\*"
+ ${Else}
+ File "${PROJECT_DIR}\dist-assets\binaries\windows\driver\ndis6\*"
+ ${EndIf}
+
+!macroend
+
+!define ExtractDriver '!insertmacro "ExtractDriver"'
+
+#
+# InstallDriver
+#
+# Install tunnel driver or update it if already present on the system
+#
+# Returns: 0 in $R0 on success, otherwise an error message in $R0
+#
+!macro InstallDriver
+
+ Push $0
+ Push $1
+
+ nsExec::ExecToStack '"$TEMP\driver\tapinstall.exe" hwids ${TAP_HARDWARE_ID}'
+
+ Pop $0
+ Pop $1
+
+ ${If} $0 != 0
+ StrCpy $R0 "Failed to list hardware IDs: error $0"
+ Goto InstallDriver_return
+ ${EndIf}
+
+ # If the driver is already installed, the hardware ID will be echoed in the command output
+ # $1 holds the output from "tapinstall hwids"
+ ${StrContains} $0 ${TAP_HARDWARE_ID} $1
+ StrCmp $0 "" InstallDriver_install_driver
+
+ # Update driver
+ nsExec::ExecToStack '"$TEMP\driver\tapinstall.exe" update "$TEMP\driver\OemVista.inf" ${TAP_HARDWARE_ID}'
+
+ Pop $0
+ Pop $1
+
+ ${If} $0 != 0
+ StrCpy $R0 "Failed to update TAP driver: error $0"
+ Goto InstallDriver_return
+ ${EndIf}
+
+ Goto InstallDriver_return_success
+
+ InstallDriver_install_driver:
+
+ nsExec::ExecToStack '"$TEMP\driver\tapinstall.exe" install "$TEMP\driver\OemVista.inf" ${TAP_HARDWARE_ID}'
+
+ Pop $0
+ Pop $1
+
+ ${If} $0 != 0
+ StrCpy $R0 "Failed to install TAP driver: error $0"
+ Goto InstallDriver_return
+ ${EndIf}
+
+ InstallDriver_return_success:
+
+ Push 0
+ Pop $R0
+
+ InstallDriver_return:
+
+ Pop $1
+ Pop $0
+
+!macroend
+
+!define InstallDriver '!insertmacro "InstallDriver"'
+
+#
+# InstallService
+#
+# Register the service with Windows and start it
+#
+# Returns: 0 in $R0 on success, otherwise an error message in $R0
+#
+!macro InstallService
+
+ Push $0
+ Push $1
+
+ nsExec::ExecToStack '"$INSTDIR\resources\mullvad-daemon.exe" --register-service'
+
+ Pop $0
+ Pop $1
+
+ ${If} $0 != 0
+ StrCpy $R0 "Failed to install Mullvad service: error $0"
+ Goto InstallService_return
+ ${EndIf}
+
+ nsExec::ExecToStack '"sc.exe" start mullvadvpn'
+
+ Pop $0
+ Pop $1
+
+ ${If} $0 != ${SERVICE_STARTED}
+ ${AndIf} $0 != ${SERVICE_START_PENDING}
+ StrCpy $R0 "Failed to start Mullvad service: error $0"
+ Goto InstallService_return
+ ${EndIf}
+
+ Push 0
+ Pop $R0
+
+ InstallService_return:
+
+ Pop $1
+ Pop $0
+
+!macroend
+
+!define InstallService '!insertmacro "InstallService"'
+
+#
+# customInstall
+#
+# This macro is activated towards the end of the installation
+# after all files are copied, shortcuts created, etc
+#
+!macro customInstall
+
+ Push $R0
+
+ ${ExtractDriver}
+ ${InstallDriver}
+
+ ${If} $R0 != 0
+ MessageBox MB_OK "Fatal error during driver installation: $R0"
+ ${BreakInstallation}
+ Abort
+ ${EndIf}
+
+ ${InstallService}
+
+ ${If} $R0 != 0
+ MessageBox MB_OK "Fatal error during service installation: $R0"
+ ${BreakInstallation}
+ Abort
+ ${EndIf}
+
+ Pop $R0
+
+!macroend
+
+###############################################################################
+#
+# Uninstaller
+#
+###############################################################################
+
+#
+# customRemoveFiles
+#
+# This macro is activated just after the removal of files have started.
+# Shortcuts etc may have been removed but application files remain.
+#
+!macro customRemoveFiles
+
+ Push $0
+
+ nsExec::ExecToStack '"sc.exe" stop mullvadvpn'
+
+ # Discard return value
+ Pop $0
+
+ Sleep 5000
+
+ nsExec::ExecToStack '"sc.exe" delete mullvadvpn'
+
+ # Discard return value
+ Pop $0
+
+ Sleep 1000
+
+ # Original removal functionality provided by Electron-builder
+ RMDir /r $INSTDIR
+
+ Pop $0
+
+!macroend
diff --git a/electron-builder.yml b/electron-builder.yml
index 8079aa3350..83bea2c583 100644
--- a/electron-builder.yml
+++ b/electron-builder.yml
@@ -49,9 +49,18 @@ pkg:
allowAnywhere: false
allowCurrentUserHome: false
+nsis:
+ oneClick: false
+ perMachine: true
+ allowElevation: true
+ allowToChangeInstallationDirectory: true
+ include: dist-assets/windows/installer.nsh
+
win:
target:
- - nsis
+ - target: nsis
+ arch:
+ - x64
artifactName: MullvadVPN-${version}.${ext}
extraResources:
- from: ./target/release/mullvad.exe
@@ -62,6 +71,10 @@ win:
to: .
- from: ./target/release/talpid_openvpn_plugin.dll
to: .
+ - from: ./windows/winfw/bin/x64-Release/winfw.dll
+ to: .
+ - from: ./dist-assets/binaries/windows/openvpn.exe
+ to: .
linux:
target: