supertuxkart-github-actions.nsi 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. ; Before you start you will need the shelllink plugin for NSIS
  2. ; http://nsis.sourceforge.net/ShellLink_plug-in
  3. ; Download it from the nsis webpage, and unzip it in the NSIS
  4. ; install dir.
  5. ;
  6. ; To use just put this in a directory below the supertuxkart directory
  7. ; which should be called "supertuxkart" and then copy the
  8. ; GPL in the supertuxkart directory to 'license.txt'.
  9. ; You will then need to make an icon, you can use:
  10. ; http://tools.dynamicdrive.com/favicon/ to convert a png to an icon.
  11. ; Once you have made an icon put it in the supertuxkart dir and call it
  12. ; icon.ico. You will need to do the same for install.ico and uninstall.ico
  13. ; Once there done then all you need to do is compile with NSIS.
  14. Unicode True
  15. ;--------------------------------
  16. ;Include Modern UI
  17. !include "MUI2.nsh"
  18. ;--------------------------------
  19. ;Include LogicLib http://nsis.sourceforge.net/LogicLib
  20. !include 'LogicLib.nsh'
  21. ;--------------------------------
  22. ;Include FileFunc lib
  23. !include "FileFunc.nsh"
  24. ;--------------------------------
  25. ;Include x64 lib
  26. !include "x64.nsh"
  27. ;--------------------------------
  28. ; We save ShellLink.dll in current directory
  29. !addplugindir .
  30. ;--------------------------------
  31. ;General
  32. ;Name and file
  33. !define APPNAME "SuperTuxKart"
  34. !define APPNAMEANDVERSION ""
  35. !define ARCH ""
  36. !define VERSION ""
  37. !define DESCRIPTION "3D open-source arcade racer with a variety characters, tracks, and modes to play"
  38. Name "${APPNAMEANDVERSION}"
  39. OutFile ""
  40. # These will be displayed by the "Click here for support information" link in "Add/Remove Programs"
  41. # It is possible to use "mailto:" links in here to open the email client
  42. !define HELPURL "https://supertuxkart.net/" # "Support Information" link
  43. !define UPDATEURL "https://supertuxkart.net/" # "Product Updates" link
  44. !define ABOUTURL "https://supertuxkart.net/" # "Publisher" link
  45. RequestExecutionLevel admin
  46. ; Overwrite later by onInit
  47. InstallDir "$PROGRAMFILES\${APPNAMEANDVERSION}"
  48. ;Get installation folder from registry if available
  49. InstallDirRegKey HKCU "Software\${APPNAMEANDVERSION}" ""
  50. ;Sets the text in the bottom corner
  51. BrandingText "${APPNAMEANDVERSION} Installer"
  52. ;Set the icon
  53. !define MUI_ICON "install.ico"
  54. !define MUI_UNICON "uninstall.ico"
  55. !define MUI_HEADERIMAGE
  56. !define MUI_WELCOMEFINISHPAGE_BITMAP "stk_installer.bmp"
  57. !define MUI_WELCOMEFINISHPAGE_BITMAP_NOSTRETCH
  58. !define MUI_HEADERIMAGE_BITMAP "logo_slim.bmp"
  59. ;!define MUI_TEXT_INSTALLING_SUBTITLE "Please vote for SuperTuxKart to become SourceForge's Project of the month at vote.supertuxkart.net"
  60. ;!define MUI_TEXT_FINISH_INFO_TEXT "Please vote for SuperTuxKart to become $\"Project of the Month$\" at vote.supertuxkart.net"
  61. ; Sets the compressor to /SOLID lzma which when I (hiker) tested was the best.
  62. ; Between LZMA and zlib there is only a 20 MB difference.
  63. SetCompressor /SOLID zlib
  64. ;Vista redirects $SMPROGRAMS to all users without this
  65. RequestExecutionLevel admin
  66. ; For the uninstaller in the remove programs
  67. !define ADD_REMOVE_KEY_NAME "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAMEANDVERSION}"
  68. Function .onInit
  69. ;Default installation folder
  70. ${If} "${ARCH}" == "x86_64"
  71. ${OrIf} "${ARCH}" == "aarch64"
  72. ${If} ${RunningX64}
  73. ${OrIf} ${IsNativeARM64}
  74. StrCpy $INSTDIR "$PROGRAMFILES64\${APPNAMEANDVERSION}"
  75. ${Else}
  76. StrCpy $INSTDIR "$PROGRAMFILES\${APPNAMEANDVERSION}"
  77. ${EndIf}
  78. ${Else}
  79. ${If} ${RunningX64}
  80. ${OrIf} ${IsNativeARM64}
  81. StrCpy $INSTDIR "$PROGRAMFILES32\${APPNAMEANDVERSION}"
  82. ${Else}
  83. StrCpy $INSTDIR "$PROGRAMFILES\${APPNAMEANDVERSION}"
  84. ${EndIf}
  85. ${EndIf}
  86. FunctionEnd
  87. ;--------------------------------
  88. ;Variables
  89. Var MUI_TEMP
  90. Var STARTMENU_FOLDER
  91. ;--------------------------------
  92. ;Interface Settings
  93. !define MUI_ABORTWARNING
  94. ;--------------------------------
  95. Function validate_dir
  96. IfFileExists $INSTDIR\data\*.* 0 return
  97. IfFileExists $INSTDIR\Uninstall.exe 0 dont_uninstall
  98. MessageBox MB_YESNO "You can't install ${APPNAMEANDVERSION} in an existing directory. Do you wish to run the uninstaller in $INSTDIR?" IDNO dont_uninstall
  99. ; -?=$INSTDIR makes sure that this installer waits for the uninstaller
  100. ; to finish. The uninstaller (and directory) are not removed, but the
  101. ; uninstaller will be overwritten by our installer anyway.
  102. ExecWait '"$INSTDIR\Uninstall.exe" _?=$INSTDIR'
  103. goto return
  104. dont_uninstall:
  105. MessageBox MB_OK "You can't install ${APPNAMEANDVERSION} in an existing directory. Please select a new directory."
  106. abort
  107. return:
  108. FunctionEnd
  109. ;--------------------------------
  110. ;Pages
  111. ;Installer pages
  112. !insertmacro MUI_PAGE_WELCOME
  113. !insertmacro MUI_PAGE_LICENSE "..\..\COPYING"
  114. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE validate_dir
  115. !insertmacro MUI_PAGE_DIRECTORY
  116. ;Start Menu Folder Page Configuration
  117. !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
  118. !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${APPNAMEANDVERSION}"
  119. !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
  120. !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
  121. !insertmacro MUI_PAGE_INSTFILES
  122. ;!define MUI_FINISHPAGE_LINK "Please vote for SuperTuxkart here"
  123. ;!define MUI_FINISHPAGE_LINK_LOCATION "http://vote.supertuxkart.net"
  124. !insertmacro MUI_PAGE_FINISH
  125. ;Uninstaller pages
  126. !insertmacro MUI_UNPAGE_WELCOME
  127. !insertmacro MUI_UNPAGE_CONFIRM
  128. !insertmacro MUI_UNPAGE_INSTFILES
  129. !insertmacro MUI_UNPAGE_FINISH
  130. ;--------------------------------
  131. ;Languages
  132. !insertmacro MUI_LANGUAGE "English"
  133. ; ---------------------------------------------------------------------------
  134. ; based on http://nsis.sourceforge.net/Check_if_a_file_exists_at_compile_time
  135. ; Sets the variable _VAR_NAME to _FILE_NAME if _VAR_NAME is not defined yet
  136. ; and _FILE_NAME exists:
  137. !macro !setIfUndefinedAndExists _VAR_NAME _FILE_NAME
  138. !ifndef ${_VAR_NAME}
  139. !tempfile _TEMPFILE
  140. !ifdef NSIS_WIN32_MAKENSIS
  141. ; Windows - cmd.exe
  142. !system 'if exist "${_FILE_NAME}" echo !define ${_VAR_NAME} "${_FILE_NAME}" > "${_TEMPFILE}"'
  143. !else
  144. ; Posix - sh
  145. !system 'if [ -e "${_FILE_NAME}" ]; then echo "!define ${_VAR_NAME} ${_FILE_NAME}" > "${_TEMPFILE}"; fi'
  146. !endif
  147. !include '${_TEMPFILE}'
  148. !delfile '${_TEMPFILE}'
  149. !undef _TEMPFILE
  150. !endif
  151. !macroend
  152. !define !setIfUndefinedAndExists "!insertmacro !setIfUndefinedAndExists"
  153. ;--------------------------------
  154. ;Installer Sections
  155. Section "Install" SecMain
  156. SetOutPath "$INSTDIR"
  157. ; files in root dir
  158. ; Try to find the binary directory in a list of 'typical' names:
  159. ; The first found directory is used
  160. ;${!setIfUndefinedAndExists} EXEC_PATH ..\..\bld\bin\RelWithDebInfo\*.*
  161. ;${!setIfUndefinedAndExists} EXEC_PATH ..\..\bld\bin\Release\*.*
  162. ;${!setIfUndefinedAndExists} EXEC_PATH ..\..\build\bin\RelWithDebInfo\*.*
  163. ;${!setIfUndefinedAndExists} EXEC_PATH ..\..\build\bin\Release\*.*
  164. ;${!setIfUndefinedAndExists} EXEC_PATH ..\..\cmake_build\bin\RelWithDebInfo\*.*
  165. ;${!setIfUndefinedAndExists} EXEC_PATH ..\..\cmake_build\bin\Release\*.*
  166. ; Check various options for the editor. Note that us devs mostly use 'bld',
  167. ; but documented is the name 'build'
  168. ;${!setIfUndefinedAndExists} EDITOR_PATH ..\..\..\editor\bld\RelWithDebInfo
  169. ;${!setIfUndefinedAndExists} EDITOR_PATH ..\..\..\editor\bld\Release
  170. ;${!setIfUndefinedAndExists} EDITOR_PATH ..\..\..\stk-editor\bld\RelWithDebInfo
  171. ;${!setIfUndefinedAndExists} EDITOR_PATH ..\..\..\stk-editor\bld\Release
  172. ;${!setIfUndefinedAndExists} EDITOR_PATH ..\..\..\supertuxkart-editor\bld\RelWithDebInfo
  173. ;${!setIfUndefinedAndExists} EDITOR_PATH ..\..\..\supertuxkart-editor\bld\Release
  174. ;${!setIfUndefinedAndExists} EDITOR_PATH ..\..\..\editor\build\RelWithDebInfo
  175. ;${!setIfUndefinedAndExists} EDITOR_PATH ..\..\..\editor\build\Release
  176. ;${!setIfUndefinedAndExists} EDITOR_PATH ..\..\..\stk-editor\build\RelWithDebInfo
  177. ;${!setIfUndefinedAndExists} EDITOR_PATH ..\..\..\stk-editor\build\Release
  178. ;${!setIfUndefinedAndExists} EDITOR_PATH ..\..\..\supertuxkart-editor\build\RelWithDebInfo
  179. ;${!setIfUndefinedAndExists} EDITOR_PATH ..\..\..\supertuxkart-editor\build\Release
  180. File /x *.ilk ..\..\build-${ARCH}\bin\*.*
  181. !ifdef EDITOR_PATH
  182. File ${EDITOR_PATH}\supertuxkart-editor.exe ${EDITOR_PATH}\supertuxkart-editor.pdb
  183. File ${EDITOR_PATH}\..\..\supertuxkart-editor.ico
  184. !endif
  185. File *.ico
  186. ; data + assets
  187. SetOutPath "$INSTDIR\data\"
  188. File /r /x .svn /x wip-* ..\..\..\stk-assets\*.*
  189. File /r /x *.sh ..\..\data\*.*
  190. ;Store installation folder
  191. WriteRegStr HKCU "Software\${APPNAMEANDVERSION}" "" $INSTDIR
  192. ;Create uninstaller
  193. WriteUninstaller "$INSTDIR\Uninstall.exe"
  194. !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  195. ;Create shortcuts
  196. SetShellVarContext all
  197. CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
  198. CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall ${APPNAMEANDVERSION}.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\uninstall.ico"
  199. CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\${APPNAMEANDVERSION}.lnk" "$INSTDIR\supertuxkart.exe" "" "$INSTDIR\icon.ico"
  200. !ifdef EDITOR_PATH
  201. CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\supertuxkart-editor (beta).lnk" "$INSTDIR\supertuxkart-editor.exe" "" "$INSTDIR\supertuxkart-editor.ico"
  202. !endif
  203. ShellLink::SetShortCutShowMode $SMPROGRAMS\$STARTMENU_FOLDER\SuperTuxKart.lnk 0
  204. !insertmacro MUI_STARTMENU_WRITE_END
  205. ; Registry information for add/remove programs
  206. ; See http://nsis.sourceforge.net/Add_uninstall_information_to_Add/Remove_Programs
  207. WriteRegStr HKLM "${ADD_REMOVE_KEY_NAME}" \
  208. "DisplayName" "${APPNAMEANDVERSION} - ${ARCH}"
  209. WriteRegStr HKLM "${ADD_REMOVE_KEY_NAME}" "Publisher" "SuperTuxKart Team"
  210. WriteRegStr HKLM "${ADD_REMOVE_KEY_NAME}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
  211. WriteRegStr HKLM "${ADD_REMOVE_KEY_NAME}" "DisplayIcon" "$\"$INSTDIR\icon.ico$\""
  212. WriteRegStr HKLM "${ADD_REMOVE_KEY_NAME}" "DisplayVersion" "${VERSION}"
  213. WriteRegStr HKLM "${ADD_REMOVE_KEY_NAME}" "HelpLink" "${HELPURL}"
  214. WriteRegStr HKLM "${ADD_REMOVE_KEY_NAME}" "URLUpdateInfo" "${UPDATEURL}"
  215. WriteRegStr HKLM "${ADD_REMOVE_KEY_NAME}" "URLInfoAbout" "${ABOUTURL}"
  216. # There is no option for modifying or repairing the install
  217. WriteRegStr HKLM "${ADD_REMOVE_KEY_NAME}" "NoModify" 1
  218. WriteRegStr HKLM "${ADD_REMOVE_KEY_NAME}" "NoRepair" 1
  219. ; Write size
  220. ; [...copy all files here, before GetSize...]
  221. ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
  222. IntFmt $0 "0x%08X" $0
  223. WriteRegDWORD HKLM "${ADD_REMOVE_KEY_NAME}" "EstimatedSize" "$0"
  224. SectionEnd
  225. ;--------------------------------
  226. ;Uninstaller Section
  227. Section "Uninstall" redist
  228. ;Removes all the supertuxkart data files
  229. ; DO NOT USE RMDIR ... $INSTDIR\*.* - if someone should e.g.
  230. ; install supertuxkart in c:\Program Files (note: no subdirectory)
  231. ; this could remove all files in Program Files!!!!!!!!!!!!!!!!!!!
  232. ; GitHub Actions script will add installed files as seen in windows.yml
  233. RMDir /r /REBOOTOK $INSTDIR\data
  234. DELETE /REBOOTOK "$INSTDIR\install.ico"
  235. DELETE /REBOOTOK "$INSTDIR\icon.ico"
  236. DELETE /REBOOTOK "$INSTDIR\supertuxkart.ico"
  237. DELETE /REBOOTOK "$INSTDIR\supertuxkart.icon"
  238. DELETE /REBOOTOK "$INSTDIR\uninstall.ico"
  239. Delete /REBOOTOK "$INSTDIR\Uninstall.exe"
  240. ;DELETE /REBOOTOK "$INSTDIR\supertuxkart-editor.exe"
  241. ;DELETE /REBOOTOK "$INSTDIR\supertuxkart-editor.ico"
  242. ;DELETE /REBOOTOK "$INSTDIR\supertuxkart-editor.pdb"
  243. RMDir "$INSTDIR"
  244. SetShellVarContext all
  245. ;Remove start menu items
  246. !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
  247. Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall ${APPNAMEANDVERSION}.lnk"
  248. Delete "$SMPROGRAMS\$MUI_TEMP\${APPNAMEANDVERSION}.lnk"
  249. ;Delete "$SMPROGRAMS\$MUI_TEMP\supertuxkart-editor (beta).lnk"
  250. ;Delete empty start menu parent diretories
  251. StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
  252. startMenuDeleteLoop:
  253. ClearErrors
  254. RMDir $MUI_TEMP
  255. GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
  256. IfErrors startMenuDeleteLoopDone
  257. StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
  258. startMenuDeleteLoopDone:
  259. DeleteRegKey /ifempty HKCU "Software\${APPNAMEANDVERSION}"
  260. DeleteRegKey HKLM "${ADD_REMOVE_KEY_NAME}"
  261. SectionEnd