Skip to content

Commit 19d7ece

Browse files
Windows installer/uninstaller tickets[CPP-751][CPP-743] (#573)
* More pleasing uninstall of old console[CPP-743] * Kill app if running before uninstalling[CPP-751] * Move NSIS plugins to LFS.
1 parent 3f7b42b commit 19d7ece

File tree

6 files changed

+51
-7
lines changed

6 files changed

+51
-7
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
"console_backend/tests/data/*" filter=lfs diff=lfs merge=lfs -text
22
"pyside-wheels/*.whl" filter=lfs diff=lfs merge=lfs -text
3+
installers/Windows/NSIS/*.zip filter=lfs diff=lfs merge=lfs -text

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ get-pip.py
1919
.*.sw?
2020
installers/Windows/*.exe
2121
installers/Linux/*.deb
22-
installers/Windows/NSIS/
22+
installers/Windows/NSIS/*
23+
!installers/Windows/NSIS/*.zip

Makefile.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -764,12 +764,15 @@ mv *.deb installers/Linux/
764764
[tasks.install-nsis-plugin]
765765
script_runner = "@duckscript"
766766
script = '''
767-
filepath = set installers/Windows/NSIS/Inetc.zip
768-
if not is_path_exists ${filepath}
769-
mkdir installers/Windows/NSIS
770-
wget -O ${filepath} https://nsis.sourceforge.io/mediawiki/images/c/c9/Inetc.zip
767+
inetc_filepath = set installers/Windows/NSIS/Plugins/x86-unicode/INetC.dll
768+
if not is_path_exists ${inetc_filepath}
771769
exec --fail-on-error unzip -d installers/Windows/NSIS installers/Windows/NSIS/Inetc.zip
772770
end
771+
nsprocess_filepath = set installers/Windows/NSIS/Plugin/nsProcess.dll
772+
if not is_path_exists ${nsprocess_filepath}
773+
exec --fail-on-error unzip -d installers/Windows/NSIS installers/Windows/NSIS/nsProcess.zip
774+
exec --fail-on-error mv installers/Windows/NSIS/Plugin/nsProcessW.dll installers/Windows/NSIS/Plugin/nsProcess.dll
775+
end
773776
'''
774777

775778
[tasks.dist-to-installer.windows]

installers/Windows/Installer.nsi

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Unicode true
88
!include FileFunc.nsh
99
!include LogicLib.nsh
1010
!addplugindir "NSIS\Plugins\x86-unicode"
11+
!addplugindir "NSIS\Plugin"
1112
!define MUI_ICON "..\..\resources\images\icon.ico"
1213
!define MUI_UNICON "..\..\resources\images\icon.ico"
1314

@@ -22,9 +23,10 @@ Unicode true
2223
!define outfile_prefix "swift-console"
2324
!define installer_dir "py39-dist"
2425
!define company_name "Swift Navigation"
25-
!define old_uninstaller "$PROGRAMFILES\${company_name}\${app_name}\Uninstall.exe"
2626
!define old_shortcut "${app_name} (Old).lnk"
2727

28+
var Checkbox
29+
2830
!define vc_redist_url "https://aka.ms/vs/17/release/vc_redist.x64.exe"
2931

3032
ManifestDPIAware true
@@ -82,6 +84,7 @@ FunctionEnd
8284

8385
!define UninstallMsg "Warning! By clicking $\"Next$\", this installer will uninstall any previous versions of the Swift Console.$\n$\n\
8486
If this is not desired, please exit the installer now."
87+
!define OldUninstallMsg "Also uninstall the previous generation of Swift Console (versions lower than v4.0.0)"
8588

8689
Function uninstallOldVersionsPage
8790
!insertmacro MUI_HEADER_TEXT "Uninstall Previous Version" "This installer will uninstall any previous versions."
@@ -95,10 +98,25 @@ If this is not desired, please exit the installer now."
9598
${NSD_CreateLabel} 0 0 100% 40u "${UninstallMsg}"
9699
Pop $0
97100

101+
${NSD_CreateCheckbox} 10u 110u 100% 10u "${OldUninstallMsg}"
102+
Pop $Checkbox
103+
${NSD_Check} $Checkbox
104+
98105
nsDialogs::Show
99106
FunctionEnd
100107

101108
Function uninstallOldVersionsPageLeave
109+
${NSD_GetState} $Checkbox $0
110+
${If} $0 <> ${BST_UNCHECKED}
111+
SetShellVarContext current
112+
RMDir /r "$PROGRAMFILES\Swift Navigation\Swift Console\*.*"
113+
Delete "$DESKTOP\Swift Console.lnk"
114+
Delete "$DESKTOP\${old_shortcut}"
115+
Delete "$SMPROGRAMS\Swift Navigation\Swift Console.lnk"
116+
Delete "$SMPROGRAMS\Swift Navigation\Uninstall.lnk"
117+
RMDir "$SMPROGRAMS\Swift Navigation"
118+
SetShellVarContext all
119+
${EndIf}
102120
Call Uninstall
103121
FunctionEnd
104122

@@ -160,6 +178,7 @@ If this is not desired, please exit the installer now."
160178

161179
Function MoveOldShtct
162180
SetShellVarContext current
181+
IfFileExists "$DESKTOP\${old_shortcut}" +2 0
163182
Rename "$DESKTOP\${app_name}.lnk" "$DESKTOP\${old_shortcut}"
164183
SetShellVarContext all
165184
FunctionEnd
@@ -230,9 +249,23 @@ Function LaunchAsNonAdmin
230249
Exec '"$WINDIR\explorer.exe" "$InstDir\${app_executable}"'
231250
FunctionEnd
232251

252+
!macro CloseAppIfRunning Prefix
253+
Function ${Prefix}CloseAppIfRunning
254+
nsProcess::_FindProcess "${app_executable}"
255+
Pop $R0
256+
${If} $R0 == 0
257+
nsProcess::_CloseProcess "${app_executable}"
258+
Sleep 2000
259+
${EndIf}
260+
nsProcess::_Unload
261+
FunctionEnd
262+
!macroend
263+
!insertmacro CloseAppIfRunning ""
264+
!insertmacro CloseAppIfRunning "un."
265+
233266
!macro Uninstall Prefix
234267
Function ${Prefix}Uninstall
235-
Exec '"${old_uninstaller}" "/AllUsers /S"'
268+
Call ${Prefix}CloseAppIfRunning
236269
RMDir /r "$InstDir"
237270
Delete "$DESKTOP\${app_name}.lnk"
238271
Delete "$SMPROGRAMS\${app_name}.lnk"

installers/Windows/NSIS/Inetc.zip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:88d9dcffbe967df6ee9f5820f8199a673383e581bf650dbc35b94846314b1a4b
3+
size 83045
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:0d864ceeb0573c9d0a3fbbbe726f4a819bbb9e7c18c8ca2adaca6f47dce6db5e
3+
size 20550

0 commit comments

Comments
 (0)