barrier/cmake/Installer.nsi.in

147 lines
4.3 KiB
Plaintext

; template variables
!define version ${in:version}
!define arch ${in:arch}
!define vcRedistDir ${in:vcRedistDir}
!define qtDir ${in:qtDir}
!define installDirVar ${in:installDirVar}
; normal variables
!define product "Synergy"
!define productOld "Synergy+"
!define packageName "synergy"
!define platform "Windows"
!define publisher "The Synergy Project"
!define helpUrl "http://synergy-foss.org/support"
!define vcRedistFile "vcredist_${arch}.exe"
!define startMenuApp "qsynergy.exe"
!define binDir "..\bin\Release"
!define uninstall "uninstall.exe"
!define icon "..\gui\res\win\QSynergy.ico"
!define controlPanelReg "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
!define MUI_ICON ${icon}
!define MUI_UNICON ${icon}
!include "MUI2.nsh"
!insertmacro MUI_PAGE_LICENSE "..\\cmake\\License.rtf"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Name ${product}
OutFile "${packageName}-${version}-${platform}-${arch}.exe"
InstallDir "${installDirVar}\${product}"
InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${product}" ""
Section
SetShellVarContext all
SetOutPath "$INSTDIR"
WriteUninstaller "$INSTDIR\${uninstall}"
; kill all synergy processes (force kill gui)
nsExec::Exec "taskkill /f /im qsynergy.exe"
nsExec::Exec "taskkill /im launcher.exe"
nsExec::Exec "taskkill /im synergys.exe"
nsExec::Exec "taskkill /im synergyc.exe"
; delete dirs from older installers
RMDir /r "$INSTDIR\..\${productOld}"
RMDir /r "$INSTDIR\bin"
RMDir /r "$INSTDIR\redist"
; delete start menu dir from older installers
RMDir /r "$SMPROGRAMS\${product}"
RMDir /r "$SMPROGRAMS\${productOld}"
; always delete any existing uninstall info
DeleteRegKey HKLM "${controlPanelReg}\${product}"
; always remove 1.3 gui
Delete "$INSTDIR\launcher.exe"
SectionEnd
Section "Server and Client" core
; client and server files
File "${binDir}\synergys.exe"
File "${binDir}\synergyc.exe"
File "${binDir}\synrgyhk.dll"
; add new uninstall info
WriteRegStr HKLM "${controlPanelReg}\${product}" "" $INSTDIR
WriteRegStr HKLM "${controlPanelReg}\${product}" "DisplayName" "${product}"
WriteRegStr HKLM "${controlPanelReg}\${product}" "DisplayVersion" "${version}"
WriteRegStr HKLM "${controlPanelReg}\${product}" "DisplayIcon" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "${controlPanelReg}\${product}" "Publisher" "${publisher}"
WriteRegStr HKLM "${controlPanelReg}\${product}" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "${controlPanelReg}\${product}" "URLInfoAbout" "${helpUrl}"
SectionEnd
Section "Graphical User Interface" gui
; gui and qt libs
File "${binDir}\qsynergy.exe"
File "${qtDir}\qt\bin\libgcc_s_dw2-1.dll"
File "${qtDir}\qt\bin\mingwm10.dll"
File "${qtDir}\qt\bin\QtGui4.dll"
File "${qtDir}\qt\bin\QtCore4.dll"
File "${qtDir}\qt\bin\QtNetwork4.dll"
; gui start menu shortcut
SetShellVarContext all
CreateShortCut "$SMPROGRAMS\${product}.lnk" "$INSTDIR\${startMenuApp}"
SectionEnd
Section "Visual C++ Redistributable" vcredist
; copy redist file, run it, then delete when done
File "${vcRedistDir}\${vcRedistFile}"
ExecWait "$INSTDIR\${vcRedistFile} /install /q"
Delete $INSTDIR\${vcRedistFile}
SectionEnd
Section Uninstall
SetShellVarContext all
; kill all synergy processes (force kill gui)
nsExec::Exec "taskkill /f /im qsynergy.exe"
nsExec::Exec "taskkill /im launcher.exe"
nsExec::Exec "taskkill /im synergys.exe"
nsExec::Exec "taskkill /im synergyc.exe"
; delete start menu shortcut
Delete "$SMPROGRAMS\${product}.lnk"
; delete all registry keys
DeleteRegKey HKLM "SOFTWARE\${product}"
DeleteRegKey HKLM "${controlPanelReg}\${product}"
; delete the files that we put there
Delete "$INSTDIR\synergyc.exe"
Delete "$INSTDIR\synergys.exe"
Delete "$INSTDIR\synrgyhk.dll"
Delete "$INSTDIR\synrgyhk.lib"
Delete "$INSTDIR\libgcc_s_dw2-1.dll"
Delete "$INSTDIR\mingwm10.dll"
Delete "$INSTDIR\qsynergy.exe"
Delete "$INSTDIR\QtCore4.dll"
Delete "$INSTDIR\QtGui4.dll"
Delete "$INSTDIR\QtNetwork4.dll"
Delete "$INSTDIR\${uninstall}"
; delete (only if empty, so we don't delete user files)
RMDir "$INSTDIR"
SectionEnd