|
| 1 | +; Custom NSIS macros for Twake Desktop (included via `nsis.include` in |
| 2 | +; electron-builder-config.js). |
| 3 | +; |
| 4 | +; Twake Desktop appId is `io.cozy.desktop`, whose electron-builder NSIS UUID |
| 5 | +; v5 is 4e3f3566-be06-5f9a-b012-0cf924cd77aa. The uninstall registry key |
| 6 | +; format changed over electron-builder versions: |
| 7 | +; - v19 (Twake <= v3.15.x): no braces |
| 8 | +; - v21 (Twake v3.16.0-v3.30.x): {with braces} |
| 9 | +; - v22+ (Twake >= v3.31): no braces (current) |
| 10 | + |
| 11 | +!include "nsDialogs.nsh" |
| 12 | +!include "FileFunc.nsh" |
| 13 | + |
| 14 | +!define APP_UNINSTALL_KEY_NO_BRACES "Software\Microsoft\Windows\CurrentVersion\Uninstall\4e3f3566-be06-5f9a-b012-0cf924cd77aa" |
| 15 | +!define APP_UNINSTALL_KEY_BRACES "Software\Microsoft\Windows\CurrentVersion\Uninstall\{4e3f3566-be06-5f9a-b012-0cf924cd77aa}" |
| 16 | + |
| 17 | +; Runs at the very end of the install section, on fresh installs, manual |
| 18 | +; upgrades and auto-updates (the auto-updater runs the same installer with |
| 19 | +; `/S --updated`; `customInstall` has no silent-mode guard in the |
| 20 | +; electron-builder templates). |
| 21 | +!macro customInstall |
| 22 | + ; Remove orphaned uninstall keys left behind by past installers so that a |
| 23 | + ; single entry ever shows up in Windows' installed apps list. The key |
| 24 | + ; currently written by the installer (no braces, in SHELL_CONTEXT) is never |
| 25 | + ; touched here. |
| 26 | + DeleteRegKey HKCU "${APP_UNINSTALL_KEY_BRACES}" |
| 27 | + ${if} $installMode == "all" |
| 28 | + DeleteRegKey HKLM "${APP_UNINSTALL_KEY_BRACES}" |
| 29 | + ; Per-machine installs from the electron-builder v19 era |
| 30 | + DeleteRegKey HKLM "${APP_UNINSTALL_KEY_NO_BRACES}" |
| 31 | + ${endif} |
| 32 | +!macroend |
| 33 | + |
| 34 | +; Runs at the very end of the uninstall section, after the uninstall |
| 35 | +; registry keys have been removed and right before `quitSuccess` (which only |
| 36 | +; calls Quit). The one-click uninstaller has no MUI pages: un.onInit forces |
| 37 | +; `SetSilent silent` after its confirmation MessageBox, so we briefly restore |
| 38 | +; the normal mode to show our own nsDialogs dialog. |
| 39 | +!macro customUnInstall |
| 40 | + ; Placeholder; filled in the next commit. |
| 41 | +!macroend |
0 commit comments