summaryrefslogtreecommitdiff
path: root/branding
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-04-24 20:38:49 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-04-30 22:10:33 +0200
commitc8cadd8bec1350b28c0042a18055eb2c7db096c6 (patch)
tree9521cbcd824b068e3069493fe152c841ab066f6b /branding
parent37ed577a6b8de8a43fb67f30e7a0c7460a4c04a9 (diff)
[pkg] two-stage build for windows to allow signed uninstaller
Diffstat (limited to 'branding')
-rw-r--r--branding/scripts/provider.py2
-rwxr-xr-xbranding/templates/makefile/Makefile18
-rwxr-xr-xbranding/templates/windows/template.nsi34
3 files changed, 32 insertions, 22 deletions
diff --git a/branding/scripts/provider.py b/branding/scripts/provider.py
index 7455556..b1beab9 100644
--- a/branding/scripts/provider.py
+++ b/branding/scripts/provider.py
@@ -5,7 +5,7 @@ import os
def getDefaultProvider(config):
provider = os.environ.get('PROVIDER')
if provider:
- print('[+] Got provider {} from environemnt'.format(provider))
+ print('[+] Got provider {} from environment'.format(provider))
else:
print('[+] Using default provider from config file')
provider = config['default']['provider']
diff --git a/branding/templates/makefile/Makefile b/branding/templates/makefile/Makefile
index 5994e19..c042d27 100755
--- a/branding/templates/makefile/Makefile
+++ b/branding/templates/makefile/Makefile
@@ -34,11 +34,19 @@ pkg_win: staging\openvpn\openvpn.exe
copy ..\bin\bitmask-helper staging\bitmask_helper.exe
"C:\Program Files (x86)\NSIS\makensis.exe" windows/$(APPNAME)-installer.nsi
else
-pkg_win: staging/openvpn/openvpn.exe
- echo "[+] building windows"
+pkg_win_stage_1: staging/openvpn/openvpn.exe
+ echo "[+] building windows [stage1]"
+ cp ../bin/windows/bitmask-vpn staging/bitmask-vpn.exe
+ cp ../bin/windows/bitmask-helper-go staging/helper.exe
+ touch windows/uninstall.exe
+ makensis -DUNINSTALLER windows/$(APPNAME)-installer.nsi
+ mv dist/produce-bitmask-uninstaller.exe ../../deploy/
+
+pkg_win_stage_2: staging/openvpn/openvpn.exe
+ echo "[+] building windows [stage2]"
cp ../bin/windows/bitmask-vpn staging/bitmask-vpn.exe
- #cp ../bin/windows/bitmask-helper staging/bitmask_helper.exe
cp ../bin/windows/bitmask-helper-go staging/helper.exe
+ cp ../windows/staging/uninstall-signed.exe windows/uninstall.exe
makensis windows/$(APPNAME)-installer.nsi
mv dist/$(APPNAME)-$(VERSION).exe ../../deploy/
endif
@@ -117,10 +125,10 @@ staging\openvpn\openvpn.exe:
copy .\staging\openvpn\openvpn.exe .\staging
copy .\staging\openvpn\*.dll .\staging
staging/openvpn/openvpn.exe:
- mkdir -p staging/openvpn
+ @mkdir -p staging/openvpn
wget https://build.openvpn.net/downloads/releases/latest/tap-windows-latest-stable.exe -O $(STAGING)/openvpn/tap-windows.exe
wget https://downloads.leap.se/thirdparty/windows/openvpn-x86_64-w64-mingw32.tar.bz2 -O $(STAGING)/openvpn/openvpn.tar.bz2
- tar xvjf $(STAGING)/openvpn/openvpn.tar.bz2 -C $(STAGING)/openvpn/
+ @tar xjf $(STAGING)/openvpn/openvpn.tar.bz2 -C $(STAGING)/openvpn/
cp $(STAGING)/openvpn/bin/openvpn.exe $(STAGING)/openvpn
cp $(STAGING)/openvpn/bin/*.dll $(STAGING)
cp $(STAGING)/openvpn/lib/engines-1_1/*.dll $(STAGING)
diff --git a/branding/templates/windows/template.nsi b/branding/templates/windows/template.nsi
index e3b2379..6fa189b 100755
--- a/branding/templates/windows/template.nsi
+++ b/branding/templates/windows/template.nsi
@@ -2,10 +2,10 @@
!echo "Stage 1: building uninstaller"
; we don't care about this installer, in this step we just pick the uninstaller
; to be able to sign it.
- OutFile "$%TEMP%\tempinstaller.exe"
- SetCompressor off
+ OutFile "..\dist\produce-bitmask-uninstaller.exe"
+ SetCompress off
!else
- !echo "Stage 2: building installer"
+ !echo "Stage 2: building main installer"
Outfile "..\dist\$applicationName-$version.exe"
SetCompressor /SOLID lzma
!endif
@@ -59,7 +59,6 @@ Section "InstallFiles"
DetailPrint "Trying to uninstall any older helper..."
ClearErrors
Delete 'C:\Program Files\$applicationName\bitmask_helper.exe'
- IfErrors 0 noErrorHelper
DetailPrint "Trying to uninstall new helper..."
ClearErrors
@@ -67,14 +66,14 @@ Section "InstallFiles"
ExecWait '"$INSTDIR\helper.exe" remove'
ClearErrors
Delete 'C:\Program Files\$applicationName\helper.exe'
- IfErrors 0 noErrorHelper
+ ;IfErrors 0 noErrorHelper
; uninstalling old nssm helper - could fail if it isn't there, or if nssm is not there...
ClearErrors
DetailPrint "Trying to uninstall an old style helper..."
ExecWait '"$INSTDIR\nssm.exe" stop $applicationNameLower-helper'
ExecWait '"$INSTDIR\nssm.exe" remove $applicationNameLower-helper confirm'
- IfErrors 0 noErrorHelper
+ ;IfErrors 0 noErrorHelper
DetailPrint "Failed to stop nssm-style helper, maybe it was not there"
; let's try to stop it in case it's the new style helper -- we need to do it to be able to overwrite it.
@@ -82,16 +81,10 @@ Section "InstallFiles"
ClearErrors
DetailPrint "Trying to uninstall a new style helper..."
ExecWait '"$INSTDIR\bitmask_helper.exe" stop'
- IfErrors 0 noErrorHelper
+ ;IfErrors 0 noErrorHelper
DetailPrint "Failed to stop new-style helper, maybe it was not there"
- ClearErrors
- DetailPrint "Trying to uninstall a new style helper..."
- ExecWait '"$INSTDIR\helper.exe" stop'
- IfErrors 0 noErrorHelper
- DetailPrint "Failed to stop new-style helper, maybe it was not there"
-
- noErrorHelper:
+ ;noErrorHelper:
; now we try to delete the systray, locked by the app - just to know if another instance of FoobarVPN is running.
ClearErrors
@@ -105,9 +98,7 @@ Section "InstallFiles"
noDelError:
- ; TODO -- write uninstaller in a separate stage, so we can sign it!
SetOutPath $INSTDIR
- WriteUninstaller $INSTDIR\uninstall.exe
; Add ourselves to Add/remove programs
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$applicationNameLower" "DisplayName" "$applicationName"
@@ -125,6 +116,7 @@ Section "InstallFiles"
createShortCut "$SMPROGRAMS\$applicationName\$applicationName.lnk" "$INSTDIR\bitmask-vpn.exe" "" "$INSTDIR\icon.ico"
File "readme.txt"
+ File "uninstall.exe"
File "/oname=icon.ico" "..\assets\icon.ico"
$extra_install_files
@@ -156,6 +148,8 @@ Section /o "TAP Virtual Ethernet Adapter" SecTAP
DetailPrint "TAP installed!"
SectionEnd
+!ifdef UNINSTALLER
+; this section should not be in the main installer, because it will cause warnings.
Section "Uninstall"
; we uninstall the new-style go helper
ExecWait '"$INSTDIR\bitmask_helper.exe" stop'
@@ -180,9 +174,17 @@ Section "Uninstall"
Delete $INSTDIR\uninstall.exe
RMDir $INSTDIR
SectionEnd
+!endif
Function .onInit
+!ifdef UNINSTALLER
+ ; If UNINSTALLER is defined, then we don't do anything execpt write out the uninstaller.
+ SetSilent silent
+ WriteUninstaller "c:\bitmask-uninstall.exe"
+ Quit ; bail out quickly when running the UNINSTALLER stage.
+!else
!insertmacro SelectByParameter ${SecTAP} SELECT_TAP 1
+!endif
FunctionEnd
;----------------------------------------