|
6 | 6 | ; next to the title, as the Botloft mascot on the page's white. |
7 | 7 | !define MUI_HEADERIMAGE_RIGHT |
8 | 8 |
|
| 9 | +; The installer's own file properties name the publisher too; Tauri's |
| 10 | +; template leaves the company out. |
| 11 | +VIAddVersionKey "CompanyName" "Botloft" |
| 12 | + |
| 13 | +; Tauri keeps the install folder in the registry under |
| 14 | +; Software\<publisher>\<product>. The publisher used to be "github", Tauri's |
| 15 | +; default from the identifier; it is "Botloft" now (`bundle.publisher`). |
| 16 | +; An install made under the old name is adopted under the new one, so an |
| 17 | +; update goes to the folder Botloft is in, and "uninstall before installing" |
| 18 | +; still finds that folder. |
| 19 | +!ifndef BOTLOFT_FOLDER_KEY |
| 20 | + !define BOTLOFT_FOLDER_KEY "Software\Botloft\Botloft" |
| 21 | +!endif |
| 22 | +!ifndef BOTLOFT_OLD_FOLDER_KEY |
| 23 | + !define BOTLOFT_OLD_FOLDER_KEY "Software\github\Botloft" |
| 24 | +!endif |
| 25 | +!ifndef BOTLOFT_OLD_PUBLISHER_KEY |
| 26 | + !define BOTLOFT_OLD_PUBLISHER_KEY "Software\github" |
| 27 | +!endif |
| 28 | + |
| 29 | +; Copies the folder of an install made under the old publisher to the new |
| 30 | +; key, and installs there unless /D chose another folder. It does nothing |
| 31 | +; once the new key exists. |
| 32 | +Function BotloftAdoptOldFolder |
| 33 | + Push $0 |
| 34 | + ReadRegStr $0 SHCTX "${BOTLOFT_FOLDER_KEY}" "" |
| 35 | + StrCmp $0 "" 0 botloft_adopt_done |
| 36 | + ReadRegStr $0 SHCTX "${BOTLOFT_OLD_FOLDER_KEY}" "" |
| 37 | + StrCmp $0 "" botloft_adopt_done 0 |
| 38 | + WriteRegStr SHCTX "${BOTLOFT_FOLDER_KEY}" "" $0 |
| 39 | + ; Only when the installer is still on its default folder: /D wins. |
| 40 | + StrCmp $INSTDIR "$LOCALAPPDATA\Botloft" 0 botloft_adopt_done |
| 41 | + StrCpy $INSTDIR $0 |
| 42 | + botloft_adopt_done: |
| 43 | + Pop $0 |
| 44 | +FunctionEnd |
| 45 | + |
| 46 | +; Before the first page, so the pages and "uninstall before installing" see |
| 47 | +; the adopted folder. |
| 48 | +!define MUI_CUSTOMFUNCTION_GUIINIT BotloftAdoptOldFolder |
| 49 | + |
| 50 | +!macro NSIS_HOOK_PREINSTALL |
| 51 | + ; The quiet installer (/S) has no pages, so nothing adopted the folder yet. |
| 52 | + ; The install section already set its output to the default folder. |
| 53 | + Call BotloftAdoptOldFolder |
| 54 | + SetOutPath $INSTDIR |
| 55 | +!macroend |
| 56 | + |
9 | 57 | !macro NSIS_HOOK_POSTINSTALL |
10 | | - ; Installed apps shows Botloft as the publisher. `bundle.publisher` stays |
11 | | - ; unset on purpose: Tauri also names the key that keeps the install folder |
12 | | - ; after it (Software\<publisher>\Botloft), so a new name would make the |
13 | | - ; first update of an existing install run the old uninstaller without its |
14 | | - ; folder. |
15 | | - WriteRegStr SHCTX "${UNINSTKEY}" "Publisher" "Botloft" |
| 58 | + ; The folder is under the new name now; the old key goes. |
| 59 | + DeleteRegKey SHCTX "${BOTLOFT_OLD_FOLDER_KEY}" |
| 60 | + DeleteRegKey /ifempty SHCTX "${BOTLOFT_OLD_PUBLISHER_KEY}" |
16 | 61 | !macroend |
17 | 62 |
|
18 | 63 | !macro NSIS_HOOK_PREUNINSTALL |
19 | 64 | ; A real uninstall stops the daemon and removes its scheduled task and |
20 | | - ; binary. Bots and data stay in %LOCALAPPDATA%\Botloft. An update runs |
21 | | - ; this uninstaller too, with /UPDATE: then the daemon keeps running. |
| 65 | + ; binary. Bots and data stay in %LOCALAPPDATA%\Botloft. An uninstaller run |
| 66 | + ; with /UPDATE leaves the daemon running. |
22 | 67 | ${If} $UpdateMode <> 1 |
23 | 68 | nsExec::Exec '"$INSTDIR\botloftd.exe" service uninstall' |
24 | 69 | Pop $0 |
|
0 commit comments