mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
Pure refactor, no behavior change. cmake/NSIS.template.in is the CPack template, and CPack substitutes the @...@ placeholders in that file only, so everything without a substitution moves into cmake/nsis/ and is included from it: installer-log.nsh the CockLog macro and the two writers behind it process-guard.nsh running instance handling, installer and uninstaller copy user-data.nsh backup/restore around the previous version's uninstaller runtime-purge.nsh stale runtime purge, diagnostics and the holder probe The page and section order, the Vars the included files share, .onInit (it names the package version in the log), AbortInstall (its Sentry offer is substituted), componentsPagePre and the registry bookkeeping stay in the template. The includes resolve through NSIS_SOURCE_PATH, which the template already uses for the bitmaps, and an include does not change the compile directory, so the holder probe keeps its relative File path.
72 lines
2.5 KiB
NSIS
72 lines
2.5 KiB
NSIS
; Installer log helpers: CockLog, CockLogWrite and CockLogListing. Included
|
|
; before the first function that logs, because CockLog is a macro and is expanded
|
|
; at the point of use. Nothing here returns anything; CockLogWrite uses
|
|
; $LogMessage/$LogHandle, CockLogListing the $Log* match variables.
|
|
|
|
; Installer log
|
|
; Every run appends a step-by-step trace to a file so a failed upgrade on a
|
|
; user's machine can be diagnosed after the fact. Kept in $TEMP rather than in
|
|
; $INSTDIR because the previous version's uninstaller removes the whole install
|
|
; directory part-way through an upgrade. Read it back with:
|
|
; notepad %TEMP%\Cockatrice-installer.log
|
|
!macro CockLog text
|
|
Push "${text}"
|
|
Call CockLogWrite
|
|
!macroend
|
|
|
|
; The body is shared because the uninstaller needs its own copy: un.* functions are
|
|
; compiled into a separate binary, and inside one a Call may only name an un. function,
|
|
; so CockLog's Call to CockLogWrite cannot be used there.
|
|
!macro CockLogWriteBody
|
|
Pop $LogMessage
|
|
FileOpen $LogHandle "$InstallLogPath" a
|
|
${If} $LogHandle == ""
|
|
Return
|
|
${EndIf}
|
|
; FileOpen places the pointer at the start of the file in every mode, so
|
|
; 'a' alone would overwrite the log from the beginning on each line. Seek
|
|
; past the existing content first to actually append.
|
|
FileSeek $LogHandle 0 END
|
|
FileWrite $LogHandle "$LogMessage$\r$\n"
|
|
FileClose $LogHandle
|
|
!macroend
|
|
|
|
Function CockLogWrite
|
|
!insertmacro CockLogWriteBody
|
|
FunctionEnd
|
|
|
|
; CockLog for un.* code: same lines, prefixed call target.
|
|
!macro CockLogUn text
|
|
Push "${text}"
|
|
Call un.CockLogWrite
|
|
!macroend
|
|
|
|
Function un.CockLogWrite
|
|
!insertmacro CockLogWriteBody
|
|
FunctionEnd
|
|
|
|
; Logs every file matching $INSTDIR\<mask>. Used to record the DLL inventory
|
|
; before and after the upgrade purge, which is what shows whether Qt6Gui.dll was
|
|
; on disk and what (if anything) survived the deletes.
|
|
!macro CockLogListing label mask
|
|
Push "${label}"
|
|
Push "$INSTDIR\${mask}"
|
|
Call CockLogListing
|
|
!macroend
|
|
|
|
Function CockLogListing
|
|
Pop $LogMatchPattern
|
|
Pop $LogMatchLabel
|
|
!insertmacro CockLog "listing [$LogMatchLabel] pattern=$LogMatchPattern"
|
|
FindFirst $LogFindHandle $LogFindName "$LogMatchPattern"
|
|
${If} $LogFindHandle == ""
|
|
!insertmacro CockLog "listing [$LogMatchLabel] (no matches)"
|
|
Return
|
|
${EndIf}
|
|
log_listing_loop:
|
|
!insertmacro CockLog "listing [$LogMatchLabel] $LogFindName"
|
|
ClearErrors
|
|
FindNext $LogFindHandle $LogFindName
|
|
IfErrors 0 log_listing_loop
|
|
FindClose $LogFindHandle
|
|
FunctionEnd
|