132 lines
4.9 KiB
NSIS
132 lines
4.9 KiB
NSIS
; Verae Print Stamp — Windows DEBUG installer with "Verae TimeStamp PDF" printer.
|
|
; Build: platform\windows\build-windows-debug.ps1 (on Windows) or makensis with -DSRCDIR.
|
|
!ifndef VERSION
|
|
!define VERSION "0.2.0-debug"
|
|
!endif
|
|
!ifndef ARCH
|
|
!define ARCH "amd64"
|
|
!endif
|
|
!ifndef SRCDIR
|
|
!define SRCDIR "."
|
|
!endif
|
|
!ifndef OUTDIR
|
|
!define OUTDIR "."
|
|
!endif
|
|
|
|
!define PRODUCT_NAME "Verae Print Stamp (debug)"
|
|
!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\VeraePrintStampDebug"
|
|
|
|
Name "${PRODUCT_NAME} ${VERSION}"
|
|
OutFile "${OUTDIR}\VeraePrintStamp-windows-${ARCH}-${VERSION}-setup.exe"
|
|
InstallDir "$PROGRAMFILES64\Verae\PrintStamp"
|
|
RequestExecutionLevel admin
|
|
Unicode true
|
|
SetCompressor /SOLID lzma
|
|
ShowInstDetails show
|
|
ShowUninstDetails show
|
|
|
|
!include "MUI2.nsh"
|
|
!include "x64.nsh"
|
|
!include "LogicLib.nsh"
|
|
|
|
!define MUI_ABORTWARNING
|
|
!define MUI_FINISHPAGE_RUN "$INSTDIR\bin\verae-print.exe"
|
|
!define MUI_FINISHPAGE_RUN_PARAMETERS "setup"
|
|
!define MUI_FINISHPAGE_RUN_TEXT "Run signing-key setup (only needed if not done before)"
|
|
!define MUI_FINISHPAGE_RUN_NOTCHECKED
|
|
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README-TEST.txt"
|
|
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Open test instructions"
|
|
|
|
!insertmacro MUI_PAGE_WELCOME
|
|
!insertmacro MUI_PAGE_LICENSE "${SRCDIR}\LICENSE.txt"
|
|
!insertmacro MUI_PAGE_INSTFILES
|
|
!insertmacro MUI_PAGE_FINISH
|
|
!insertmacro MUI_UNPAGE_CONFIRM
|
|
!insertmacro MUI_UNPAGE_INSTFILES
|
|
!insertmacro MUI_LANGUAGE "English"
|
|
|
|
!define PS '"$WINDIR\Sysnative\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass'
|
|
|
|
Var LogDir
|
|
|
|
Function .onInit
|
|
ReadEnvStr $LogDir "ProgramData"
|
|
StrCpy $LogDir "$LogDir\Verae\logs"
|
|
${If} ${RunningX64}
|
|
SetRegView 64
|
|
${Else}
|
|
MessageBox MB_ICONSTOP "This debug build targets 64-bit Windows."
|
|
Abort
|
|
${EndIf}
|
|
FunctionEnd
|
|
|
|
Function un.onInit
|
|
SetRegView 64
|
|
FunctionEnd
|
|
|
|
Section "Verae Print Stamp + printer" SecMain
|
|
SectionIn RO
|
|
; stop a running helper so files can be replaced
|
|
nsExec::ExecToLog 'taskkill /F /IM verae-printhelper.exe'
|
|
Pop $0
|
|
|
|
SetOutPath "$INSTDIR\bin"
|
|
File "${SRCDIR}\verae-print.exe"
|
|
File "${SRCDIR}\verae-printhelper.exe"
|
|
SetOutPath "$INSTDIR\scripts"
|
|
File "${SRCDIR}\scripts\install-printer.ps1"
|
|
File "${SRCDIR}\scripts\uninstall-printer.ps1"
|
|
File "${SRCDIR}\scripts\verae-diag.ps1"
|
|
SetOutPath "$INSTDIR"
|
|
File "${SRCDIR}\README-TEST.txt"
|
|
File "${SRCDIR}\LICENSE.txt"
|
|
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
|
|
|
; Remove the old per-user 0.1.2 CLI-only install (it shadows PATH and has no printer)
|
|
DetailPrint "Removing old per-user install in $LOCALAPPDATA\Verae\PrintStamp (if any)"
|
|
Delete "$LOCALAPPDATA\Verae\PrintStamp\bin\verae-print.exe"
|
|
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\VeraePrintStamp"
|
|
|
|
WriteRegStr HKLM "${UNINST_KEY}" "DisplayName" "${PRODUCT_NAME} ${VERSION}"
|
|
WriteRegStr HKLM "${UNINST_KEY}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
|
|
WriteRegStr HKLM "${UNINST_KEY}" "DisplayVersion" "${VERSION}"
|
|
WriteRegStr HKLM "${UNINST_KEY}" "Publisher" "Verae"
|
|
|
|
CreateDirectory "$SMPROGRAMS\Verae"
|
|
CreateShortCut "$SMPROGRAMS\Verae\Verae - Collect diagnostics.lnk" "$WINDIR\System32\WindowsPowerShell\v1.0\powershell.exe" '-NoProfile -ExecutionPolicy Bypass -NoExit -File "$INSTDIR\scripts\verae-diag.ps1"'
|
|
CreateShortCut "$SMPROGRAMS\Verae\Verae - Setup signing key.lnk" "$INSTDIR\bin\verae-print.exe" "setup"
|
|
CreateShortCut "$SMPROGRAMS\Verae\Verae - Start print helper.lnk" "$INSTDIR\bin\verae-printhelper.exe"
|
|
CreateShortCut "$SMPROGRAMS\Verae\Verae - Logs folder.lnk" "$WINDIR\explorer.exe" '"$LogDir"'
|
|
CreateShortCut "$SMPROGRAMS\Verae\Uninstall Verae Print Stamp (debug).lnk" "$INSTDIR\Uninstall.exe"
|
|
|
|
DetailPrint "Installing printer(s) — full transcript in $LogDir"
|
|
nsExec::ExecToLog '${PS} -File "$INSTDIR\scripts\install-printer.ps1" -InstallDir "$INSTDIR"'
|
|
Pop $0
|
|
${If} $0 == "0"
|
|
DetailPrint "Verae printer install: OK"
|
|
${Else}
|
|
DetailPrint "Verae printer install: FAILED (exit $0) — run Start menu > Verae > Collect diagnostics"
|
|
MessageBox MB_ICONEXCLAMATION "Printer setup reported a problem (exit $0).$\r$\nLogs: $LogDir$\r$\nPlease run Start > Verae > Collect diagnostics and send the zip from your Desktop."
|
|
${EndIf}
|
|
SectionEnd
|
|
|
|
Section "Uninstall"
|
|
nsExec::ExecToLog '${PS} -File "$INSTDIR\scripts\uninstall-printer.ps1"'
|
|
Pop $0
|
|
nsExec::ExecToLog 'taskkill /F /IM verae-printhelper.exe'
|
|
Pop $0
|
|
Delete "$INSTDIR\bin\verae-print.exe"
|
|
Delete "$INSTDIR\bin\verae-printhelper.exe"
|
|
RMDir "$INSTDIR\bin"
|
|
Delete "$INSTDIR\scripts\*.ps1"
|
|
RMDir "$INSTDIR\scripts"
|
|
Delete "$INSTDIR\README-TEST.txt"
|
|
Delete "$INSTDIR\LICENSE.txt"
|
|
Delete "$INSTDIR\Uninstall.exe"
|
|
RMDir "$INSTDIR"
|
|
Delete "$SMPROGRAMS\Verae\*.lnk"
|
|
RMDir "$SMPROGRAMS\Verae"
|
|
DeleteRegKey HKLM "${UNINST_KEY}"
|
|
DeleteRegKey HKLM "Software\Verae\PrintStamp"
|
|
; logs in %ProgramData%\Verae\logs are kept on purpose
|
|
SectionEnd
|