diff options
author | Araq <rumpf_a@web.de> | 2014-10-17 03:27:04 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-10-17 03:27:04 +0200 |
commit | 4accf4292997bda0e9746a152ba202c646e01e11 (patch) | |
tree | 2d69a13fc8e1850604d854ce7692404bad9fd7e3 /tools/niminst | |
parent | bd54c44239ae34b8b8e756e6acfc5dc82f49edb5 (diff) | |
download | Nim-4accf4292997bda0e9746a152ba202c646e01e11.tar.gz |
added missing template file
Diffstat (limited to 'tools/niminst')
-rw-r--r-- | tools/niminst/nsis.tmpl | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/tools/niminst/nsis.tmpl b/tools/niminst/nsis.tmpl new file mode 100644 index 000000000..cea7e0683 --- /dev/null +++ b/tools/niminst/nsis.tmpl @@ -0,0 +1,166 @@ +#! stdtmpl(subsChar='?') | standard +#proc generateNsisSetup(c: TConfigData): string = +# result = "; NSIS script generated by niminst\n" & +# "; To regenerate run ``niminst nsis`` or ``koch nsis``\n" + +!define PRODUCT_NAME "?c.displayName" +!define PRODUCT_VERSION "?c.version" +!define PRODUCT_PUBLISHER "?c.authors" +!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\?{c.name}.exe" +!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" +!define PRODUCT_UNINST_ROOT_KEY "HKCU" +!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir" + +; MUI 1.67 compatible ------ +!include "MUI.nsh" +!define MULTIUSER_EXECUTIONLEVEL Standard +!include "MultiUser.nsh" +!include "zipdll.nsh" + +InstallDir "$LOCALAPPDATA\?{c.name}" + +; MUI Settings +!define MUI_ABORTWARNING +!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" +!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" + +; Welcome page +!insertmacro MUI_PAGE_WELCOME +; License page +!insertmacro MUI_PAGE_LICENSE "?{expandFilename(c.license)}" +; Components page +!insertmacro MUI_PAGE_COMPONENTS +; Directory page +!insertmacro MUI_PAGE_DIRECTORY +; Start menu page +var ICONS_GROUP +!define MUI_STARTMENUPAGE_NODISABLE +!define MUI_STARTMENUPAGE_DEFAULTFOLDER "?c.displayName" +!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}" +!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" +!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}" +!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP +; Instfiles page +!insertmacro MUI_PAGE_INSTFILES +; Finish page +; !define MUI_FINISHPAGE_RUN "$INSTDIR\start.bat" +!insertmacro MUI_PAGE_FINISH + +; Uninstaller pages +!insertmacro MUI_UNPAGE_INSTFILES + +; Language files +!insertmacro MUI_LANGUAGE "English" + +; MUI end ------ + +Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" +OutFile "?{c.name}_?{c.version}.exe" +; InstallDir "$PROGRAMFILES\?c.displayName" +InstallDirRegKey HKCU "${PRODUCT_DIR_REGKEY}" "" +ShowInstDetails show +ShowUnInstDetails show + +Section "Core" SEC0 + SetOverwrite ifnewer + SetOutPath "$INSTDIR" + #for i in low(TFileCategory)..fcWindows: + # for f in items(c.cat[i]): + SetOutPath "$INSTDIR\?{splitFile(f).dir.toWin}" + File "?{expandFilename(f).toWin}" + # end for + #end for + + +; Shortcuts + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application + CreateDirectory "$SMPROGRAMS\$ICONS_GROUP" + + #if c.app == appConsole: + CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\?{c.displayName}.lnk" "$INSTDIR\start.bat" + CreateShortCut "$DESKTOP\?{c.displayName}.lnk" "$INSTDIR\start.bat" + #else: + CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\?{c.displayName}.lnk" "$INSTDIR\?{c.name}.exe" + CreateShortCut "$DESKTOP\?{c.displayName}.lnk" "$INSTDIR\?{c.name}.exe" + #end if + #for f in items(c.cat[fcDocStart]): + CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\?{splitFile(f).name}.lnk" "$INSTDIR\?{f.toWin}" + #end for + + !insertmacro MUI_STARTMENU_WRITE_END +SectionEnd + +#var i = 0 +#for download in c.downloads: +# inc i +# let d = download.split('|') +# if d.len != 5: +# quit("download string needs 5 parts: " & download) +# end if +# let sectionName = d[0] +# let dir = d[1] +# let zipName = d[2] +# let size = d[3] +# let url = d[4] + Section /o "?sectionName" SEC?i + + AddSize ?size + + NSISdl::download "?url" "$INSTDIR\?zipName" + Pop $0 + ${If} $0 == "success" + ZipDLL::extractall "$INSTDIR\?zipName" "$INSTDIR\?dir" + Delete "$INSTDIR\?zipName" + ${Else} + MessageBox mb_iconstop "Error: $0" ;Show cancel/error message + ${EndIf} + +; Shortcuts + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application + !insertmacro MUI_STARTMENU_WRITE_END + SectionEnd +#end + +Section -AdditionalIcons + SetOutPath $INSTDIR + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application + CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninst.exe" + !insertmacro MUI_STARTMENU_WRITE_END +SectionEnd + +Section -Post + WriteUninstaller "$INSTDIR\uninst.exe" + WriteRegStr HKCU "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\bin\?{c.name}.exe" + WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" + WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" + WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\?{c.name}.exe" + WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" + WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" +SectionEnd + +Function .onInit + !insertmacro MULTIUSER_INIT +FunctionEnd + +Function un.onUninstSuccess + HideWindow + MessageBox MB_ICONINFORMATION|MB_OK "Uninstall was completed successfully." +FunctionEnd + +Function un.onInit + MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Remove $(^Name) from your computer." IDYES +2 + !insertmacro MULTIUSER_UNINIT + Abort +FunctionEnd + +Section Uninstall + !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP + Delete "$DESKTOP\?{c.displayName}.lnk" + + RMDir /r "$SMPROGRAMS\$ICONS_GROUP" + RMDir /r "$INSTDIR" + + DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" + DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}" + SetAutoClose true +SectionEnd \ No newline at end of file |