GRASS-Installer.nsi.tmpl 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988
  1. ;----------------------------------------------------------------------------------------------------------------------------
  2. ;GRASS GIS Installer for Windows
  3. ;Written by Marco Pasetti
  4. ;Updated for OSGeo4W by Colin Nielsen, Helmut Kudrnovsky, and Martin Landa
  5. ;Last Update: $Id$
  6. ;Mail to: grass-dev@lists.osgeo.org
  7. ;----------------------------------------------------------------------------------------------------------------------------
  8. ;Select if you are building a "Development Version" (Devel) or a "Release Version" (Release) of the GRASS Installer
  9. !define INSTALLER_TYPE "Devel"
  10. ;----------------------------------------------------------------------------------------------------------------------------
  11. ;set compression configuration
  12. SetCompressor /SOLID lzma
  13. SetCompressorDictSize 128
  14. ;----------------------------------------------------------------------------------------------------------------------------
  15. ;Version variables
  16. !if "@GRASS_VERSION_GIT@" == ""
  17. !define GIT_REVISION "0"
  18. !else
  19. !define GIT_REVISION "@GRASS_VERSION_GIT@"
  20. !endif
  21. !define BINARY_REVISION "1"
  22. !define VERSION_NUMBER "@GRASS_VERSION_MAJOR@.@GRASS_VERSION_MINOR@.@GRASS_VERSION_RELEASE@"
  23. !define GRASS_BASE "GRASS GIS @GRASS_VERSION_MAJOR@.@GRASS_VERSION_MINOR@"
  24. !define GRASS_COMMAND "grass@GRASS_VERSION_MAJOR@@GRASS_VERSION_MINOR@"
  25. ;----------------------------------------------------------------------------------------------------------------------------
  26. ;Define Platform and installation folder
  27. ;----------------------------------------------------------------------------------------------------------------------------
  28. !define PLATFORM "x86_64"
  29. InstallDir "$PROGRAMFILES64\${GRASS_BASE}"
  30. ;----------------------------------------------------------------------------------------------------------------------------
  31. ;Don't modify the following lines
  32. ;----------------------------------------------------------------------------------------------------------------------------
  33. ;NSIS Includes
  34. !include "MUI2.nsh"
  35. !include "LogicLib.nsh"
  36. !include "Sections.nsh"
  37. ;----------------------------------------------------------------------------------------------------------------------------
  38. ;Set the installer variables, depending on the selected version to build
  39. !define PACKAGE_FOLDER ".\GRASS-@GRASS_VERSION_MAJOR@@GRASS_VERSION_MINOR@-Package"
  40. !if ${INSTALLER_TYPE} == "Release"
  41. !define INSTALLER_NAME "WinGRASS-${VERSION_NUMBER}-${BINARY_REVISION}-Setup.exe"
  42. !define DISPLAYED_NAME "GRASS GIS ${VERSION_NUMBER}-${BINARY_REVISION}"
  43. !define CHECK_INSTALL_NAME "GRASS GIS @GRASS_VERSION_MAJOR@@GRASS_VERSION_MINOR@"
  44. !else
  45. !define INSTALLER_NAME "WinGRASS-${VERSION_NUMBER}-${GIT_REVISION}-${BINARY_REVISION}-Setup.exe"
  46. !define DISPLAYED_NAME "GRASS GIS ${VERSION_NUMBER}-${GIT_REVISION}-${BINARY_REVISION}"
  47. !define CHECK_INSTALL_NAME "GRASS GIS @GRASS_VERSION_MAJOR@@GRASS_VERSION_MINOR@ GIT"
  48. !endif
  49. ;Define the source path of the demolocation files
  50. !define DEMOLOCATION_PATH "${PACKAGE_FOLDER}\demolocation"
  51. ;----------------------------------------------------------------------------------------------------------------------------
  52. ;Publisher variables
  53. !define PUBLISHER "GRASS Development Team"
  54. !define WEB_SITE "https://grass.osgeo.org"
  55. !define WIKI_PAGE "https://grass.osgeo.org/wiki"
  56. ;----------------------------------------------------------------------------------------------------------------------------
  57. ;General Definitions
  58. ;Name of the application shown during install
  59. Name "${DISPLAYED_NAME}"
  60. ;Name of the output file (installer executable)
  61. OutFile "${INSTALLER_NAME}"
  62. ;Request application privileges for Windows
  63. RequestExecutionLevel admin
  64. ;Tell the installer to hide Install and Uninstall details as default
  65. ShowInstDetails hide
  66. ShowUnInstDetails hide
  67. ;----------------------------------------------------------------------------------------------------------------------------
  68. ;StrReplace Function
  69. ;Replaces all occurrences of a given needle within a haystack with another string
  70. ;Written by dandaman32
  71. Var STR_REPLACE_VAR_0
  72. Var STR_REPLACE_VAR_1
  73. Var STR_REPLACE_VAR_2
  74. Var STR_REPLACE_VAR_3
  75. Var STR_REPLACE_VAR_4
  76. Var STR_REPLACE_VAR_5
  77. Var STR_REPLACE_VAR_6
  78. Var STR_REPLACE_VAR_7
  79. Var STR_REPLACE_VAR_8
  80. Function StrReplace
  81. Exch $STR_REPLACE_VAR_2
  82. Exch 1
  83. Exch $STR_REPLACE_VAR_1
  84. Exch 2
  85. Exch $STR_REPLACE_VAR_0
  86. StrCpy $STR_REPLACE_VAR_3 -1
  87. StrLen $STR_REPLACE_VAR_4 $STR_REPLACE_VAR_1
  88. StrLen $STR_REPLACE_VAR_6 $STR_REPLACE_VAR_0
  89. loop:
  90. IntOp $STR_REPLACE_VAR_3 $STR_REPLACE_VAR_3 + 1
  91. StrCpy $STR_REPLACE_VAR_5 $STR_REPLACE_VAR_0 $STR_REPLACE_VAR_4 $STR_REPLACE_VAR_3
  92. StrCmp $STR_REPLACE_VAR_5 $STR_REPLACE_VAR_1 found
  93. StrCmp $STR_REPLACE_VAR_3 $STR_REPLACE_VAR_6 done
  94. Goto loop
  95. found:
  96. StrCpy $STR_REPLACE_VAR_5 $STR_REPLACE_VAR_0 $STR_REPLACE_VAR_3
  97. IntOp $STR_REPLACE_VAR_8 $STR_REPLACE_VAR_3 + $STR_REPLACE_VAR_4
  98. StrCpy $STR_REPLACE_VAR_7 $STR_REPLACE_VAR_0 "" $STR_REPLACE_VAR_8
  99. StrCpy $STR_REPLACE_VAR_0 $STR_REPLACE_VAR_5$STR_REPLACE_VAR_2$STR_REPLACE_VAR_7
  100. StrLen $STR_REPLACE_VAR_6 $STR_REPLACE_VAR_0
  101. Goto loop
  102. done:
  103. Pop $STR_REPLACE_VAR_1 ; Prevent "invalid opcode" errors and keep the
  104. Pop $STR_REPLACE_VAR_1 ; stack as it was before the function was called
  105. Exch $STR_REPLACE_VAR_0
  106. FunctionEnd
  107. !macro _strReplaceConstructor OUT NEEDLE NEEDLE2 HAYSTACK
  108. Push "${HAYSTACK}"
  109. Push "${NEEDLE}"
  110. Push "${NEEDLE2}"
  111. Call StrReplace
  112. Pop "${OUT}"
  113. !macroend
  114. !define StrReplace '!insertmacro "_strReplaceConstructor"'
  115. ;----------------------------------------------------------------------------------------------------------------------------
  116. ;.onInit Function (called when the installer is nearly finished initializing)
  117. ;Check if GRASS is already installed on the system and, if yes, what version and binary release;
  118. ;depending on that, select the install procedure:
  119. ;1. first installation = if GRASS is not already installed
  120. ;install GRASS asking for the install PATH
  121. ;2. upgrade installation = if an older release of GRASS is already installed
  122. ;call the uninstaller of the currently installed GRASS release
  123. ;if the uninstall procedure succeeded, call the current installer without asking for the install PATH
  124. ;GRASS will be installed in the same PATH of the previous installation
  125. ;3. downgrade installation = if a newer release of GRASS is already installed
  126. ;call the uninstaller of the currently installed GRASS release
  127. ;if the uninstall procedure succeeded, call the current installer without asking for the install PATH
  128. ;GRASS will be installed in the same PATH of the previous installation
  129. ;4. repair installation = if the same release of GRASS is already installed
  130. ;call the uninstaller of the currently installed GRASS release
  131. ;if the uninstall procedure succeeded, call the current installer asking for the install PATH
  132. ;the currently installed release of GRASS is defined by the variable $INSTALLED_VERSION = $INSTALLED_GIT_REVISION + $INSTALLED_BINARY_REVISION
  133. Function .onInit
  134. Var /GLOBAL ASK_FOR_PATH
  135. StrCpy $ASK_FOR_PATH "YES"
  136. Var /GLOBAL UNINSTALL_STRING
  137. Var /GLOBAL INSTALL_PATH
  138. Var /GLOBAL INSTALLED_VERSION_NUMBER
  139. Var /GLOBAL INSTALLED_GIT_REVISION
  140. Var /GLOBAL INSTALLED_BINARY_REVISION
  141. Var /GLOBAL INSTALLED_VERSION
  142. Var /GLOBAL DISPLAYED_INSTALLED_VERSION
  143. Var /GLOBAL MESSAGE_0_
  144. Var /GLOBAL MESSAGE_1_
  145. Var /GLOBAL MESSAGE_2_
  146. Var /GLOBAL MESSAGE_3_
  147. ReadRegStr $UNINSTALL_STRING HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "UninstallString"
  148. ReadRegStr $INSTALL_PATH HKLM "Software\${GRASS_BASE}" "InstallPath"
  149. ReadRegStr $INSTALLED_VERSION_NUMBER HKLM "Software\${GRASS_BASE}" "VersionNumber"
  150. ReadRegStr $INSTALLED_GIT_REVISION HKLM "Software\${GRASS_BASE}" "GitRevision"
  151. ${If} $INSTALLED_GIT_REVISION == ""
  152. ReadRegStr $INSTALLED_GIT_REVISION HKLM "Software\${GRASS_BASE}" "Revision"
  153. ${EndIf}
  154. ReadRegStr $INSTALLED_BINARY_REVISION HKLM "Software\${GRASS_BASE}" "BinaryRevision"
  155. StrCpy $MESSAGE_0_ "${CHECK_INSTALL_NAME} is already installed on your system.$\r$\n"
  156. StrCpy $MESSAGE_0_ "$MESSAGE_0_$\r$\n"
  157. !if ${INSTALLER_TYPE} == "Release"
  158. ${If} $INSTALLED_BINARY_REVISION == ""
  159. StrCpy $DISPLAYED_INSTALLED_VERSION "$INSTALLED_VERSION_NUMBER"
  160. ${Else}
  161. StrCpy $DISPLAYED_INSTALLED_VERSION "$INSTALLED_VERSION_NUMBER-$INSTALLED_BINARY_REVISION"
  162. ${EndIf}
  163. !else
  164. StrCpy $DISPLAYED_INSTALLED_VERSION "$INSTALLED_VERSION_NUMBER-$INSTALLED_GIT_REVISION-$INSTALLED_BINARY_REVISION"
  165. !endif
  166. StrCpy $MESSAGE_0_ "$MESSAGE_0_The installed release is $DISPLAYED_INSTALLED_VERSION$\r$\n"
  167. StrCpy $MESSAGE_1_ "$MESSAGE_0_$\r$\n"
  168. StrCpy $MESSAGE_1_ "$MESSAGE_1_You are going to install a newer release of ${CHECK_INSTALL_NAME}$\r$\n"
  169. StrCpy $MESSAGE_1_ "$MESSAGE_1_$\r$\n"
  170. StrCpy $MESSAGE_1_ "$MESSAGE_1_Press OK to uninstall GRASS $DISPLAYED_INSTALLED_VERSION"
  171. StrCpy $MESSAGE_1_ "$MESSAGE_1_ and install ${DISPLAYED_NAME} or Cancel to quit."
  172. StrCpy $MESSAGE_2_ "$MESSAGE_0_$\r$\n"
  173. StrCpy $MESSAGE_2_ "$MESSAGE_2_You are going to install an older release of ${CHECK_INSTALL_NAME}$\r$\n"
  174. StrCpy $MESSAGE_2_ "$MESSAGE_2_$\r$\n"
  175. StrCpy $MESSAGE_2_ "$MESSAGE_2_Press OK to uninstall GRASS $DISPLAYED_INSTALLED_VERSION"
  176. StrCpy $MESSAGE_2_ "$MESSAGE_2_ and install ${DISPLAYED_NAME} or Cancel to quit."
  177. StrCpy $MESSAGE_3_ "$MESSAGE_0_$\r$\n"
  178. StrCpy $MESSAGE_3_ "$MESSAGE_3_This is the latest release available.$\r$\n"
  179. StrCpy $MESSAGE_3_ "$MESSAGE_3_$\r$\n"
  180. StrCpy $MESSAGE_3_ "$MESSAGE_3_Press OK to reinstall ${DISPLAYED_NAME} or Cancel to quit."
  181. IntOp $INSTALLED_GIT_REVISION $INSTALLED_GIT_REVISION * 1
  182. IntOp $INSTALLED_BINARY_REVISION $INSTALLED_BINARY_REVISION * 1
  183. IntOp $INSTALLED_VERSION $INSTALLED_GIT_REVISION + $INSTALLED_BINARY_REVISION
  184. !define /math VERSION ${GIT_REVISION} + ${BINARY_REVISION}
  185. ${If} $INSTALLED_VERSION_NUMBER == ""
  186. ${Else}
  187. ${If} $INSTALLED_VERSION < ${VERSION}
  188. MessageBox MB_OKCANCEL "$MESSAGE_1_" IDOK upgrade IDCANCEL quit_upgrade
  189. upgrade:
  190. StrCpy $ASK_FOR_PATH "NO"
  191. ExecWait '"$UNINSTALL_STRING" _?=$INSTALL_PATH' $0
  192. Goto continue_upgrade
  193. quit_upgrade:
  194. Abort
  195. continue_upgrade:
  196. ${ElseIf} $INSTALLED_VERSION > ${VERSION}
  197. MessageBox MB_OKCANCEL "$MESSAGE_2_" IDOK downgrade IDCANCEL quit_downgrade
  198. downgrade:
  199. StrCpy $ASK_FOR_PATH "NO"
  200. ExecWait '"$UNINSTALL_STRING" _?=$INSTALL_PATH' $0
  201. Goto continue_downgrade
  202. quit_downgrade:
  203. Abort
  204. continue_downgrade:
  205. ${ElseIf} $INSTALLED_VERSION = ${VERSION}
  206. MessageBox MB_OKCANCEL "$MESSAGE_3_" IDOK reinstall IDCANCEL quit_reinstall
  207. reinstall:
  208. ExecWait '"$UNINSTALL_STRING" _?=$INSTALL_PATH' $0
  209. Goto continue_reinstall
  210. quit_reinstall:
  211. Abort
  212. continue_reinstall:
  213. ${EndIf}
  214. ${EndIf}
  215. ${If} $INSTALLED_VERSION_NUMBER == ""
  216. ${Else}
  217. ${If} $0 = 0
  218. ${Else}
  219. Abort
  220. ${EndIf}
  221. ${EndIf}
  222. FunctionEnd
  223. ;----------------------------------------------------------------------------------------------------------------------------
  224. ;CheckUpdate Function
  225. ;Check if to show the MUI_PAGE_DIRECTORY during the installation (to ask for the install PATH)
  226. Function CheckUpdate
  227. ${If} $ASK_FOR_PATH == "NO"
  228. Abort
  229. ${EndIf}
  230. FunctionEnd
  231. ;----------------------------------------------------------------------------------------------------------------------------
  232. ;CheckInstDir Function
  233. ;this is commented out, because the installation path should be in $PROGRAMFILES
  234. ;Check if GRASS is going to be installed in a directory containing spaces
  235. ;if yes, show a warning message
  236. ;Function CheckInstDir
  237. ; Var /GLOBAL INSTDIR_TEST
  238. ; Var /GLOBAL INSTDIR_LENGTH
  239. ; Var /GLOBAL INSTDIR_TEST_LENGTH
  240. ; Var /GLOBAL MESSAGE_CHKINST_
  241. ;
  242. ; StrCpy $MESSAGE_CHKINST_ "WARNING: you are about to install GRASS into a directory that has spaces$\r$\n"
  243. ; StrCpy $MESSAGE_CHKINST_ "$MESSAGE_CHKINST_in either its name or the path of directories leading up to it.$\r$\n"
  244. ; StrCpy $MESSAGE_CHKINST_ "$MESSAGE_CHKINST_Some functionalities of GRASS might be hampered by this. We would highly$\r$\n"
  245. ; StrCpy $MESSAGE_CHKINST_ "$MESSAGE_CHKINST_appreciate if you tried and reported any problems, so that we can fix them.$\r$\n"
  246. ; StrCpy $MESSAGE_CHKINST_ "$MESSAGE_CHKINST_However, if you want to avoid any such issues, we recommend that you$\r$\n"
  247. ; StrCpy $MESSAGE_CHKINST_ "$MESSAGE_CHKINST_choose a simple installation path without spaces, such as: C:\${GRASS_BASE}.$\r$\n"
  248. ;
  249. ; ${StrReplace} "$INSTDIR_TEST" " " "" "$INSTDIR"
  250. ;
  251. ; StrLen $INSTDIR_LENGTH "$INSTDIR"
  252. ; StrLen $INSTDIR_TEST_LENGTH "$INSTDIR_TEST"
  253. ;
  254. ; ${If} $INSTDIR_TEST_LENGTH < $INSTDIR_LENGTH
  255. ; MessageBox MB_OK|MB_ICONEXCLAMATION "$MESSAGE_CHKINST_"
  256. ; ${EndIf}
  257. ;
  258. ;FunctionEnd
  259. ;----------------------------------------------------------------------------------------------------------------------------
  260. ;ReplaceLineString Function
  261. ;Replace String in an existing file
  262. ; code taken from http://nsis.sourceforge.net/Replace_line_that_starts_with_specified_string
  263. Function ReplaceLineStr
  264. Exch $R0 ; string to replace that whole line with
  265. Exch
  266. Exch $R1 ; string that line should start with
  267. Exch
  268. Exch 2
  269. Exch $R2 ; file
  270. Push $R3 ; file handle
  271. Push $R4 ; temp file
  272. Push $R5 ; temp file handle
  273. Push $R6 ; global
  274. Push $R7 ; input string length
  275. Push $R8 ; line string length
  276. Push $R9 ; global
  277. StrLen $R7 $R1
  278. GetTempFileName $R4
  279. FileOpen $R5 $R4 w
  280. FileOpen $R3 $R2 r
  281. ReadLoop:
  282. ClearErrors
  283. FileRead $R3 $R6
  284. IfErrors Done
  285. StrLen $R8 $R6
  286. StrCpy $R9 $R6 $R7 -$R8
  287. StrCmp $R9 $R1 0 +3
  288. FileWrite $R5 "$R0$\r$\n"
  289. Goto ReadLoop
  290. FileWrite $R5 $R6
  291. Goto ReadLoop
  292. Done:
  293. FileClose $R3
  294. FileClose $R5
  295. SetDetailsPrint none
  296. Delete $R2
  297. Rename $R4 $R2
  298. SetDetailsPrint both
  299. Pop $R9
  300. Pop $R8
  301. Pop $R7
  302. Pop $R6
  303. Pop $R5
  304. Pop $R4
  305. Pop $R3
  306. Pop $R2
  307. Pop $R1
  308. Pop $R0
  309. FunctionEnd
  310. ;----------------------------------------------------------------------------------------------------------------------------
  311. ;Interface Settings
  312. !define MUI_ABORTWARNING
  313. !define MUI_ICON ".\Installer-Files\Install_GRASS.ico"
  314. !define MUI_UNICON ".\Installer-Files\Uninstall_GRASS.ico"
  315. !define MUI_HEADERIMAGE_BITMAP_NOSTETCH ".\Installer-Files\InstallHeaderImage.bmp"
  316. !define MUI_HEADERIMAGE_UNBITMAP_NOSTRETCH ".\Installer-Files\UnInstallHeaderImage.bmp"
  317. !define MUI_WELCOMEFINISHPAGE_BITMAP ".\Installer-Files\WelcomeFinishPage.bmp"
  318. !define MUI_UNWELCOMEFINISHPAGE_BITMAP ".\Installer-Files\UnWelcomeFinishPage.bmp"
  319. ;----------------------------------------------------------------------------------------------------------------------------
  320. ;Installer Pages
  321. !insertmacro MUI_PAGE_WELCOME
  322. ;These indented statements modify settings for MUI_PAGE_LICENSE
  323. ; (with thanks to Ubuntu)
  324. !define MUI_LICENSEPAGE_TEXT_BOTTOM "GRASS is software libre. You are encouraged and legally \
  325. entitled to copy, reinstall, modify, and redistribute this program \
  326. for yourself and your friends under the terms of the GPL. Happy \
  327. mapping!"
  328. !define MUI_LICENSEPAGE_BUTTON "Next >"
  329. !insertmacro MUI_PAGE_LICENSE "${PACKAGE_FOLDER}\GPL.TXT"
  330. !define MUI_PAGE_CUSTOMFUNCTION_PRE CheckUpdate
  331. !insertmacro MUI_PAGE_DIRECTORY
  332. ;Page custom CheckInstDir
  333. !insertmacro MUI_PAGE_COMPONENTS
  334. !insertmacro MUI_PAGE_INSTFILES
  335. ;These indented statements modify settings for MUI_PAGE_FINISH
  336. !define MUI_FINISHPAGE_NOAUTOCLOSE
  337. !define MUI_FINISHPAGE_RUN
  338. !define MUI_FINISHPAGE_RUN_NOTCHECKED
  339. !define MUI_FINISHPAGE_RUN_TEXT "Launch GRASS GIS"
  340. !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchGrass"
  341. !define MUI_FINISHPAGE_SHOWREADME
  342. !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
  343. !define MUI_FINISHPAGE_SHOWREADME_TEXT "View the reference manual"
  344. !define MUI_FINISHPAGE_SHOWREADME_FUNCTION "ViewReadme"
  345. !insertmacro MUI_PAGE_FINISH
  346. !insertmacro MUI_UNPAGE_WELCOME
  347. !insertmacro MUI_UNPAGE_CONFIRM
  348. !insertmacro MUI_UNPAGE_INSTFILES
  349. !insertmacro MUI_UNPAGE_FINISH
  350. ;----------------------------------------------------------------------------------------------------------------------------
  351. ;Language files
  352. !insertmacro MUI_LANGUAGE "English"
  353. ;----------------------------------------------------------------------------------------------------------------------------
  354. ;launch Grass Gis by exit the installation wizard
  355. Function LaunchGrass
  356. ExecShell "" "$DESKTOP\${GRASS_BASE}.lnk"
  357. FunctionEnd
  358. ;----------------------------------------------------------------------------------------------------------------------------
  359. ;launch reference manual by exit the installation wizard
  360. Function ViewReadme
  361. ExecShell "open" "$INSTDIR\docs\html\index.html"
  362. FunctionEnd
  363. ;----------------------------------------------------------------------------------------------------------------------------
  364. ;Installer Sections
  365. ;Declares the variables for optional Sample Data Sections
  366. Var /GLOBAL HTTP_PATH
  367. Var /GLOBAL ARCHIVE_NAME
  368. Var /GLOBAL EXTENDED_ARCHIVE_NAME
  369. Var /GLOBAL ORIGINAL_UNTAR_FOLDER
  370. Var /GLOBAL CUSTOM_UNTAR_FOLDER
  371. Var /GLOBAL ARCHIVE_SIZE_KB
  372. Var /GLOBAL ARCHIVE_SIZE_MB
  373. Var /GLOBAL DOWNLOAD_MESSAGE_
  374. Section "GRASS" SecGRASS
  375. SectionIn RO
  376. ;Set the INSTALL_DIR variable
  377. Var /GLOBAL INSTALL_DIR
  378. ${If} $ASK_FOR_PATH == "NO"
  379. StrCpy $INSTALL_DIR "$INSTALL_PATH"
  380. ${Else}
  381. StrCpy $INSTALL_DIR "$INSTDIR"
  382. ${EndIf}
  383. ;Set to try to overwrite existing files
  384. SetOverwrite try
  385. ;Set the GIS_DATABASE directory
  386. SetShellVarContext current
  387. Var /GLOBAL GIS_DATABASE
  388. StrCpy $GIS_DATABASE "$DOCUMENTS\grassdata"
  389. ;Create the GIS_DATABASE directory
  390. CreateDirectory "$GIS_DATABASE"
  391. ;add Installer files
  392. SetOutPath "$INSTALL_DIR"
  393. File .\Installer-Files\GRASS-WebSite.url
  394. File .\Installer-Files\WinGRASS-README.url
  395. ;add GRASS files
  396. SetOutPath "$INSTALL_DIR"
  397. File /r ${PACKAGE_FOLDER}\*.*
  398. ;grant $INSTDIR\etc read write accessible and show if succeeded: error if it failed
  399. AccessControl::GrantOnFile "$INSTDIR\etc" "(S-1-5-32-545)" "FullAccess"
  400. Pop $R0
  401. DetailPrint $R0
  402. ;grant modifying/overwriting fontcap file and show if succeeded: error if it failed
  403. AccessControl::GrantOnFile "$INSTDIR\etc\fontcap" "(S-1-5-32-545)" "FullAccess"
  404. Pop $R0
  405. DetailPrint $R0
  406. ;create run_gmkfontcap.bat
  407. ClearErrors
  408. FileOpen $0 $INSTALL_DIR\etc\run_gmkfontcap.bat w
  409. IfErrors done_create_run_gmkfontcap.bat
  410. FileWrite $0 '@echo off$\r$\n'
  411. FileWrite $0 'rem #########################################################################$\r$\n'
  412. FileWrite $0 'rem #$\r$\n'
  413. FileWrite $0 'rem # Run g.mkfontcap outside a grass session during installation$\r$\n'
  414. FileWrite $0 'rem #$\r$\n'
  415. FileWrite $0 'rem #########################################################################$\r$\n'
  416. FileWrite $0 'echo Setup of WinGRASS-${VERSION_NUMBER}$\r$\n'
  417. FileWrite $0 'echo Generating the font configuration file by scanning various directories for fonts.$\r$\n'
  418. FileWrite $0 'echo Please wait. Console window will close automatically ....$\r$\n'
  419. FileWrite $0 '$\r$\n'
  420. FileWrite $0 'rem set gisbase$\r$\n'
  421. FileWrite $0 'set GISBASE=$INSTALL_DIR$\r$\n'
  422. FileWrite $0 '$\r$\n'
  423. FileWrite $0 'rem set path to freetype dll$\r$\n'
  424. FileWrite $0 'set FREETYPEBASE=$INSTALL_DIR\extrabin;$INSTALL_DIR\lib$\r$\n'
  425. FileWrite $0 '$\r$\n'
  426. FileWrite $0 'rem set dependencies path$\r$\n'
  427. FileWrite $0 'set PATH=%FREETYPEBASE%;%PATH%$\r$\n'
  428. FileWrite $0 '$\r$\n'
  429. FileWrite $0 'rem GISRC must be set$\r$\n'
  430. FileWrite $0 'set GISRC=dummy$\r$\n'
  431. FileWrite $0 '$\r$\n'
  432. FileWrite $0 'rem run g.mkfontcap outside a grass session$\r$\n'
  433. FileWrite $0 '"%GISBASE%\bin\g.mkfontcap.exe" -o$\r$\n'
  434. FileWrite $0 'exit$\r$\n'
  435. FileClose $0
  436. done_create_run_gmkfontcap.bat:
  437. ;create run_gmkfontcap.bat.manifest
  438. ClearErrors
  439. FileOpen $0 $INSTALL_DIR\etc\run_gmkfontcap.bat.manifest w
  440. IfErrors done_create_run_gmkfontcap.bat.manifest
  441. FileWrite $0 ' <?xml version="1.0" encoding="UTF-8" standalone="yes"?>$\r$\n'
  442. FileWrite $0 '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">$\r$\n'
  443. FileWrite $0 ' <assemblyIdentity version="1.0.0.0"$\r$\n'
  444. FileWrite $0 ' processorArchitecture="X86"$\r$\n'
  445. FileWrite $0 ' name="run_gmkfontcap"$\r$\n'
  446. FileWrite $0 ' type="win32"/>$\r$\n'
  447. FileWrite $0 ' <description>GRASS help script:run_gmkfontcap<description>$\r$\n'
  448. FileWrite $0 ' <!-- Identify the application security requirements. -->$\r$\n'
  449. FileWrite $0 ' <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">$\r$\n'
  450. FileWrite $0 ' <security>$\r$\n'
  451. FileWrite $0 ' <requestedPrivileges>$\r$\n'
  452. FileWrite $0 ' <requestedExecutionLevel$\r$\n'
  453. FileWrite $0 ' level="requireAdministrator"$\r$\n'
  454. FileWrite $0 ' uiAccess="false"/>$\r$\n'
  455. FileWrite $0 ' </requestedPrivileges>$\r$\n'
  456. FileWrite $0 ' </security>$\r$\n'
  457. FileWrite $0 ' </trustInfo>$\r$\n'
  458. FileWrite $0 '</assembly>$\r$\n'
  459. FileClose $0
  460. done_create_run_gmkfontcap.bat.manifest:
  461. ;Run g.mkfontcap outside a grass session during installation to catch all fonts
  462. ExecWait '"$INSTALL_DIR\etc\run_gmkfontcap.bat"'
  463. ;set $INSTDIR\etc back to read accessible
  464. AccessControl::SetOnFile "$INSTDIR\etc" "(S-1-5-32-545)" "GenericRead + GenericExecute"
  465. ;Install demolocation into the GIS_DATABASE directory
  466. SetOutPath "$GIS_DATABASE\demolocation"
  467. File /r ${DEMOLOCATION_PATH}\*.*
  468. RMDir /r "$GIS_DATABASE\demolocation\.svn"
  469. RMDir /r "$GIS_DATABASE\demolocation\PERMANENT\.svn"
  470. RMDir /r "$GIS_DATABASE\demolocation\PERMANENT\vector\.svn"
  471. RMDir /r "$GIS_DATABASE\demolocation\PERMANENT\vector\mysites\.svn"
  472. RMDir /r "$GIS_DATABASE\demolocation\PERMANENT\vector\point\.svn"
  473. RMDir /r "$GIS_DATABASE\demolocation\PERMANENT\dbf\.svn"
  474. ;Create the Uninstaller
  475. WriteUninstaller "$INSTALL_DIR\Uninstall-GRASS.exe"
  476. ;Registry Key Entries
  477. ;HKEY_LOCAL_MACHINE Install entries
  478. ;Set the Name, Version and Revision of GRASS + PublisherInfo + InstallPath
  479. WriteRegStr HKLM "Software\${GRASS_BASE}" "Name" "${GRASS_BASE}"
  480. WriteRegStr HKLM "Software\${GRASS_BASE}" "VersionNumber" "${VERSION_NUMBER}"
  481. WriteRegStr HKLM "Software\${GRASS_BASE}" "GitRevision" "${GIT_REVISION}"
  482. WriteRegStr HKLM "Software\${GRASS_BASE}" "BinaryRevision" "${BINARY_REVISION}"
  483. WriteRegStr HKLM "Software\${GRASS_BASE}" "Publisher" "${PUBLISHER}"
  484. WriteRegStr HKLM "Software\${GRASS_BASE}" "WebSite" "${WEB_SITE}"
  485. WriteRegStr HKLM "Software\${GRASS_BASE}" "InstallPath" "$INSTALL_DIR"
  486. ;HKEY_LOCAL_MACHINE Uninstall entries
  487. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "DisplayName" "GRASS GIS @GRASS_VERSION_MAJOR@.@GRASS_VERSION_MINOR@"
  488. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "UninstallString" "$INSTALL_DIR\Uninstall-GRASS.exe"
  489. !if ${INSTALLER_TYPE} == "Release"
  490. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}"\
  491. "DisplayVersion" "${VERSION_NUMBER}-${BINARY_REVISION}"
  492. !else
  493. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}"\
  494. "DisplayVersion" "${VERSION_NUMBER}-${GIT_REVISION}-${BINARY_REVISION}"
  495. !endif
  496. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "DisplayIcon" "$INSTALL_DIR\gui\icons\grass.ico"
  497. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "EstimatedSize" 1
  498. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "HelpLink" "${WIKI_PAGE}"
  499. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "URLInfoAbout" "${WEB_SITE}"
  500. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "Publisher" "${PUBLISHER}"
  501. ;Create the Desktop Shortcut
  502. SetShellVarContext current
  503. CreateShortCut "$DESKTOP\${GRASS_BASE}.lnk" "$INSTALL_DIR\${GRASS_COMMAND}.bat" "--gui"\
  504. "$INSTALL_DIR\gui\icons\grass.ico" "" SW_SHOWNORMAL "" "Launch GRASS GIS ${VERSION_NUMBER}"
  505. ;Create the Windows Start Menu Shortcuts
  506. SetShellVarContext all
  507. CreateDirectory "$SMPROGRAMS\${GRASS_BASE}"
  508. CreateShortCut "$SMPROGRAMS\${GRASS_BASE}\${GRASS_BASE}.lnk" "$INSTALL_DIR\${GRASS_COMMAND}.bat" "--gui"\
  509. "$INSTALL_DIR\gui\icons\grass.ico" "" SW_SHOWNORMAL "" "Launch GRASS GIS ${VERSION_NUMBER}"
  510. CreateShortCut "$SMPROGRAMS\${GRASS_BASE}\Uninstall ${GRASS_BASE}.lnk" "$INSTALL_DIR\Uninstall-GRASS.exe" ""\
  511. "$INSTALL_DIR\Uninstall-GRASS.exe" "" SW_SHOWNORMAL "" "Uninstall GRASS GIS ${VERSION_NUMBER}"
  512. ;Create the grass_command.bat
  513. ClearErrors
  514. FileOpen $0 $INSTALL_DIR\${GRASS_COMMAND}.bat w
  515. IfErrors done_create_grass_command.bat
  516. FileWrite $0 '@echo off$\r$\n'
  517. FileWrite $0 'rem #########################################################################$\r$\n'
  518. FileWrite $0 'rem #$\r$\n'
  519. FileWrite $0 'rem # File dynamically created by NSIS installer script;$\r$\n'
  520. FileWrite $0 'rem #$\r$\n'
  521. FileWrite $0 'rem #########################################################################$\r$\n'
  522. FileWrite $0 'rem #$\r$\n'
  523. FileWrite $0 'rem # GRASS initialization bat script$\r$\n'
  524. FileWrite $0 'rem #$\r$\n'
  525. FileWrite $0 'rem #########################################################################$\r$\n'
  526. FileWrite $0 '$\r$\n'
  527. FileWrite $0 'set GISBASE=$INSTALL_DIR$\r$\n'
  528. FileWrite $0 '$\r$\n'
  529. FileWrite $0 'call "%GISBASE%\etc\env.bat"$\r$\n'
  530. FileWrite $0 '$\r$\n'
  531. FileWrite $0 'cd "%USERPROFILE%"'
  532. FileWrite $0 '$\r$\n'
  533. FileWrite $0 '"%GRASS_PYTHON%" "%GISBASE%\etc\grass@GRASS_VERSION_MAJOR@@GRASS_VERSION_MINOR@.py" %*'
  534. FileWrite $0 '$\r$\n$\r$\n'
  535. FileWrite $0 'if %ERRORLEVEL% GEQ 1 pause'
  536. FileClose $0
  537. done_create_grass_command.bat:
  538. ;Set the UNIX_LIKE GRASS Path
  539. Var /GLOBAL UNIX_LIKE_DRIVE
  540. Var /GLOBAL UNIX_LIKE_GRASS_PATH
  541. StrCpy $UNIX_LIKE_DRIVE "$INSTALL_DIR" 3
  542. StrCpy $UNIX_LIKE_GRASS_PATH "$INSTALL_DIR" "" 3
  543. ;replace "\" with "/" in $UNIX_LIKE_DRIVE
  544. ${StrReplace} "$UNIX_LIKE_DRIVE" "\" "/" "$UNIX_LIKE_DRIVE"
  545. ;replace ":" with "" in $UNIX_LIKE_DRIVE
  546. ${StrReplace} "$UNIX_LIKE_DRIVE" ":" "" "$UNIX_LIKE_DRIVE"
  547. ;replace "\" with "/" in $UNIX_LIKE_GRASS_PATH
  548. ${StrReplace} "$UNIX_LIKE_GRASS_PATH" "\" "/" "$UNIX_LIKE_GRASS_PATH"
  549. ;Set the USERNAME variable
  550. Var /GLOBAL USERNAME
  551. Var /GLOBAL PROFILE_DRIVE
  552. Var /GLOBAL PROFILE_ROOT
  553. ;It first searches for the Key Regestry value "Logon User Name" in HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer"
  554. ReadRegStr $USERNAME HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer" "Logon User Name"
  555. ;If the Key Registry value is empty, it uses a work around, retrieving the Username string from the System User Profile variable ($PROFILE)
  556. ;It first read the $PROFILE variable, to scan the OS version:
  557. ;If equal to "drive:\Users\UserName", the OS is Vista, and the $USERNAME variable set to $PROFILE - "drive:\Users\"
  558. ;If not, the OS is XP or previous, and the $USERNAME variable set to $PROFILE - "drive:\Documents and Settings\"
  559. ${If} $USERNAME == ""
  560. StrCpy $PROFILE_DRIVE "$PROFILE" 2
  561. StrCpy $PROFILE_ROOT "$PROFILE" 5 -3
  562. ${If} $USERNAME = "Users"
  563. ${StrReplace} "$USERNAME" "$PROFILE_DRIVE\Users\" "" "$PROFILE"
  564. ${Else}
  565. ${StrReplace} "$USERNAME" "$PROFILE_DRIVE\Documents and Settings\" "" "$PROFILE"
  566. ${EndIf}
  567. ${EndIf}
  568. ;Get the short form of the install path (to allow for paths with spaces)
  569. VAR /GLOBAL INST_DIR_SHORT
  570. GetFullPathName /SHORT $INST_DIR_SHORT $INSTALL_DIR
  571. ;Set the Unix-Like GIS_DATABASE Path
  572. ;Var /GLOBAL UNIX_LIKE_GIS_DATABASE_PATH
  573. ;replace \ with / in $GIS_DATABASE
  574. ;${StrReplace} "$UNIX_LIKE_GIS_DATABASE_PATH" "\" "/" "$GIS_DATABASE"
  575. SetShellVarContext current
  576. ${If} ${FileExists} "$APPDATA\GRASS@GRASS_VERSION_MAJOR@\rc"
  577. DetailPrint "File $APPDATA\GRASS@GRASS_VERSION_MAJOR@\rc already exists. Skipping."
  578. ${Else}
  579. ;create $APPDATA\GRASS@GRASS_VERSION_MAJOR@\rc
  580. ClearErrors
  581. CreateDirectory $APPDATA\GRASS@GRASS_VERSION_MAJOR@
  582. FileOpen $0 $APPDATA\GRASS@GRASS_VERSION_MAJOR@\rc w
  583. IfErrors done_create_grass_rc
  584. FileWrite $0 'GISDBASE: $GIS_DATABASE$\r$\n'
  585. FileWrite $0 'LOCATION_NAME: demolocation$\r$\n'
  586. FileWrite $0 'MAPSET: PERMANENT$\r$\n'
  587. FileClose $0
  588. done_create_grass_rc:
  589. ${EndIf}
  590. ;replace gisbase
  591. Push "$INSTDIR\etc\grass@GRASS_VERSION_MAJOR@@GRASS_VERSION_MINOR@.py" ; file to modify
  592. Push 'gisbase = "/c/OSGeo4W/apps/grass/grass-@GRASS_VERSION_MAJOR@.@GRASS_VERSION_MINOR@.@GRASS_VERSION_RELEASE@"' ; string that a line must begin with *WS Sensitive*
  593. Push 'gisbase = "$INSTDIR"' ; string to replace whole line with
  594. Call ReplaceLineStr
  595. ;replace config_projshare
  596. Push "$INSTDIR\etc\grass@GRASS_VERSION_MAJOR@@GRASS_VERSION_MINOR@.py" ; file to modify
  597. Push 'config_projshare = "/c/OSGeo4W/share/proj"' ; string that a line must begin with *WS Sensitive*
  598. Push 'config_projshare = "$INSTDIR\share\proj"' ; string to replace whole line with
  599. Call ReplaceLineStr
  600. ;replace BU with numeric group name for local users
  601. AccessControl::SetOnFile "$INSTDIR\etc\grass@GRASS_VERSION_MAJOR@@GRASS_VERSION_MINOR@.py" "(S-1-5-32-545)" "GenericRead + GenericExecute"
  602. SectionEnd
  603. ;--------------------------------------------------------------------------
  604. Function DownloadInstallMSRuntime
  605. IntOp $ARCHIVE_SIZE_MB $ARCHIVE_SIZE_KB / 1024
  606. StrCpy $DOWNLOAD_MESSAGE_ "The installer will download the $EXTENDED_ARCHIVE_NAME.$\r$\n"
  607. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$\r$\n"
  608. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_These system libraries from Microsoft are needed for programs"
  609. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ built with Microsoft's Visual C++ compiler, such as Python and"
  610. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ GDAL which ship with GRASS, since MS does not include them by"
  611. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ default. You might already have them installed by other software,"
  612. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ if so you don't need to install them again, but if not GRASS will"
  613. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ fail to start and you will see errors like 'Missing MSVCR71.dll"
  614. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ or MSVCP100.dll'.$\r$\n"
  615. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$\r$\n"
  616. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_The archive is about $ARCHIVE_SIZE_MB MB and may take"
  617. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ several minutes to download.$\r$\n"
  618. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$\r$\n"
  619. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_The $EXTENDED_ARCHIVE_NAME will be copied to:$\r$\n"
  620. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$TEMP\$CUSTOM_UNTAR_FOLDER.$\r$\n"
  621. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$\r$\n"
  622. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_Press OK to continue and install the runtimes, or Cancel"
  623. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ to skip the download and complete the GRASS"
  624. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ installation without the $EXTENDED_ARCHIVE_NAME.$\r$\n"
  625. MessageBox MB_OKCANCEL "$DOWNLOAD_MESSAGE_" IDOK download IDCANCEL cancel_download
  626. download:
  627. SetShellVarContext current
  628. InitPluginsDir
  629. NSISdl::download "$HTTP_PATH/$ARCHIVE_NAME" "$TEMP\$ARCHIVE_NAME"
  630. Pop $0
  631. StrCmp $0 "success" download_ok download_failed
  632. download_ok:
  633. InitPluginsDir
  634. untgz::extract "-d" "$TEMP\$ORIGINAL_UNTAR_FOLDER" "-zbz2" "$TEMP\$ARCHIVE_NAME"
  635. Pop $0
  636. StrCmp $0 "success" untar_ok untar_failed
  637. download_failed:
  638. DetailPrint "$0" ;print error message to log
  639. MessageBox MB_OK "Download Failed.$\r$\nGRASS will be installed without the $EXTENDED_ARCHIVE_NAME."
  640. Goto end
  641. cancel_download:
  642. MessageBox MB_OK "Download Cancelled.$\r$\nGRASS will be installed without the $EXTENDED_ARCHIVE_NAME."
  643. Goto end
  644. untar_failed:
  645. DetailPrint "$0" ;print error message to log
  646. untar_ok:
  647. DetailPrint "Archive successfully unzipped."
  648. DetailPrint "Copying runtime files ..."
  649. CopyFiles "$TEMP\$ORIGINAL_UNTAR_FOLDER\bin\*.dll" "$INSTALL_DIR\extrabin"
  650. DetailPrint "MS runtime files installed."
  651. Goto end
  652. end:
  653. FunctionEnd
  654. Section "Important Microsoft Runtime DLLs" SecMSRuntime
  655. ;Set the size (in KB) of the archive file
  656. StrCpy $ARCHIVE_SIZE_KB 833
  657. ;Set the size (in KB) of the unpacked archive file
  658. AddSize 13500
  659. StrCpy $HTTP_PATH "http://download.osgeo.org/osgeo4w/v2/${PLATFORM}/release/msvcrt2019/"
  660. StrCpy $ARCHIVE_NAME "msvcrt2019-14.2-1.tar.bz2"
  661. StrCpy $EXTENDED_ARCHIVE_NAME "Microsoft Visual C++ Redistributable Packages"
  662. StrCpy $ORIGINAL_UNTAR_FOLDER "install_msruntime"
  663. Call DownloadInstallMSRuntime
  664. SectionEnd
  665. Function DownloadDataSet
  666. ; IntOp $ARCHIVE_SIZE_MB $ARCHIVE_SIZE_KB / 1024
  667. StrCpy $DOWNLOAD_MESSAGE_ "The installer will download the $EXTENDED_ARCHIVE_NAME sample data set.$\r$\n"
  668. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$\r$\n"
  669. ; StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_The archive is about $ARCHIVE_SIZE_MB MB and may take"
  670. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_The archive is about $ARCHIVE_SIZE_KB KB and may take"
  671. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ several minutes to download.$\r$\n"
  672. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$\r$\n"
  673. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_The $EXTENDED_ARCHIVE_NAME dataset will be copied to:$\r$\n"
  674. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$GIS_DATABASE\$CUSTOM_UNTAR_FOLDER.$\r$\n"
  675. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$\r$\n"
  676. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_Press OK to continue or Cancel to skip the download and complete the GRASS"
  677. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ installation without the $EXTENDED_ARCHIVE_NAME data set.$\r$\n"
  678. MessageBox MB_OKCANCEL "$DOWNLOAD_MESSAGE_" IDOK download IDCANCEL cancel_download
  679. download:
  680. SetShellVarContext current
  681. InitPluginsDir
  682. NSISdl::download "$HTTP_PATH/$ARCHIVE_NAME" "$TEMP\$ARCHIVE_NAME"
  683. Pop $0
  684. StrCmp $0 "success" download_ok download_failed
  685. download_ok:
  686. InitPluginsDir
  687. untgz::extract "-d" "$GIS_DATABASE" "$TEMP\$ARCHIVE_NAME"
  688. Pop $0
  689. StrCmp $0 "success" untar_ok untar_failed
  690. untar_ok:
  691. Rename "$GIS_DATABASE\$ORIGINAL_UNTAR_FOLDER" "$GIS_DATABASE\$CUSTOM_UNTAR_FOLDER"
  692. Delete "$TEMP\$ARCHIVE_NAME"
  693. Goto end
  694. download_failed:
  695. DetailPrint "$0" ;print error message to log
  696. MessageBox MB_OK "Download Failed.$\r$\nGRASS will be installed without the $EXTENDED_ARCHIVE_NAME sample data set."
  697. Goto end
  698. cancel_download:
  699. MessageBox MB_OK "Download Cancelled.$\r$\nGRASS will be installed without the $EXTENDED_ARCHIVE_NAME sample data set."
  700. Goto end
  701. untar_failed:
  702. DetailPrint "$0" ;print error message to log
  703. end:
  704. FunctionEnd
  705. Section /O "North Carolina (Wake County) Data Set" SecNorthCarolinaSDB
  706. ;Set the size (in KB) of the archive file
  707. StrCpy $ARCHIVE_SIZE_KB 144213
  708. ;Set the size (in KB) of the unpacked archive file
  709. AddSize 254521
  710. StrCpy $HTTP_PATH "https://grass.osgeo.org/sampledata/north_carolina/"
  711. StrCpy $ARCHIVE_NAME "nc_spm_08_grass7.tar.gz"
  712. StrCpy $EXTENDED_ARCHIVE_NAME "North Carolina (Wake County)"
  713. StrCpy $ORIGINAL_UNTAR_FOLDER "nc_spm_08_grass7"
  714. StrCpy $CUSTOM_UNTAR_FOLDER "North_Carolina"
  715. Call DownloadDataSet
  716. SectionEnd
  717. Section /O "South Dakota (Spearfish County) Data Set" SecSpearfishSDB
  718. ;Set the size (in KB) of the archive file
  719. StrCpy $ARCHIVE_SIZE_KB 20803
  720. ;Set the size (in KB) of the unpacked archive file
  721. AddSize 42171
  722. StrCpy $HTTP_PATH "https://grass.osgeo.org/sampledata"
  723. StrCpy $ARCHIVE_NAME "spearfish_grass70data-0.3.tar.gz"
  724. StrCpy $EXTENDED_ARCHIVE_NAME "South Dakota (Spearfish County)"
  725. StrCpy $ORIGINAL_UNTAR_FOLDER "spearfish60_grass7"
  726. StrCpy $CUSTOM_UNTAR_FOLDER "Spearfish60_grass7"
  727. Call DownloadDataSet
  728. SectionEnd
  729. ;--------------------------------------------------------------------------
  730. ;Clean downloaded MS runtime files by .onInstSuccess
  731. Function .onInstSuccess
  732. ${If} ${SectionIsSelected} ${SecMSRuntime}
  733. Delete "$TEMP\$ARCHIVE_NAME"
  734. RMDir /r "$TEMP\$ORIGINAL_UNTAR_FOLDER"
  735. RMDir "$TEMP\$ORIGINAL_UNTAR_FOLDER"
  736. ${EndIf}
  737. FunctionEnd
  738. ;--------------------------------------------------------------------------
  739. ;Uninstaller Section
  740. Section "Uninstall"
  741. ;remove files & folders
  742. RMDir /r "$INSTDIR"
  743. ;remove the Desktop ShortCut
  744. SetShellVarContext current
  745. Delete "$DESKTOP\${GRASS_BASE}.lnk"
  746. ;remove the Programs Start ShortCuts
  747. SetShellVarContext all
  748. RMDir /r "$SMPROGRAMS\${GRASS_BASE}"
  749. ;remove the $APPDATA\GRASS@GRASS_VERSION_MAJOR@ folder
  750. ;disabled, don't remove user settings
  751. ; SetShellVarContext current
  752. ;RMDir /r "$APPDATA\GRASS@GRASS_VERSION_MAJOR@"
  753. ;${If} ${FileExists} "$APPDATA\GRASS@GRASS_VERSION_MAJOR@\addons\*.*"
  754. ; RMDir /r "$APPDATA\GRASS@GRASS_VERSION_MAJOR@\addons"
  755. ;${EndIf}
  756. ;remove the Registry Entries
  757. DeleteRegKey HKLM "Software\${GRASS_BASE}"
  758. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}"
  759. SectionEnd
  760. ;--------------------------------------------------------------------------
  761. ;Installer Section Descriptions
  762. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  763. !insertmacro MUI_DESCRIPTION_TEXT ${SecGRASS} "Install GRASS ${VERSION_NUMBER}"
  764. !insertmacro MUI_DESCRIPTION_TEXT ${SecMSRuntime} "Some software included in this installer (e.g. GDAL, Python) may need Microsoft's Visual C++ redistributable system libraries.$\r$\nDownload and install the Redistributable Package. (12 MB)"
  765. !insertmacro MUI_DESCRIPTION_TEXT ${SecNorthCarolinaSDB} "Download and install the North Carolina (Wake County) sample data set. (141 MB)"
  766. !insertmacro MUI_DESCRIPTION_TEXT ${SecSpearfishSDB} "Download and install the South Dakota (Spearfish County) sample data set. (22 MB)"
  767. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  768. ;--------------------------------------------------------------------------