Skip to content
⌘ NSIS Forum Archive

Create PatchInstaller NSH-Script from Template

1 posts

abramar#

Create PatchInstaller NSH-Script from Template

we have introduced a patch installer for our software. Therefore we are using CMake with NSIS with WPatch Plugin to identify modified files between two releases and generate a WGenPatDir.nsh file. Our goal is to modify the Patch function like this:

Function Patch

StrCmp $3 "CHECK" after_save
IfFileExists '$INSTDIR\$0' 0 after_save
DetailPrint "Rename orignal file $INSTDIR\$0 to $INSTDIR\$0.orig"
Rename '$INSTDIR\$0' '$INSTDIR\$0.orig'
after_save:
DetailPrint 'Patch: $0'
StrCpy $0 '$INSTDIR\$0'
retry:
WPatch::PatchFile /NOUNLOAD ; expects $0:file path, $1😳ptions, $2😛atch path
IntCmp $1 0 continue can_skip 0
SetErrors
can_skip:
SetDetailsPrint listonly
DetailPrint '=> Error $1'
SetDetailsPrint both
IntCmp $1 1 0 continue continue
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(^FileError_NoIgnore) /SD IDCANCEL IDRETRY retry
Abort
continue:
FunctionEnd
This function ensure, that original files will be renamed to new ending “.orig”.

Is there a possibility to adapt the generated WGenPatDir-File? Maybe a template file, which is used during generation process.