Ultimaker-Cura.nsi.jinja 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. # Copyright (c) 2022 UltiMaker B.V.
  2. # Cura's build system is released under the terms of the AGPLv3 or higher.
  3. !define APP_NAME "{{ app_name }}"
  4. !define COMP_NAME "{{ company }}"
  5. !define WEB_SITE "{{ web_site }}"
  6. !define VERSION "{{ version }}"
  7. !define VIVERSION "{{ version_major }}.{{ version_minor }}.{{ version_patch }}.0"
  8. !define COPYRIGHT "Copyright (c) {{ year }} {{ company }}"
  9. !define DESCRIPTION "Application"
  10. !define LICENSE_TXT "{{ cura_license_file }}"
  11. !define INSTALLER_NAME "{{ destination }}"
  12. !define MAIN_APP_EXE "{{ main_app }}"
  13. !define INSTALL_TYPE "SetShellVarContext all"
  14. !define REG_ROOT "HKLM"
  15. !define REG_APP_PATH "Software\Microsoft\Windows\CurrentVersion\App Paths\${APP_NAME}-${VERSION}"
  16. !define UNINSTALL_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}-${VERSION}"
  17. !define REG_START_MENU "Start Menu Folder"
  18. ;Require administrator access
  19. RequestExecutionLevel admin
  20. var SM_Folder
  21. ######################################################################
  22. VIProductVersion "${VIVERSION}"
  23. VIAddVersionKey "ProductName" "{{ app_name }}"
  24. VIAddVersionKey "CompanyName" "${COMP_NAME}"
  25. VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
  26. VIAddVersionKey "FileDescription" "${DESCRIPTION}"
  27. VIAddVersionKey "FileVersion" "${VIVERSION}"
  28. ######################################################################
  29. SetCompressor {{ compression_method }}
  30. Name "${APP_NAME}"
  31. Caption "${APP_NAME}"
  32. OutFile "${INSTALLER_NAME}"
  33. BrandingText "${APP_NAME}"
  34. InstallDir "$PROGRAMFILES64\${APP_NAME}"
  35. ######################################################################
  36. !include "MUI2.nsh"
  37. !include fileassoc.nsh
  38. !define MUI_ABORTWARNING
  39. !define MUI_UNABORTWARNING
  40. !define MUI_ICON "{{ cura_icon }}"
  41. !define MUI_WELCOMEFINISHPAGE_BITMAP "{{ cura_banner_img }}"
  42. !define MUI_UNWELCOMEFINISHPAGE_BITMAP "{{ cura_banner_img }}"
  43. !insertmacro MUI_PAGE_WELCOME
  44. !ifdef LICENSE_TXT
  45. !insertmacro MUI_PAGE_LICENSE "${LICENSE_TXT}"
  46. !endif
  47. !insertmacro MUI_PAGE_DIRECTORY
  48. !ifdef REG_START_MENU
  49. !define MUI_STARTMENUPAGE_NODISABLE
  50. !define MUI_STARTMENUPAGE_DEFAULTFOLDER "UltiMaker Cura"
  51. !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${REG_ROOT}"
  52. !define MUI_STARTMENUPAGE_REGISTRY_KEY "${UNINSTALL_PATH}"
  53. !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${REG_START_MENU}"
  54. !insertmacro MUI_PAGE_STARTMENU Application $SM_Folder
  55. !endif
  56. !insertmacro MUI_PAGE_INSTFILES
  57. # Set up explorer to run Cura instead of directly, so it's not executed elevated (with all negative consequences that brings for an unelevated user).
  58. !define MUI_FINISHPAGE_RUN "$WINDIR\explorer.exe"
  59. !define MUI_FINISHPAGE_RUN_PARAMETERS "$INSTDIR\${MAIN_APP_EXE}"
  60. !insertmacro MUI_PAGE_FINISH
  61. !insertmacro MUI_UNPAGE_CONFIRM
  62. !insertmacro MUI_UNPAGE_INSTFILES
  63. !insertmacro MUI_UNPAGE_FINISH
  64. !insertmacro MUI_LANGUAGE "English"
  65. ######################################################################
  66. Section -MainProgram
  67. ${INSTALL_TYPE}
  68. SetOverwrite ifnewer
  69. {% for out_path, files in mapped_out_paths.items() %}SetOutPath "{{ out_path }}"{% for file in files %}
  70. File "{{ file[0] }}"{% endfor %}
  71. {% endfor %}SectionEnd
  72. ######################################################################
  73. Section -Extension_Reg
  74. !insertmacro APP_ASSOCIATE "stl" "Cura.model" "Standard Tessellation Language (STL) files" "$INSTDIR\${MAIN_APP_EXE},0" "Open with {{ app_name }}" "$INSTDIR\${MAIN_APP_EXE} $\"%1$\""
  75. !insertmacro APP_ASSOCIATE "3mf" "Cura.project" "3D Manufacturing Format (3MF) files" "$INSTDIR\${MAIN_APP_EXE},0" "Open with {{ app_name }}" "$INSTDIR\${MAIN_APP_EXE} $\"%1$\""
  76. SectionEnd
  77. Section -Icons_Reg
  78. SetOutPath "$INSTDIR"
  79. WriteUninstaller "$INSTDIR\uninstall.exe"
  80. !ifdef REG_START_MENU
  81. !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  82. CreateDirectory "$SMPROGRAMS\$SM_Folder"
  83. CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
  84. CreateShortCut "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
  85. !ifdef WEB_SITE
  86. WriteIniStr "$INSTDIR\UltiMaker Cura website.url" "InternetShortcut" "URL" "${WEB_SITE}"
  87. CreateShortCut "$SMPROGRAMS\$SM_Folder\UltiMaker Cura website.lnk" "$INSTDIR\UltiMaker Cura website.url"
  88. !endif
  89. !insertmacro MUI_STARTMENU_WRITE_END
  90. !endif
  91. !ifndef REG_START_MENU
  92. CreateDirectory "$SMPROGRAMS\{{ app_name }}"
  93. CreateShortCut "$SMPROGRAMS\{{ app_name }}\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
  94. CreateShortCut "$SMPROGRAMS\{{ app_name }}\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
  95. !ifdef WEB_SITE
  96. WriteIniStr "$INSTDIR\UltiMaker Cura website.url" "InternetShortcut" "URL" "${WEB_SITE}"
  97. CreateShortCut "$SMPROGRAMS\{{ app_name }}\UltiMaker Cura website.lnk" "$INSTDIR\UltiMaker Cura website.url"
  98. !endif
  99. !endif
  100. WriteRegStr ${REG_ROOT} "${REG_APP_PATH}" "" "$INSTDIR\${MAIN_APP_EXE}"
  101. WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayName" "${APP_NAME}"
  102. WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "UninstallString" "$INSTDIR\uninstall.exe"
  103. WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayIcon" "$INSTDIR\${MAIN_APP_EXE}"
  104. WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayVersion" "${VERSION}"
  105. WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "Publisher" "${COMP_NAME}"
  106. !ifdef WEB_SITE
  107. WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "URLInfoAbout" "${WEB_SITE}"
  108. !endif
  109. SectionEnd
  110. ######################################################################
  111. Section UrlProtocol
  112. WriteRegStr HKCR "cura" "" "URL:cura"
  113. WriteRegStr HKCR "cura" "URL Protocol" ""
  114. WriteRegStr HKCR "cura\DefaultIcon" "" "$INSTDIR\${MAIN_APP_EXE},1"
  115. WriteRegStr HKCR "cura\shell" "" "open"
  116. WriteRegStr HKCR "cura\shell\open\command" "" '"$INSTDIR\${MAIN_APP_EXE}" "%1"'
  117. WriteRegStr HKCR "slicer" "" "URL:slicer"
  118. WriteRegStr HKCR "slicer" "URL Protocol" ""
  119. WriteRegStr HKCR "slicer\DefaultIcon" "" "$INSTDIR\${MAIN_APP_EXE},1"
  120. WriteRegStr HKCR "slicer\shell" "" "open"
  121. WriteRegStr HKCR "slicer\shell\open\command" "" '"$INSTDIR\${MAIN_APP_EXE}" "%1"'
  122. SectionEnd
  123. ######################################################################
  124. Section Uninstall
  125. ${INSTALL_TYPE}{% for files in mapped_out_paths.values() %}{% for file in files %}
  126. Delete "{{ file[1] }}"{% endfor %}{% endfor %}{% for rem_dir in rmdir_paths %}
  127. RmDir "{{ rem_dir }}"{% endfor %}
  128. # FIXME: dirty solution, but for some reason these directories aren't removed
  129. RmDir "$INSTDIR\share\cura\resources\scripts"
  130. RmDir "$INSTDIR\share\cura\resources"
  131. RmDir "$INSTDIR\share\cura"
  132. RmDir "$INSTDIR\share\uranium\resources\scripts"
  133. RmDir "$INSTDIR\share\uranium\resources"
  134. RmDir "$INSTDIR\share\uranium"
  135. RmDir "$INSTDIR\share"
  136. Delete "$INSTDIR\uninstall.exe"
  137. !ifdef WEB_SITE
  138. Delete "$INSTDIR\${APP_NAME} website.url"
  139. !endif
  140. RmDir /r /REBOOTOK "$INSTDIR"
  141. !ifdef REG_START_MENU
  142. !insertmacro MUI_STARTMENU_GETFOLDER "Application" $SM_Folder
  143. Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk"
  144. Delete "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk"
  145. !ifdef WEB_SITE
  146. Delete "$SMPROGRAMS\$SM_Folder\UltiMaker Cura website.lnk"
  147. !endif
  148. RmDir "$SMPROGRAMS\$SM_Folder"
  149. !endif
  150. !ifndef REG_START_MENU
  151. Delete "$SMPROGRAMS\{{ app_name }}\${APP_NAME}.lnk"
  152. Delete "$SMPROGRAMS\{{ app_name }}\Uninstall ${APP_NAME}.lnk"
  153. !ifdef WEB_SITE
  154. Delete "$SMPROGRAMS\{{ app_name }}\UltiMaker Cura website.lnk"
  155. !endif
  156. RmDir "$SMPROGRAMS\{{ app_name }}"
  157. !endif
  158. !insertmacro APP_UNASSOCIATE "stl" "Cura.model"
  159. !insertmacro APP_UNASSOCIATE "3mf" "Cura.project"
  160. ; Unassociate file associations for 'cura' protocol
  161. DeleteRegKey HKCR "cura"
  162. ; Unassociate file associations for 'slicer' protocol
  163. DeleteRegKey HKCR "slicer"
  164. DeleteRegKey ${REG_ROOT} "${REG_APP_PATH}"
  165. DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
  166. SectionEnd