120 lines
3.7 KiB
NSIS
120 lines
3.7 KiB
NSIS
; PgTidy Windows installer (NSIS)
|
|
;
|
|
; Build: makensis -DVERSION=1.2.3 -DEXE=<abs path to pgtidy.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 "pgtidy-setup-windows-amd64.exe"
|
|
!endif
|
|
!ifndef EXE
|
|
!define EXE "pgtidy-windows-amd64.exe"
|
|
!endif
|
|
|
|
!define APPNAME "PgTidy"
|
|
!define REGKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\PgTidy"
|
|
!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}"
|
|
VIAddVersionKey "LegalCopyright" "Warky Devs"
|
|
|
|
!include "MUI2.nsh"
|
|
!include "LogicLib.nsh"
|
|
!include "StrFunc.nsh"
|
|
!include "WinMessages.nsh"
|
|
${StrStr}
|
|
${UnStrRep}
|
|
|
|
!define MUI_ABORTWARNING
|
|
!define MUI_ICON "..\assets\logo_128.ico"
|
|
!define MUI_UNICON "..\assets\logo_128.ico"
|
|
|
|
!insertmacro MUI_PAGE_WELCOME
|
|
!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
|
|
!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=pgtidy.exe" "${EXE}"
|
|
File "..\LICENSE"
|
|
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\pgtidy.exe"
|
|
WriteRegStr HKLM "${REGKEY}" "InstallLocation" "$INSTDIR"
|
|
WriteRegStr HKLM "${REGKEY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
|
WriteRegStr HKLM "${REGKEY}" "QuietUninstallString" '"$INSTDIR\uninstall.exe" /S'
|
|
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\pgtidy.exe"
|
|
Delete "$INSTDIR\LICENSE"
|
|
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
|