- windows/installer.nsi: installs to Program Files, manages system PATH, registers uninstaller - relspec update [--check] [--yes]: compares against the latest release and prompts; on Windows downloads and runs the installer - release workflow builds and uploads relspec-setup-windows-amd64.exe - make installer-windows
112 lines
3.4 KiB
NSIS
112 lines
3.4 KiB
NSIS
; RelSpec Windows installer (NSIS)
|
|
;
|
|
; Build: makensis -DVERSION=1.2.3 -DEXE=<abs path to relspec.exe> -DOUT=<abs path to installer> windows/installer.nsi
|
|
; Use absolute paths for EXE and OUT; relative ones resolve unpredictably.
|
|
|
|
!ifndef VERSION
|
|
!define VERSION "0.0.0"
|
|
!endif
|
|
!ifndef OUT
|
|
!define OUT "relspec-setup-windows-amd64.exe"
|
|
!endif
|
|
!ifndef EXE
|
|
!define EXE "relspec-windows-amd64.exe"
|
|
!endif
|
|
|
|
!define APPNAME "RelSpec"
|
|
!define REGKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\RelSpec"
|
|
!define ENVKEY "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
|
|
|
|
Unicode true
|
|
Name "${APPNAME} ${VERSION}"
|
|
OutFile "${OUT}"
|
|
InstallDir "$PROGRAMFILES64\${APPNAME}"
|
|
InstallDirRegKey HKLM "Software\${APPNAME}" "InstallDir"
|
|
RequestExecutionLevel admin
|
|
SetCompressor /SOLID lzma
|
|
|
|
VIProductVersion "${VERSION}.0"
|
|
VIAddVersionKey "ProductName" "${APPNAME}"
|
|
VIAddVersionKey "FileDescription" "${APPNAME} installer"
|
|
VIAddVersionKey "FileVersion" "${VERSION}"
|
|
VIAddVersionKey "ProductVersion" "${VERSION}"
|
|
|
|
!include "MUI2.nsh"
|
|
!include "LogicLib.nsh"
|
|
!include "StrFunc.nsh"
|
|
!include "WinMessages.nsh"
|
|
${StrStr}
|
|
${StrRep}
|
|
${UnStrRep}
|
|
|
|
!insertmacro MUI_PAGE_WELCOME
|
|
!insertmacro MUI_PAGE_DIRECTORY
|
|
!insertmacro MUI_PAGE_INSTFILES
|
|
!insertmacro MUI_PAGE_FINISH
|
|
!insertmacro MUI_UNPAGE_CONFIRM
|
|
!insertmacro MUI_UNPAGE_INSTFILES
|
|
!insertmacro MUI_LANGUAGE "English"
|
|
|
|
Section "Install"
|
|
SetRegView 64
|
|
SetOutPath "$INSTDIR"
|
|
File "/oname=relspec.exe" "${EXE}"
|
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
|
|
|
WriteRegStr HKLM "Software\${APPNAME}" "InstallDir" "$INSTDIR"
|
|
WriteRegStr HKLM "${REGKEY}" "DisplayName" "${APPNAME}"
|
|
WriteRegStr HKLM "${REGKEY}" "DisplayVersion" "${VERSION}"
|
|
WriteRegStr HKLM "${REGKEY}" "Publisher" "Warky Devs"
|
|
WriteRegStr HKLM "${REGKEY}" "DisplayIcon" "$INSTDIR\relspec.exe"
|
|
WriteRegStr HKLM "${REGKEY}" "InstallLocation" "$INSTDIR"
|
|
WriteRegStr HKLM "${REGKEY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
|
WriteRegDWORD HKLM "${REGKEY}" "NoModify" 1
|
|
WriteRegDWORD HKLM "${REGKEY}" "NoRepair" 1
|
|
|
|
; Add the install directory to the system PATH unless it is already there.
|
|
ReadRegStr $0 HKLM "${ENVKEY}" "Path"
|
|
${StrStr} $1 ";$0;" ";$INSTDIR;"
|
|
${If} $1 == ""
|
|
StrLen $2 $0
|
|
${If} $2 > 900
|
|
; NSIS strings are limited; rewriting a very long PATH could truncate it.
|
|
MessageBox MB_OK|MB_ICONEXCLAMATION "PATH is too long to update automatically. Add $INSTDIR to PATH manually."
|
|
${Else}
|
|
${If} $0 == ""
|
|
WriteRegExpandStr HKLM "${ENVKEY}" "Path" "$INSTDIR"
|
|
${Else}
|
|
WriteRegExpandStr HKLM "${ENVKEY}" "Path" "$0;$INSTDIR"
|
|
${EndIf}
|
|
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
|
${EndIf}
|
|
${EndIf}
|
|
SectionEnd
|
|
|
|
Section "Uninstall"
|
|
SetRegView 64
|
|
Delete "$INSTDIR\relspec.exe"
|
|
Delete "$INSTDIR\uninstall.exe"
|
|
RMDir "$INSTDIR"
|
|
|
|
; Remove the install directory from the system PATH.
|
|
ReadRegStr $0 HKLM "${ENVKEY}" "Path"
|
|
; Wrap in separators so every entry, including the first and last, matches.
|
|
StrCpy $1 ";$0;"
|
|
${UnStrRep} $1 "$1" ";$INSTDIR;" ";"
|
|
StrCpy $2 $1 1
|
|
${If} $2 == ";"
|
|
StrCpy $1 $1 "" 1
|
|
${EndIf}
|
|
StrCpy $2 $1 1 -1
|
|
${If} $2 == ";"
|
|
StrCpy $1 $1 -1
|
|
${EndIf}
|
|
${If} $1 != $0
|
|
WriteRegExpandStr HKLM "${ENVKEY}" "Path" "$1"
|
|
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
|
${EndIf}
|
|
|
|
DeleteRegKey HKLM "${REGKEY}"
|
|
DeleteRegKey HKLM "Software\${APPNAME}"
|
|
SectionEnd
|