diff --git a/.gitmodules b/.gitmodules index 5759c03f6..f22fa3235 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "resources/scripts/nsis"] path = resources/scripts/nsis url = https://github.com/martinrotter/nsis.git +[submodule "resources/scripts/findreplace"] + path = resources/scripts/findreplace + url = https://github.com/martinrotter/findreplace.git diff --git a/resources/nsis/NSIS.template.in b/resources/nsis/NSIS.template.in index db16900af..63466ec34 100755 --- a/resources/nsis/NSIS.template.in +++ b/resources/nsis/NSIS.template.in @@ -169,10 +169,11 @@ LangString DESC_StartMenuShortcuts ${LANG_ENGLISH} "Start Menu Shortcuts for ${A ; Uninstaller section. Section "Uninstall" - ; Remove core application files & directories. - @CPACK_NSIS_DELETE_FILES@ - @CPACK_NSIS_DELETE_DIRECTORIES@ - + ; Here remove all files, but skip "data" folder. + Push "$INSTDIR" + Push "data" + Call RmDirsButOne + ; Remove uninstaller. Delete "$INSTDIR\Uninstall.exe" @@ -192,17 +193,43 @@ SectionEnd ;-------------------------------- ; Custom functions. +Function RmDirsButOne + Exch $R0 ; exclude dir + Exch + Exch $R1 ; route dir + Push $R2 + Push $R3 + + ClearErrors + FindFirst $R3 $R2 "$R1\*.*" + IfErrors Exit + + Top: + StrCmp $R2 "." Next + StrCmp $R2 ".." Next + StrCmp $R2 $R0 Next + IfFileExists "$R1\$R2\*.*" 0 Next + RmDir /r "$R1\$R2" + + #Goto Exit ;uncomment this to stop it being recursive (delete only one dir) + + Next: + ClearErrors + FindNext $R3 $R2 + IfErrors Exit + Goto Top + + Exit: + FindClose $R3 + + Pop $R3 + Pop $R2 + Pop $R1 + Pop $R0 +FunctionEnd + ; Executed when installer starts. Function .onInit IntOp $0 ${SF_SELECTED} | ${SF_RO} SectionSetFlags ${Core} $0 -FunctionEnd - -; Conditional saving to registry. -Function ConditionalAddToRegisty - Pop $0 - Pop $1 - StrCmp "$0" "" ConditionalAddToRegisty_EmptyString - WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" "$1" "$0" - ConditionalAddToRegisty_EmptyString: FunctionEnd \ No newline at end of file diff --git a/resources/scripts/findreplace b/resources/scripts/findreplace new file mode 160000 index 000000000..b72408bec --- /dev/null +++ b/resources/scripts/findreplace @@ -0,0 +1 @@ +Subproject commit b72408bece60b888a9257da2039441b221803a19