]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Improve Windows NSIS installer script (setup.nsi) (#831)
authorPierre4012 <45879018+Pierre4012@users.noreply.github.com>
Mon, 25 Mar 2024 15:43:49 +0000 (16:43 +0100)
committerGitHub <noreply@github.com>
Mon, 25 Mar 2024 15:43:49 +0000 (16:43 +0100)
* Improve Windows NSIS installer script (setup.nsi)

Two improvements of installer script :
- avoid error message when Unbound is running,
- add "DisplayVersion" in registry thus Windows package manager (Winget) can handle Unbound.

* Update setup.nsi ask user to stop unbound service + DisplayVersion in Windows registry

winrc/setup.nsi

index 886d83a99929470eab346351ff26cac8d02dd607..7374f5d5a237f090e5f7abaccc8c544bfe4d2303 100644 (file)
@@ -78,6 +78,15 @@ section "Root anchor - DNSSEC" SectionRootKey
 sectionEnd
 
 section "-hidden.postinstall"
+       # if Unbund is already installed, ask to stop it to allow file replacement
+       IfFileExists "$INSTDIR\unbound-service-remove.exe" 0 next_label
+       MessageBox MB_YESNO "Unbound is already installed! Would you like to stop the service to continue with the update?" /SD IDYES IDNO false_label # defaults to yes on silent installations
+               nsExec::ExecToLog '"$INSTDIR\unbound-service-remove.exe" stop'
+               Sleep 1000
+               Goto next_label
+       false_label:
+               Quit
+       next_label:
        # copy files
        SetRegView 64
        setOutPath $INSTDIR
@@ -134,6 +143,7 @@ section "-hidden.postinstall"
 
        # register uninstaller
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "DisplayName" "Unbound"
+       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "DisplayVersion" "${VERSION}"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "UninstallString" "$\"$INSTDIR\uninst.exe$\""
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "QuietUninstallString" "$\"$INSTDIR\uninst.exe$\" /S"
        WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "NoModify" "1"