diff --git a/.gitignore b/.gitignore index 0eef66b..ffbb501 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ /linux/debian/portmaster/ *.exe /windows/install_summary.nsh +/windows/install_finish.nsh +/windows/.wine \ No newline at end of file diff --git a/windows/Makefile b/windows/Makefile index 8fba7a1..7aacd81 100644 --- a/windows/Makefile +++ b/windows/Makefile @@ -1,17 +1,26 @@ # Note: Built for execution in container .github/actions/build-nsis STARTURL ?= https://updates.safing.io/latest/windows_amd64/start/portmaster-start.exe +MAKENSIS ?= makensis +WINEPREFIX ?= all: portmaster-uninstaller.exe portmaster-installer.exe +prepare-wine: + wget -O /tmp/nsis-installer.exe https://downloads.sourceforge.net/project/nsis/NSIS%203/3.08/nsis-3.08-setup.exe\?ts\=gAAAAABhgOi_QwQAJSZpPpH77UeO42NdRuMrbb9gHArOw_q1xuPE-qVke0568R-KvtJXhFvZ6Z142oyJlQYiDDLQtylZsOvtAw%3D%3D\&r\=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fnsis%2Ffiles%2FNSIS%25203%2F3.08%2Fnsis-3.08-setup.exe%2Fdownload%3Fuse_mirror%3Dnav%26download%3D + WINEPREFIX=$(shell pwd)/.wine wine /tmp/nsis-installer.exe + @echo "run: 'export WINEPREFIX=$(shell pwd)/.wine'" + wine-setup: +ifeq (,$(findstring $(shell pwd),$(WINEPREFIX))) which sudo && sudo chown -R $$(id -u):$$(id -g) $(WINEPREFIX) || true +endif portmaster-start.exe: curl --fail --user-agent GitHub -o portmaster-start.exe $(STARTURL) -portmaster-uninstaller.exe: wine-setup portmaster-installer.nsi install_summary.nsh - makensis -DUNINSTALLER portmaster-installer.nsi +portmaster-uninstaller.exe: wine-setup portmaster-installer.nsi install_summary.nsh install_finish.nsh + $(MAKENSIS) -DUNINSTALLER portmaster-installer.nsi wine ./uninstaller_pkg.exe ifdef SIGN @echo -e "If wanted, sign now (on Windows) using:\nsign.bat portmaster-uninstaller.exe\npress enter to continue" @@ -23,16 +32,27 @@ install_summary.nsh: install_summary.rtf perl -p -e 's/\r?\n/\$$\\r\$$\\n/' install_summary.rtf >> install_summary.nsh echo '"' >> install_summary.nsh -portmaster-installer.exe: wine-setup portmaster-start.exe portmaster-installer.nsi portmaster-uninstaller.exe install_summary.nsh - makensis -DINSTALLER -DPRODUCTION portmaster-installer.nsi #Production enables good compression (takes longer) +install_finish.nsh: install_finish.rtf + echo -n '$${NSD_SetText} $$0 "' > install_finish.nsh + perl -p -e 's/\r?\n/\$$\\r\$$\\n/' install_finish.rtf >> install_finish.nsh + echo '"' >> install_finish.nsh + +portmaster-installer.exe: wine-setup portmaster-start.exe portmaster-installer.nsi portmaster-uninstaller.exe install_summary.nsh install_finish.nsh + $(MAKENSIS) -DINSTALLER -DPRODUCTION portmaster-installer.nsi #Production enables good compression (takes longer) ifdef SIGN @echo -e "If wanted, sign now (on Windows) using:\nsign.bat portmaster-installer.exe\npress enter to continue" @read x endif +test: portmaster-installer.exe + mkdir -p /tmp/test-wine + rm -rf /tmp/test-wine/prefix || true + WINEPREFIX=/tmp/test-wine/prefix wine ./portmaster-installer.exe + clean: rm -f portmaster-uninstaller.exe rm -f uninstaller_pkg.exe rm -f portmaster-installer.exe rm -f install_summary.nsh + rm -f install_finish.nsh rm -rf portmaster-start.exe diff --git a/windows/install_finish.rtf b/windows/install_finish.rtf new file mode 100644 index 0000000..4226889 --- /dev/null +++ b/windows/install_finish.rtf @@ -0,0 +1,7 @@ +{\rtf1\ansi +\ +\f1\b0\fs18 \ +\f0\b Portmaster updates itself automatically. You can always follow the progress on fixes and new features on https://github.com/safing/portmaster/\ +\ +\f0\b In order to finish the Portmaster installation you must reboot your system.\ +} \ No newline at end of file diff --git a/windows/install_summary.rtf b/windows/install_summary.rtf index 3abc014..ce413c7 100644 --- a/windows/install_summary.rtf +++ b/windows/install_summary.rtf @@ -1,9 +1,4 @@ {\rtf1\ansi -\f0\b\fs30 Important -\ -\f1\b0\fs18 \ -\f0\b Portmaster updates itself automatically. Learn more about this on docs.safing.io.\ -\ \ \f0\fs30 Details \f1\b0\fs18 \ diff --git a/windows/portmaster-installer.nsi b/windows/portmaster-installer.nsi index f88121f..69e46a5 100644 --- a/windows/portmaster-installer.nsi +++ b/windows/portmaster-installer.nsi @@ -1,5 +1,9 @@ Unicode true ; The Multi-Language-Part is a modified version of the MultiLanguage-NSIS-Example +!define MUI_ICON "portmaster.ico" +!define MUI_UNICON "portmaster.ico" +!define MUI_HEADERIMAGE + !include MUI2.nsh !include nsDialogs.nsh !include LogicLib.nsh @@ -45,6 +49,7 @@ Var InstDir_parent ;!insertmacro MUI_PAGE_DIRECTORY Page custom fnc_PageSummary_Show !insertmacro MUI_PAGE_INSTFILES +Page custom fnc_PageFinish_Show !insertmacro MUI_PAGE_FINISH ; Uninstaller Pages @@ -54,6 +59,7 @@ Page custom fnc_PageSummary_Show !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH !endif + !include languages.nsh Function fnc_PageSummary_Show @@ -62,7 +68,7 @@ Function fnc_PageSummary_Show ${If} $0 == error Abort ${EndIf} - !insertmacro MUI_HEADER_TEXT "Summary" "A summary of all that will be installed (and reversed on uninstall)" + !insertmacro MUI_HEADER_TEXT "Summary" "A summary of all that will be installed" nsDialogs::CreateControl "RichEdit20A" ${ES_READONLY}|${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP}|${WS_VSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN} ${WS_EX_STATICEDGE} 0 0 100% 119u '' Pop $0 @@ -71,16 +77,33 @@ Function fnc_PageSummary_Show nsDialogs::Show FunctionEnd +Function fnc_PageFinish_Show + nsDialogs::Create 1018 + Pop $0 + ${If} $0 == error + Abort + ${EndIf} + !insertmacro MUI_HEADER_TEXT "Installation successfull" "" + + nsDialogs::CreateControl "RichEdit20A" ${ES_READONLY}|${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP}|${WS_VSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN} ${WS_EX_STATICEDGE} 0 0 100% 119u '' + Pop $0 + !include install_finish.nsh + + nsDialogs::Show +FunctionEnd + Function .onInit ReadEnvStr $0 PROGRAMDATA StrCpy $InstDir "$0\Safing\Portmaster" StrCpy $InstDir_parent "$0\Safing" + SetRebootFlag true FunctionEnd Function un.onInit ReadEnvStr $0 PROGRAMDATA StrCpy $InstDir "$0\Safing\Portmaster" StrCpy $InstDir_parent "$0\Safing" + SetRebootFlag true FunctionEnd !ifdef INSTALLER @@ -88,7 +111,7 @@ Section "Install" ${If} ${IsWin10} ; do nothing ${ElseIf} ${AtLeastWin10} - MessageBox MB_ICONEXCLAMATION "This MS Version seems not to be supported, Portmaster is not installed" + MessageBox MB_ICONEXCLAMATION "This Windows Version is not supported. The Portmaster cannot be installed" SetErrors Abort ${EndIf} @@ -140,6 +163,14 @@ dontUpdate: WriteRegStr HKLM "SOFTWARE\Classes\CLSID\{7F00FB48-65D5-4BA8-A35B-F194DA7E1A51}\LocalServer32" "" '"$INSTDIR\${ExeName}" notifier-snoretoast' +; prepare directory structure + DetailPrint "Preparing installation directory ..." + nsExec::ExecToStack '$INSTDIR\${ExeName} clean-structure --data=$InstDir' + pop $0 + pop $1 + ; we ignore the error here as a reboot is suggested anyway and that will + ; fix the above error as well. + ; download DetailPrint "Downloading Portmaster modules, this may take a while ..." nsExec::ExecToStack '$INSTDIR\${ExeName} update --data=$InstDir' @@ -147,7 +178,9 @@ dontUpdate: pop $1 ; DetailPrint $1 ; # would print > BOF from portmaster-start log ${If} $0 <> 0 - MessageBox MB_ICONEXCLAMATION "Failed to download Portmaster modules. The portmaster service will attempt to download the modules when started. Note that it will take some time before you see it starting." + MessageBox MB_ICONEXCLAMATION "Failed to download Portmaster assets required for installation. Please check your Internet connection and try installing again." + SetErrors + Abort ${EndIf} ; register Service @@ -157,7 +190,7 @@ dontUpdate: pop $1 DetailPrint $1 ${If} $0 <> 0 - MessageBox MB_ICONEXCLAMATION "Windows Service registration failed, see details." + MessageBox MB_ICONEXCLAMATION "Windows Service registration failed. Please contact our support at support@safing.io." SetErrors Abort ${EndIf} @@ -182,12 +215,8 @@ dontUpdate: WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Portmaster" \ "NoModify" 1 - ; Start Portmaster Core Service and Notifier - DetailPrint "Starting Portmaster Core Service and Notifier ..." - Exec '"sc.exe" start PortmasterCore' - Exec '"$INSTDIR\${ExeName}" notifier --data=$InstDir' - SectionEnd + !endif !ifdef UNINSTALLER diff --git a/windows/portmaster.bmp b/windows/portmaster.bmp new file mode 100644 index 0000000..49329f2 Binary files /dev/null and b/windows/portmaster.bmp differ