Ultimaker-Cura.nsi.jinja 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 }} {{ version_major }}.{{ version_minor }}.{{ version_patch }}"
  4. !define COMP_NAME "{{ company }}"
  5. !define WEB_SITE "{{ web_site }}"
  6. !define VERSION "{{ version_major }}.{{ version_minor }}.{{ version_patch }}.{{ version_build }}"
  7. !define COPYRIGHT "Copyright (c) {{ year }} {{ company }}"
  8. !define DESCRIPTION "Application"
  9. !define LICENSE_TXT "{{ cura_license_file }}"
  10. !define INSTALLER_NAME "{{ destination }}"
  11. !define MAIN_APP_EXE "{{ main_app }}"
  12. !define INSTALL_TYPE "SetShellVarContext all"
  13. !define REG_ROOT "HKCU"
  14. !define REG_APP_PATH "Software\Microsoft\Windows\CurrentVersion\App Paths\${MAIN_APP_EXE}"
  15. !define UNINSTALL_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
  16. !define REG_START_MENU "Start Menu Folder"
  17. ;Require administrator access
  18. RequestExecutionLevel admin
  19. var SM_Folder
  20. ######################################################################
  21. VIProductVersion "${VERSION}"
  22. VIAddVersionKey "ProductName" "${APP_NAME}"
  23. VIAddVersionKey "CompanyName" "${COMP_NAME}"
  24. VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
  25. VIAddVersionKey "FileDescription" "${DESCRIPTION}"
  26. VIAddVersionKey "FileVersion" "${VERSION}"
  27. ######################################################################
  28. SetCompressor {{ compression_method }}
  29. Name "${APP_NAME}"
  30. Caption "${APP_NAME}"
  31. OutFile "${INSTALLER_NAME}"
  32. BrandingText "${APP_NAME}"
  33. InstallDirRegKey "${REG_ROOT}" "${REG_APP_PATH}" ""
  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 "{{ app_name }}"
  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\${APP_NAME} website.url" "InternetShortcut" "URL" "${WEB_SITE}"
  87. CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME} Website.lnk" "$INSTDIR\${APP_NAME} 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\${APP_NAME} website.url" "InternetShortcut" "URL" "${WEB_SITE}"
  97. CreateShortCut "$SMPROGRAMS\{{ app_name }}\${APP_NAME} Website.lnk" "$INSTDIR\${APP_NAME} 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 Uninstall
  112. ${INSTALL_TYPE}{% for files in mapped_out_paths.values() %}{% for file in files %}
  113. Delete "{{ file[1] }}"{% endfor %}{% endfor %}{% for rem_dir in rmdir_paths %}
  114. RmDir "{{ rem_dir }}"{% endfor %}
  115. # FIXME: dirty solution, but for some reason these directories aren't removed
  116. RmDir "$INSTDIR\share\cura\resources\scripts"
  117. RmDir "$INSTDIR\share\cura\resources"
  118. RmDir "$INSTDIR\share\cura"
  119. RmDir "$INSTDIR\share\uranium\resources\scripts"
  120. RmDir "$INSTDIR\share\uranium\resources"
  121. RmDir "$INSTDIR\share\uranium"
  122. RmDir "$INSTDIR\share"
  123. Delete "$INSTDIR\uninstall.exe"
  124. !ifdef WEB_SITE
  125. Delete "$INSTDIR\${APP_NAME} website.url"
  126. !endif
  127. RmDir "$INSTDIR"
  128. !ifdef REG_START_MENU
  129. !insertmacro MUI_STARTMENU_GETFOLDER "Application" $SM_Folder
  130. Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk"
  131. Delete "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk"
  132. !ifdef WEB_SITE
  133. Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME} Website.lnk"
  134. !endif
  135. RmDir "$SMPROGRAMS\$SM_Folder"
  136. !endif
  137. !ifndef REG_START_MENU
  138. Delete "$SMPROGRAMS\{{ app_name }}\${APP_NAME}.lnk"
  139. Delete "$SMPROGRAMS\{{ app_name }}\Uninstall ${APP_NAME}.lnk"
  140. !ifdef WEB_SITE
  141. Delete "$SMPROGRAMS\{{ app_name }}\${APP_NAME} Website.lnk"
  142. !endif
  143. RmDir "$SMPROGRAMS\{{ app_name }}"
  144. !endif
  145. !insertmacro APP_UNASSOCIATE "stl" "Cura.model"
  146. !insertmacro APP_UNASSOCIATE "3mf" "Cura.project"
  147. DeleteRegKey ${REG_ROOT} "${REG_APP_PATH}"
  148. DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
  149. SectionEnd
  150. ######################################################################