GRASS-Installer.nsi 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  1. ;----------------------------------------------------------------------------------------------------------------------------
  2. ;GRASS 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. ;Define the source path of the demolocation files
  9. !define DEMOLOCATION_PATH "c:\osgeo4w\usr\src\grass_trunk\demolocation"
  10. ;Define the source of the patched msys.bat
  11. !define MSYS_BATCH "C:\OSGeo4W\usr\src\grass_trunk\mswindows\osgeo4w\msys.bat"
  12. ;Select if you are building a "Development Version" (Devel) or a "Release Version" (Release) of the GRASS Installer
  13. !define INSTALLER_TYPE "Devel"
  14. ;----------------------------------------------------------------------------------------------------------------------------
  15. ;set compression configuration
  16. SetCompressor /SOLID lzma
  17. SetCompressorDictSize 64
  18. ;----------------------------------------------------------------------------------------------------------------------------
  19. ;Version variables
  20. !define SVN_REVISION "36599"
  21. !define BINARY_REVISION "1"
  22. !if ${INSTALLER_TYPE} == "Release"
  23. !define VERSION_NUMBER "7.0.0"
  24. !define GRASS_COMMAND "grass70"
  25. !define GRASS_BASE "GRASS 7.0"
  26. !else
  27. !define VERSION_NUMBER "7.0.SVN"
  28. !define GRASS_COMMAND "grass70svn"
  29. !define GRASS_BASE "GRASS 7.0.SVN"
  30. !endif
  31. ;----------------------------------------------------------------------------------------------------------------------------
  32. ;Don't modify the following lines
  33. ;----------------------------------------------------------------------------------------------------------------------------
  34. ;NSIS Includes
  35. !include "MUI2.nsh"
  36. !include "LogicLib.nsh"
  37. ;----------------------------------------------------------------------------------------------------------------------------
  38. ;Set the installer variables, depending on the selected version to build
  39. !define PACKAGE_FOLDER ".\GRASS-70-Package"
  40. !if ${INSTALLER_TYPE} == "Release"
  41. !define INSTALLER_NAME "WinGRASS-${VERSION_NUMBER}-${BINARY_REVISION}-Setup.exe"
  42. !define DISPLAYED_NAME "GRASS ${VERSION_NUMBER}-${BINARY_REVISION}"
  43. !define CHECK_INSTALL_NAME "GRASS 70"
  44. !else
  45. !define INSTALLER_NAME "WinGRASS-${VERSION_NUMBER}-r${SVN_REVISION}-${BINARY_REVISION}-Setup.exe"
  46. !define DISPLAYED_NAME "GRASS ${VERSION_NUMBER}-r${SVN_REVISION}-${BINARY_REVISION}"
  47. !define CHECK_INSTALL_NAME "GRASS 70 SVN"
  48. !endif
  49. ;----------------------------------------------------------------------------------------------------------------------------
  50. ;Publisher variables
  51. !define PUBLISHER "GRASS Development Team"
  52. !define WEB_SITE "http://grass.osgeo.org"
  53. !define WIKI_PAGE "http://grass.osgeo.org/wiki"
  54. ;----------------------------------------------------------------------------------------------------------------------------
  55. ;General Definitions
  56. ;Name of the application shown during install
  57. Name "${DISPLAYED_NAME}"
  58. ;Name of the output file (installer executable)
  59. OutFile "${INSTALLER_NAME}"
  60. ;Define installation folder
  61. InstallDir "$PROGRAMFILES\${GRASS_BASE}"
  62. ;Request application privileges for Windows Vista
  63. RequestExecutionLevel admin
  64. ;Tell the installer to show Install and Uninstall details as default
  65. ShowInstDetails show
  66. ShowUnInstDetails show
  67. ;----------------------------------------------------------------------------------------------------------------------------
  68. ;StrReplace Function
  69. ;Replaces all ocurrences 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_SVN_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_SVN_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. Var /GLOBAL R_HKLM_INSTALL_PATH
  148. Var /GLOBAL R_HKCU_INSTALL_PATH
  149. ReadRegStr $UNINSTALL_STRING HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "UninstallString"
  150. ReadRegStr $INSTALL_PATH HKLM "Software\${GRASS_BASE}" "InstallPath"
  151. ReadRegStr $INSTALLED_VERSION_NUMBER HKLM "Software\${GRASS_BASE}" "VersionNumber"
  152. ReadRegStr $INSTALLED_SVN_REVISION HKLM "Software\${GRASS_BASE}" "SvnRevision"
  153. ReadRegStr $R_HKLM_INSTALL_PATH HKLM "Software\R-core\R" "InstallPath"
  154. ReadRegStr $R_HKCU_INSTALL_PATH HKCU "Software\R-core\R" "InstallPath"
  155. ${If} $INSTALLED_SVN_REVISION == ""
  156. ReadRegStr $INSTALLED_SVN_REVISION HKLM "Software\${GRASS_BASE}" "Revision"
  157. ${EndIf}
  158. ReadRegStr $INSTALLED_BINARY_REVISION HKLM "Software\${GRASS_BASE}" "BinaryRevision"
  159. StrCpy $MESSAGE_0_ "${CHECK_INSTALL_NAME} is already installed on your system.$\r$\n"
  160. StrCpy $MESSAGE_0_ "$MESSAGE_0_$\r$\n"
  161. !if ${INSTALLER_TYPE} == "Release"
  162. ${If} $INSTALLED_BINARY_REVISION == ""
  163. StrCpy $DISPLAYED_INSTALLED_VERSION "$INSTALLED_VERSION_NUMBER"
  164. ${Else}
  165. StrCpy $DISPLAYED_INSTALLED_VERSION "$INSTALLED_VERSION_NUMBER-$INSTALLED_BINARY_REVISION"
  166. ${EndIf}
  167. !else
  168. StrCpy $DISPLAYED_INSTALLED_VERSION "$INSTALLED_VERSION_NUMBER-$INSTALLED_SVN_REVISION-$INSTALLED_BINARY_REVISION"
  169. !endif
  170. StrCpy $MESSAGE_0_ "$MESSAGE_0_The installed release is $DISPLAYED_INSTALLED_VERSION$\r$\n"
  171. StrCpy $MESSAGE_1_ "$MESSAGE_0_$\r$\n"
  172. StrCpy $MESSAGE_1_ "$MESSAGE_1_You are going to install a newer release of ${CHECK_INSTALL_NAME}$\r$\n"
  173. StrCpy $MESSAGE_1_ "$MESSAGE_1_$\r$\n"
  174. StrCpy $MESSAGE_1_ "$MESSAGE_1_Press OK to uninstall GRASS $DISPLAYED_INSTALLED_VERSION"
  175. StrCpy $MESSAGE_1_ "$MESSAGE_1_ and install ${DISPLAYED_NAME} or Cancel to quit."
  176. StrCpy $MESSAGE_2_ "$MESSAGE_0_$\r$\n"
  177. StrCpy $MESSAGE_2_ "$MESSAGE_2_You are going to install an older release of ${CHECK_INSTALL_NAME}$\r$\n"
  178. StrCpy $MESSAGE_2_ "$MESSAGE_2_$\r$\n"
  179. StrCpy $MESSAGE_2_ "$MESSAGE_2_Press OK to uninstall GRASS $DISPLAYED_INSTALLED_VERSION"
  180. StrCpy $MESSAGE_2_ "$MESSAGE_2_ and install ${DISPLAYED_NAME} or Cancel to quit."
  181. StrCpy $MESSAGE_3_ "$MESSAGE_0_$\r$\n"
  182. StrCpy $MESSAGE_3_ "$MESSAGE_3_This is the latest release available.$\r$\n"
  183. StrCpy $MESSAGE_3_ "$MESSAGE_3_$\r$\n"
  184. StrCpy $MESSAGE_3_ "$MESSAGE_3_Press OK to reinstall ${DISPLAYED_NAME} or Cancel to quit."
  185. IntOp $INSTALLED_SVN_REVISION $INSTALLED_SVN_REVISION * 1
  186. IntOp $INSTALLED_BINARY_REVISION $INSTALLED_BINARY_REVISION * 1
  187. IntOp $INSTALLED_VERSION $INSTALLED_SVN_REVISION + $INSTALLED_BINARY_REVISION
  188. !define /math VERSION ${SVN_REVISION} + ${BINARY_REVISION}
  189. ${If} $INSTALLED_VERSION_NUMBER == ""
  190. ${Else}
  191. ${If} $INSTALLED_VERSION < ${VERSION}
  192. MessageBox MB_OKCANCEL "$MESSAGE_1_" IDOK upgrade IDCANCEL quit_upgrade
  193. upgrade:
  194. StrCpy $ASK_FOR_PATH "NO"
  195. ExecWait '"$UNINSTALL_STRING" _?=$INSTALL_PATH' $0
  196. Goto continue_upgrade
  197. quit_upgrade:
  198. Abort
  199. continue_upgrade:
  200. ${ElseIf} $INSTALLED_VERSION > ${VERSION}
  201. MessageBox MB_OKCANCEL "$MESSAGE_2_" IDOK downgrade IDCANCEL quit_downgrade
  202. downgrade:
  203. StrCpy $ASK_FOR_PATH "NO"
  204. ExecWait '"$UNINSTALL_STRING" _?=$INSTALL_PATH' $0
  205. Goto continue_downgrade
  206. quit_downgrade:
  207. Abort
  208. continue_downgrade:
  209. ${ElseIf} $INSTALLED_VERSION = ${VERSION}
  210. MessageBox MB_OKCANCEL "$MESSAGE_3_" IDOK reinstall IDCANCEL quit_reinstall
  211. reinstall:
  212. ExecWait '"$UNINSTALL_STRING" _?=$INSTALL_PATH' $0
  213. Goto continue_reinstall
  214. quit_reinstall:
  215. Abort
  216. continue_reinstall:
  217. ${EndIf}
  218. ${EndIf}
  219. ${If} $INSTALLED_VERSION_NUMBER == ""
  220. ${Else}
  221. ${If} $0 = 0
  222. ${Else}
  223. Abort
  224. ${EndIf}
  225. ${EndIf}
  226. FunctionEnd
  227. ;----------------------------------------------------------------------------------------------------------------------------
  228. ;CheckUpdate Function
  229. ;Check if to show the MUI_PAGE_DIRECTORY during the installation (to ask for the install PATH)
  230. Function CheckUpdate
  231. ${If} $ASK_FOR_PATH == "NO"
  232. Abort
  233. ${EndIf}
  234. FunctionEnd
  235. ;----------------------------------------------------------------------------------------------------------------------------
  236. ;CheckInstDir Function
  237. ;this is commented out, because the installation path should be in $PROGRAMFILES
  238. ;Check if GRASS is going to be installed in a directory containing spaces
  239. ;if yes, show a warning message
  240. ;Function CheckInstDir
  241. ; Var /GLOBAL INSTDIR_TEST
  242. ; Var /GLOBAL INSTDIR_LENGHT
  243. ; Var /GLOBAL INSTDIR_TEST_LENGHT
  244. ; Var /GLOBAL MESSAGE_CHKINST_
  245. ;
  246. ; StrCpy $MESSAGE_CHKINST_ "WARNING: you are about to install GRASS into a directory that has spaces$\r$\n"
  247. ; StrCpy $MESSAGE_CHKINST_ "$MESSAGE_CHKINST_in either its name or the path of directories leading up to it.$\r$\n"
  248. ; StrCpy $MESSAGE_CHKINST_ "$MESSAGE_CHKINST_Some functionalities of GRASS might be hampered by this. We would highly$\r$\n"
  249. ; StrCpy $MESSAGE_CHKINST_ "$MESSAGE_CHKINST_appreciate if you tried and reported any problems, so that we can fix them.$\r$\n"
  250. ; StrCpy $MESSAGE_CHKINST_ "$MESSAGE_CHKINST_However, if you want to avoid any such issues, we recommend that you$\r$\n"
  251. ; StrCpy $MESSAGE_CHKINST_ "$MESSAGE_CHKINST_choose a simple installation path without spaces, such as: C:\${GRASS_BASE}.$\r$\n"
  252. ;
  253. ; ${StrReplace} "$INSTDIR_TEST" " " "" "$INSTDIR"
  254. ;
  255. ; StrLen $INSTDIR_LENGHT "$INSTDIR"
  256. ; StrLen $INSTDIR_TEST_LENGHT "$INSTDIR_TEST"
  257. ;
  258. ; ${If} $INSTDIR_TEST_LENGHT < $INSTDIR_LENGHT
  259. ; MessageBox MB_OK|MB_ICONEXCLAMATION "$MESSAGE_CHKINST_"
  260. ; ${EndIf}
  261. ;
  262. ;FunctionEnd
  263. ;----------------------------------------------------------------------------------------------------------------------------
  264. ;ReplaceLineString Function
  265. ;Replace String in an existing file
  266. ; code taken from http://nsis.sourceforge.net/Replace_line_that_starts_with_specified_string
  267. Function ReplaceLineStr
  268. Exch $R0 ; string to replace that whole line with
  269. Exch
  270. Exch $R1 ; string that line should start with
  271. Exch
  272. Exch 2
  273. Exch $R2 ; file
  274. Push $R3 ; file handle
  275. Push $R4 ; temp file
  276. Push $R5 ; temp file handle
  277. Push $R6 ; global
  278. Push $R7 ; input string length
  279. Push $R8 ; line string length
  280. Push $R9 ; global
  281. StrLen $R7 $R1
  282. GetTempFileName $R4
  283. FileOpen $R5 $R4 w
  284. FileOpen $R3 $R2 r
  285. ReadLoop:
  286. ClearErrors
  287. FileRead $R3 $R6
  288. IfErrors Done
  289. StrLen $R8 $R6
  290. StrCpy $R9 $R6 $R7 -$R8
  291. StrCmp $R9 $R1 0 +3
  292. FileWrite $R5 "$R0$\r$\n"
  293. Goto ReadLoop
  294. FileWrite $R5 $R6
  295. Goto ReadLoop
  296. Done:
  297. FileClose $R3
  298. FileClose $R5
  299. SetDetailsPrint none
  300. Delete $R2
  301. Rename $R4 $R2
  302. SetDetailsPrint both
  303. Pop $R9
  304. Pop $R8
  305. Pop $R7
  306. Pop $R6
  307. Pop $R5
  308. Pop $R4
  309. Pop $R3
  310. Pop $R2
  311. Pop $R1
  312. Pop $R0
  313. FunctionEnd
  314. ;----------------------------------------------------------------------------------------------------------------------------
  315. ;Interface Settings
  316. !define MUI_ABORTWARNING
  317. !define MUI_ICON ".\Installer-Files\Install_GRASS.ico"
  318. !define MUI_UNICON ".\Installer-Files\Uninstall_GRASS.ico"
  319. !define MUI_HEADERIMAGE_BITMAP_NOSTETCH ".\Installer-Files\InstallHeaderImage.bmp"
  320. !define MUI_HEADERIMAGE_UNBITMAP_NOSTRETCH ".\Installer-Files\UnInstallHeaderImage.bmp"
  321. !define MUI_WELCOMEFINISHPAGE_BITMAP ".\Installer-Files\WelcomeFinishPage.bmp"
  322. !define MUI_UNWELCOMEFINISHPAGE_BITMAP ".\Installer-Files\UnWelcomeFinishPage.bmp"
  323. ;----------------------------------------------------------------------------------------------------------------------------
  324. ;Installer Pages
  325. !insertmacro MUI_PAGE_WELCOME
  326. ;These indented statements modify settings for MUI_PAGE_LICENSE
  327. ; (with thanks to Ubuntu)
  328. !define MUI_LICENSEPAGE_TEXT_BOTTOM "GRASS is software libre. You are encouraged and legally \
  329. entitled to copy, reinstall, modify, and redistribute this program \
  330. for yourself and your friends under the terms of the GPL. Happy \
  331. mapping!"
  332. !define MUI_LICENSEPAGE_BUTTON "Next >"
  333. !insertmacro MUI_PAGE_LICENSE "${PACKAGE_FOLDER}\GPL.TXT"
  334. !define MUI_PAGE_CUSTOMFUNCTION_PRE CheckUpdate
  335. !insertmacro MUI_PAGE_DIRECTORY
  336. ;Page custom CheckInstDir
  337. !insertmacro MUI_PAGE_COMPONENTS
  338. !insertmacro MUI_PAGE_INSTFILES
  339. ;These indented statements modify settings for MUI_PAGE_FINISH
  340. !define MUI_FINISHPAGE_NOAUTOCLOSE
  341. !define MUI_FINISHPAGE_RUN
  342. !define MUI_FINISHPAGE_RUN_NOTCHECKED
  343. !define MUI_FINISHPAGE_RUN_TEXT "Launch GRASS GIS"
  344. !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchGrass"
  345. !define MUI_FINISHPAGE_SHOWREADME
  346. !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
  347. !define MUI_FINISHPAGE_SHOWREADME_TEXT "View the reference manual"
  348. !define MUI_FINISHPAGE_SHOWREADME_FUNCTION "ViewReadme"
  349. !insertmacro MUI_PAGE_FINISH
  350. !insertmacro MUI_UNPAGE_WELCOME
  351. !insertmacro MUI_UNPAGE_CONFIRM
  352. !insertmacro MUI_UNPAGE_INSTFILES
  353. !insertmacro MUI_UNPAGE_FINISH
  354. ;----------------------------------------------------------------------------------------------------------------------------
  355. ;Language files
  356. !insertmacro MUI_LANGUAGE "English"
  357. ;----------------------------------------------------------------------------------------------------------------------------
  358. ;launch Grass Gis by exit the installation wizard
  359. Function LaunchGrass
  360. ExecShell "" "$DESKTOP\GRASS ${VERSION_NUMBER}.lnk"
  361. FunctionEnd
  362. ;----------------------------------------------------------------------------------------------------------------------------
  363. ;launch reference manual by exit the installation wizard
  364. Function ViewReadme
  365. ExecShell "open" "$INSTDIR\docs\html\index.html"
  366. FunctionEnd
  367. ;----------------------------------------------------------------------------------------------------------------------------
  368. ;Installer Sections
  369. ;Declares the variables for optional Sample Data Sections
  370. Var /GLOBAL HTTP_PATH
  371. Var /GLOBAL ARCHIVE_NAME
  372. Var /GLOBAL EXTENDED_ARCHIVE_NAME
  373. Var /GLOBAL ORIGINAL_UNTAR_FOLDER
  374. Var /GLOBAL CUSTOM_UNTAR_FOLDER
  375. Var /GLOBAL ARCHIVE_SIZE_KB
  376. Var /GLOBAL ARCHIVE_SIZE_MB
  377. Var /GLOBAL DOWNLOAD_MESSAGE_
  378. Section "GRASS" SecGRASS
  379. SectionIn RO
  380. ;Set the INSTALL_DIR variable
  381. Var /GLOBAL INSTALL_DIR
  382. ${If} $ASK_FOR_PATH == "NO"
  383. StrCpy $INSTALL_DIR "$INSTALL_PATH"
  384. ${Else}
  385. StrCpy $INSTALL_DIR "$INSTDIR"
  386. ${EndIf}
  387. ;Set to try to overwrite existing files
  388. SetOverwrite try
  389. ;Set the GIS_DATABASE directory
  390. SetShellVarContext current
  391. Var /GLOBAL GIS_DATABASE
  392. StrCpy $GIS_DATABASE "$DOCUMENTS\GIS DataBase"
  393. ;Create the GIS_DATABASE directory
  394. CreateDirectory "$GIS_DATABASE"
  395. ;add Installer files
  396. SetOutPath "$INSTALL_DIR\icons"
  397. File .\Installer-Files\GRASS.ico
  398. File .\Installer-Files\GRASS_Web.ico
  399. File .\Installer-Files\GRASS_tcltk.ico
  400. File .\Installer-Files\GRASS_MSys.ico
  401. File .\Installer-Files\GRASS_CMD.ico
  402. File .\Installer-Files\MSYS_Custom_Icon.ico
  403. File .\Installer-Files\WinGRASS.ico
  404. SetOutPath "$INSTALL_DIR"
  405. File .\Installer-Files\GRASS-WebSite.url
  406. File .\Installer-Files\WinGRASS-README.url
  407. ;add GRASS files
  408. SetOutPath "$INSTALL_DIR"
  409. File /r ${PACKAGE_FOLDER}\*.*
  410. ;create run_gmkfontcap.bat
  411. ClearErrors
  412. FileOpen $0 $INSTALL_DIR\etc\run_gmkfontcap.bat w
  413. IfErrors done_create_run_gmkfontcap.bat
  414. FileWrite $0 '@echo off$\r$\n'
  415. FileWrite $0 'rem #########################################################################$\r$\n'
  416. FileWrite $0 'rem #$\r$\n'
  417. FileWrite $0 'rem # Run g.mkfontcap outside a grass session during installation$\r$\n'
  418. FileWrite $0 'rem #$\r$\n'
  419. FileWrite $0 'rem #########################################################################$\r$\n'
  420. FileWrite $0 'echo Setup of WinGRASS-${VERSION_NUMBER}$\r$\n'
  421. FileWrite $0 'echo Generating the font configuration file by scanning various directories for fonts.$\r$\n'
  422. FileWrite $0 'echo Please wait. Console window will close automatically ....$\r$\n'
  423. FileWrite $0 '$\r$\n'
  424. FileWrite $0 'rem set gisbase$\r$\n'
  425. FileWrite $0 'set GISBASE=$INSTALL_DIR$\r$\n'
  426. FileWrite $0 '$\r$\n'
  427. FileWrite $0 'rem set path to freetype dll$\r$\n'
  428. FileWrite $0 'set FREETYPEBASE=$INSTALL_DIR\extralib;$INSTALL_DIR\lib$\r$\n'
  429. FileWrite $0 '$\r$\n'
  430. FileWrite $0 'rem set dependecies path$\r$\n'
  431. FileWrite $0 'set PATH=%FREETYPEBASE%;%PATH%$\r$\n'
  432. FileWrite $0 '$\r$\n'
  433. FileWrite $0 'rem run g.mkfontcap outside a grass session$\r$\n'
  434. FileWrite $0 '"%GISBASE%\bin\g.mkfontcap.exe" -o$\r$\n'
  435. FileWrite $0 'exit$\r$\n'
  436. FileClose $0
  437. done_create_run_gmkfontcap.bat:
  438. ;create run_gmkfontcap.bat.manifest
  439. ClearErrors
  440. FileOpen $0 $INSTALL_DIR\etc\run_gmkfontcap.bat.manifest w
  441. IfErrors done_create_run_gmkfontcap.bat.manifest
  442. FileWrite $0 ' <?xml version="1.0" encoding="UTF-8" standalone="yes"?>$\r$\n'
  443. FileWrite $0 '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">$\r$\n'
  444. FileWrite $0 ' <assemblyIdentity version="1.0.0.0"$\r$\n'
  445. FileWrite $0 ' processorArchitecture="X86"$\r$\n'
  446. FileWrite $0 ' name="run_gmkfontcap"$\r$\n'
  447. FileWrite $0 ' type="win32"/>$\r$\n'
  448. FileWrite $0 ' <description>GRASS help script:run_gmkfontcap<description>$\r$\n'
  449. FileWrite $0 ' <!-- Identify the application security requirements. -->$\r$\n'
  450. FileWrite $0 ' <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">$\r$\n'
  451. FileWrite $0 ' <security>$\r$\n'
  452. FileWrite $0 ' <requestedPrivileges>$\r$\n'
  453. FileWrite $0 ' <requestedExecutionLevel$\r$\n'
  454. FileWrite $0 ' level="asInvoker"$\r$\n'
  455. FileWrite $0 ' uiAccess="false"/>$\r$\n'
  456. FileWrite $0 ' </requestedPrivileges>$\r$\n'
  457. FileWrite $0 ' </security>$\r$\n'
  458. FileWrite $0 ' </trustInfo>$\r$\n'
  459. FileWrite $0 '</assembly>$\r$\n'
  460. FileClose $0
  461. done_create_run_gmkfontcap.bat.manifest:
  462. ;Run g.mkfontcap outside a grass session during installation to catch all fonts
  463. ExecWait '"$INSTALL_DIR\etc\run_gmkfontcap.bat"'
  464. ;Install demolocation into the GIS_DATABASE directory
  465. SetOutPath "$GIS_DATABASE\demolocation"
  466. File /r ${DEMOLOCATION_PATH}\*.*
  467. ;add msys.bat into the INSTALL_DIR\msys directory
  468. SetOutPath "$INSTALL_DIR\msys"
  469. File /r ${MSYS_BATCH}
  470. ;Create the Uninstaller
  471. WriteUninstaller "$INSTALL_DIR\Uninstall-GRASS.exe"
  472. ;Registry Key Entries
  473. ;HKEY_LOCAL_MACHINE Install entries
  474. ;Set the Name, Version and Revision of GRASS + PublisherInfo + InstallPath
  475. WriteRegStr HKLM "Software\${GRASS_BASE}" "Name" "GRASS 7.0"
  476. WriteRegStr HKLM "Software\${GRASS_BASE}" "VersionNumber" "${VERSION_NUMBER}"
  477. WriteRegStr HKLM "Software\${GRASS_BASE}" "SvnRevision" "${SVN_REVISION}"
  478. WriteRegStr HKLM "Software\${GRASS_BASE}" "BinaryRevision" "${BINARY_REVISION}"
  479. WriteRegStr HKLM "Software\${GRASS_BASE}" "Publisher" "${PUBLISHER}"
  480. WriteRegStr HKLM "Software\${GRASS_BASE}" "WebSite" "${WEB_SITE}"
  481. WriteRegStr HKLM "Software\${GRASS_BASE}" "InstallPath" "$INSTALL_DIR"
  482. ;HKEY_LOCAL_MACHINE Uninstall entries
  483. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "DisplayName" "GRASS 7.0"
  484. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "UninstallString" "$INSTALL_DIR\Uninstall-GRASS.exe"
  485. !if ${INSTALLER_TYPE} == "Release"
  486. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}"\
  487. "DisplayVersion" "${VERSION_NUMBER}-${BINARY_REVISION}"
  488. !else
  489. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}"\
  490. "DisplayVersion" "${VERSION_NUMBER}-r${SVN_REVISION}-${BINARY_REVISION}"
  491. !endif
  492. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "DisplayIcon" "$INSTALL_DIR\icons\GRASS.ico"
  493. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "EstimatedSize" 1
  494. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "HelpLink" "${WIKI_PAGE}"
  495. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "URLInfoAbout" "${WEB_SITE}"
  496. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}" "Publisher" "${PUBLISHER}"
  497. ;Create the Desktop Shortcut
  498. SetShellVarContext current
  499. CreateShortCut "$DESKTOP\GRASS ${VERSION_NUMBER}.lnk" "$INSTALL_DIR\${GRASS_COMMAND}.bat" "-wx"\
  500. "$INSTALL_DIR\icons\GRASS.ico" "" SW_SHOWMINIMIZED "" "Launch GRASS ${VERSION_NUMBER} with wxGUI"
  501. ; not working after changing to start Grass7 by grass70.py
  502. ;CreateShortCut "$DESKTOP\GRASS ${VERSION_NUMBER} with MSYS.lnk" "$INSTALL_DIR\msys\msys.bat" "/grass/bin/${GRASS_COMMAND} -wxpython"\
  503. ;"$INSTALL_DIR\icons\GRASS_MSys.ico" "" SW_SHOWNORMAL "" "Launch GRASS ${VERSION_NUMBER} with wxGUI and a MSYS UNIX terminal"
  504. ; new attempt to get Grass70-wx-gui and a working msys-shell in a windows command line
  505. CreateShortCut "$DESKTOP\GRASS ${VERSION_NUMBER} with MSYS.lnk" "$INSTALL_DIR\set_shell_start_${GRASS_COMMAND}.bat" ""\
  506. "$INSTALL_DIR\icons\GRASS_MSys.ico" "" SW_SHOWNORMAL "" "Launch GRASS ${VERSION_NUMBER} with wxGUI and a MSYS-Windows-commandline"
  507. ;Create the Windows Start Menu Shortcuts
  508. SetShellVarContext all
  509. CreateDirectory "$SMPROGRAMS\${GRASS_BASE}"
  510. CreateShortCut "$SMPROGRAMS\${GRASS_BASE}\GRASS GUI.lnk" "$INSTALL_DIR\${GRASS_COMMAND}.bat" "-wx"\
  511. "$INSTALL_DIR\icons\GRASS.ico" "" SW_SHOWMINIMIZED "" "Launch GRASS ${VERSION_NUMBER} with wxGUI"
  512. CreateShortCut "$SMPROGRAMS\${GRASS_BASE}\GRASS Command Line.lnk" "$INSTALL_DIR\${GRASS_COMMAND}.bat" "-text"\
  513. "$INSTALL_DIR\icons\GRASS_CMD.ico" "" SW_SHOWNORMAL "" "Launch GRASS ${VERSION_NUMBER} in text mode"
  514. CreateShortCut "$SMPROGRAMS\${GRASS_BASE}\MSYS UNIX Console.lnk" "$INSTALL_DIR\msys\msys.bat" ""\
  515. "$INSTALL_DIR\icons\MSYS_Custom_Icon.ico" "" SW_SHOWNORMAL "" "Open a MSYS UNIX console"
  516. CreateShortCut "$SMPROGRAMS\${GRASS_BASE}\GRASS Web Site.lnk" "$INSTALL_DIR\GRASS-WebSite.url" ""\
  517. "$INSTALL_DIR\icons\GRASS_Web.ico" "" SW_SHOWNORMAL "" "Visit the GRASS website"
  518. ;CreateShortCut "$SMPROGRAMS\${GRASS_BASE}\GRASS GUI with MSYS.lnk" "$INSTALL_DIR\msys\msys.bat" "/grass/bin/${GRASS_COMMAND} -wx"\
  519. ;"$INSTALL_DIR\icons\GRASS_MSys.ico" "" SW_SHOWNORMAL "" "Launch GRASS ${VERSION_NUMBER} with wxGUI and a MSYS UNIX terminal"
  520. CreateShortCut "$SMPROGRAMS\${GRASS_BASE}\GRASS GUI with MSYS.lnk" "$INSTALL_DIR\set_shell_start_${GRASS_COMMAND}.bat" ""\
  521. "$INSTALL_DIR\icons\GRASS_MSys.ico" "" SW_SHOWNORMAL "" "Launch GRASS ${VERSION_NUMBER} with wxGUI and a MSYS-Windows-commandline"
  522. ; FIXME: ship the WinGrass release notes .html file instead of URL
  523. ; http://trac.osgeo.org/grass/browser/grass-web/trunk/grass70/binary/mswindows/native/README.html?format=raw
  524. ; probably ship with devel versions too? ie Release Notes, not the Release Announcement press release.
  525. !if ${INSTALLER_TYPE} == "Release"
  526. CreateShortCut "$SMPROGRAMS\${GRASS_BASE}\Release Notes.lnk" "$INSTALL_DIR\WinGRASS-README.url" ""\
  527. "$INSTALL_DIR\icons\WinGRASS.ico" "" SW_SHOWNORMAL "" "Visit the WinGRASS Project Web Page"
  528. !endif
  529. CreateShortCut "$SMPROGRAMS\${GRASS_BASE}\Uninstall GRASS.lnk" "$INSTALL_DIR\Uninstall-GRASS.exe" ""\
  530. "$INSTALL_DIR\Uninstall-GRASS.exe" "" SW_SHOWNORMAL "" "Uninstall GRASS ${VERSION_NUMBER}"
  531. ;Create the grass_command.bat
  532. ClearErrors
  533. FileOpen $0 $INSTALL_DIR\${GRASS_COMMAND}.bat w
  534. IfErrors done_create_grass_command.bat
  535. FileWrite $0 '@echo off$\r$\n'
  536. FileWrite $0 'rem #########################################################################$\r$\n'
  537. FileWrite $0 'rem #$\r$\n'
  538. FileWrite $0 'rem # File dynamically created by NSIS installer script;$\r$\n'
  539. FileWrite $0 'rem #$\r$\n'
  540. FileWrite $0 'rem #########################################################################$\r$\n'
  541. FileWrite $0 'rem #$\r$\n'
  542. FileWrite $0 'rem # GRASS Initialization$\r$\n'
  543. FileWrite $0 'rem #$\r$\n'
  544. FileWrite $0 'rem #########################################################################$\r$\n'
  545. FileWrite $0 '$\r$\n'
  546. FileWrite $0 'rem Set GRASS Installation Directory Variable$\r$\n'
  547. FileWrite $0 'set GISBASE=$INSTALL_DIR$\r$\n'
  548. FileWrite $0 '$\r$\n'
  549. ${If} $R_HKLM_INSTALL_PATH != ""
  550. FileWrite $0 'set PATH=$R_HKLM_INSTALL_PATH\bin;%PATH%$\r$\n'
  551. FileWrite $0 '$\r$\n'
  552. ${EndIf}
  553. ${If} $R_HKCU_INSTALL_PATH != ""
  554. FileWrite $0 'set PATH=$R_HKCU_INSTALL_PATH\bin;%PATH%$\r$\n'
  555. FileWrite $0 '$\r$\n'
  556. ${EndIf}
  557. FileWrite $0 'call "%GISBASE%\etc\env.bat"$\r$\n'
  558. FileWrite $0 '$\r$\n'
  559. FileWrite $0 'cd "%USERPROFILE%"'
  560. FileWrite $0 '$\r$\n'
  561. FileWrite $0 '%GRASS_PYTHON% "%GISBASE%\etc\grass70.py" %*'
  562. FileClose $0
  563. done_create_grass_command.bat:
  564. ;Create the set_shell_start_grass.bat to start Grass7-wxgui and a msys-windows-commandline
  565. ClearErrors
  566. FileOpen $0 $INSTALL_DIR\set_shell_start_${GRASS_COMMAND}.bat w
  567. IfErrors done_create_set_shell_start_grass.bat
  568. FileWrite $0 '@echo off$\r$\n'
  569. FileWrite $0 'rem #########################################################################$\r$\n'
  570. FileWrite $0 'rem #$\r$\n'
  571. FileWrite $0 'rem # File dynamically created by NSIS installer script$\r$\n'
  572. FileWrite $0 'rem #$\r$\n'
  573. FileWrite $0 'rem #########################################################################$\r$\n'
  574. FileWrite $0 'rem #$\r$\n'
  575. FileWrite $0 'rem # Set SHELL and start GRASS$\r$\n'
  576. FileWrite $0 'rem #$\r$\n'
  577. FileWrite $0 'rem #########################################################################$\r$\n'
  578. FileWrite $0 '$\r$\n'
  579. FileWrite $0 'rem *******Set SHELL***********$\r$\n'
  580. FileWrite $0 '$\r$\n'
  581. FileWrite $0 'set SHELL="$INSTALL_DIR\msys\bin\sh.exe"$\r$\n'
  582. FileWrite $0 '$\r$\n'
  583. FileWrite $0 '"$INSTALL_DIR\${GRASS_COMMAND}.bat"$\r$\n'
  584. FileClose $0
  585. done_create_set_shell_start_grass.bat:
  586. ;Set the UNIX_LIKE GRASS Path
  587. Var /GLOBAL UNIX_LIKE_DRIVE
  588. Var /GLOBAL UNIX_LIKE_GRASS_PATH
  589. StrCpy $UNIX_LIKE_DRIVE "$INSTALL_DIR" 3
  590. StrCpy $UNIX_LIKE_GRASS_PATH "$INSTALL_DIR" "" 3
  591. ;replace "\" with "/" in $UNIX_LIKE_DRIVE
  592. ${StrReplace} "$UNIX_LIKE_DRIVE" "\" "/" "$UNIX_LIKE_DRIVE"
  593. ;replace ":" with "" in $UNIX_LIKE_DRIVE
  594. ${StrReplace} "$UNIX_LIKE_DRIVE" ":" "" "$UNIX_LIKE_DRIVE"
  595. ;replace "\" with "/" in $UNIX_LIKE_GRASS_PATH
  596. ${StrReplace} "$UNIX_LIKE_GRASS_PATH" "\" "/" "$UNIX_LIKE_GRASS_PATH"
  597. ;Set the USERNAME variable
  598. Var /GLOBAL USERNAME
  599. Var /GLOBAL PROFILE_DRIVE
  600. Var /GLOBAL PROFILE_ROOT
  601. ;It first searches for the Key Regestry value "Logon User Name" in HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer"
  602. ReadRegStr $USERNAME HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer" "Logon User Name"
  603. ;If the Key Registry value is empty, it uses a work around, retrieving the Username string from the System User Profile variable ($PROFILE)
  604. ;It first read the $PROFILE variable, to scan the OS version:
  605. ;If equal to "drive:\Users\UserName", the OS is Vista, and the $USERNAME variable set to $PROFILE - "drive:\Users\"
  606. ;If not, the OS is XP or previous, and the $USERNAME variable set to $PROFILE - "drive:\Documents and Settings\"
  607. ${If} $USERNAME == ""
  608. StrCpy $PROFILE_DRIVE "$PROFILE" 2
  609. StrCpy $PROFILE_ROOT "$PROFILE" 5 -3
  610. ${If} $USERNAME = "Users"
  611. ${StrReplace} "$USERNAME" "$PROFILE_DRIVE\Users\" "" "$PROFILE"
  612. ${Else}
  613. ${StrReplace} "$USERNAME" "$PROFILE_DRIVE\Documents and Settings\" "" "$PROFILE"
  614. ${EndIf}
  615. ${EndIf}
  616. ;create the $INSTALL_DIR\bin grass_command
  617. ClearErrors
  618. FileOpen $0 $INSTALL_DIR\${GRASS_COMMAND}.sh w
  619. IfErrors done_create_grass_command
  620. FileWrite $0 '#! /bin/sh$\r$\n'
  621. FileWrite $0 '#########################################################################$\r$\n'
  622. FileWrite $0 '#$\r$\n'
  623. FileWrite $0 '# File dynamically created by NSIS installer script;$\r$\n'
  624. FileWrite $0 '# Written by Marco Pasetti;$\r$\n'
  625. FileWrite $0 '#$\r$\n'
  626. FileWrite $0 '#########################################################################$\r$\n'
  627. FileWrite $0 '#$\r$\n'
  628. FileWrite $0 '# MODULE: GRASS Initialization$\r$\n'
  629. FileWrite $0 '# AUTHOR(S): Justin Hickey - Thailand - jhickey@hpcc.nectec.or.th$\r$\n'
  630. FileWrite $0 '# PURPOSE: The source file for this shell script is in$\r$\n'
  631. FileWrite $0 '# lib/init/grass.src and is the grass startup script. It$\r$\n'
  632. FileWrite $0 '# requires a source file because the definition of GISBASE$\r$\n'
  633. FileWrite $0 '# is not known until compile time and is substituted from the$\r$\n'
  634. FileWrite $0 '# Makefile. Any command line options are passed to Init.sh.$\r$\n'
  635. FileWrite $0 '# COPYRIGHT: (C) 2000-2010 by the GRASS Development Team$\r$\n'
  636. FileWrite $0 '#$\r$\n'
  637. FileWrite $0 '# This program is free software under the GNU General Public$\r$\n'
  638. FileWrite $0 '# License (>=v2). Read the file COPYING that comes with GRASS$\r$\n'
  639. FileWrite $0 '# for details.$\r$\n'
  640. FileWrite $0 '#$\r$\n'
  641. FileWrite $0 '#########################################################################$\r$\n'
  642. FileWrite $0 '#$\r$\n'
  643. FileWrite $0 '# Modified by Marco Pasetti$\r$\n'
  644. FileWrite $0 '# added the export PATH instruction to let GRASS work from$\r$\n'
  645. FileWrite $0 '# the MSYS environment in the dynamic NSIS installation$\r$\n'
  646. FileWrite $0 '#$\r$\n'
  647. FileWrite $0 '#########################################################################$\r$\n'
  648. FileWrite $0 '$\r$\n'
  649. FileWrite $0 'trap "echo '
  650. FileWrite $0 "'User break!' ; "
  651. FileWrite $0 'exit" 2 3 9 15$\r$\n'
  652. FileWrite $0 '$\r$\n'
  653. FileWrite $0 '# Set the GISBASE variable$\r$\n'
  654. FileWrite $0 'GISBASE="/$UNIX_LIKE_DRIVE$UNIX_LIKE_GRASS_PATH"$\r$\n'
  655. FileWrite $0 'export GISBASE$\r$\n'
  656. FileWrite $0 '$\r$\n'
  657. FileWrite $0 '# Set the PATH variable$\r$\n'
  658. FileWrite $0 'PATH="$$GISBASE/extrabin:$$GISBASE/extralib:$$PATH"$\r$\n'
  659. FileWrite $0 'PATH="$$GISBASE/tcl-tk/bin:$$GISBASE/sqlite/bin:$$GISBASE/gpsbabel:$$PATH"$\r$\n'
  660. FileWrite $0 'export PATH$\r$\n'
  661. FileWrite $0 '# Set the PYTHONPATH variable$\r$\n'
  662. FileWrite $0 'PYTHONPATH="$$GISBASE/etc/python:$$GISBASE/Python25:$$PYTHONPATH"$\r$\n'
  663. FileWrite $0 'export PYTHONPATH$\r$\n'
  664. FileWrite $0 'PYTHONHOME="$INSTALL_DIR\Python25"$\r$\n'
  665. FileWrite $0 'export PYTHONHOME$\r$\n'
  666. FileWrite $0 'if [ -z "$$GRASS_PYTHON" ] ; then$\r$\n'
  667. FileWrite $0 ' GRASS_PYTHON=python$\r$\n'
  668. FileWrite $0 ' export GRASS_PYTHON$\r$\n'
  669. FileWrite $0 'fi$\r$\n'
  670. FileWrite $0 '$\r$\n'
  671. FileWrite $0 '# Set the GRASS_PROJSHARE variable$\r$\n'
  672. FileWrite $0 'GRASS_PROJSHARE="$INSTALL_DIR\proj"$\r$\n'
  673. FileWrite $0 'export GRASS_PROJSHARE$\r$\n'
  674. FileWrite $0 '$\r$\n'
  675. FileWrite $0 '# Set the GDAL_DATA variable$\r$\n'
  676. FileWrite $0 'GDAL_DATA="$INSTALL_DIR\share\gdal"$\r$\n'
  677. FileWrite $0 'export GDAL_DATA$\r$\n'
  678. FileWrite $0 '$\r$\n'
  679. FileWrite $0 '# Set the PROJ_LIB variable$\r$\n'
  680. FileWrite $0 'PROJ_LIB="$INSTALL_DIR\proj"$\r$\n'
  681. FileWrite $0 'export PROJ_LIB $\r$\n'
  682. FileWrite $0 '$\r$\n'
  683. FileWrite $0 '# Set the GEOTIFF_CSV variable$\r$\n'
  684. FileWrite $0 'GEOTIFF_CSV="$INSTALL_DIR\share\epsg_csv"$\r$\n'
  685. FileWrite $0 'export GEOTIFF_CSV$\r$\n'
  686. FileWrite $0 '$\r$\n'
  687. FileWrite $0 '"$$GRASS_PYTHON $$GISBASE/etc/grass70.py" "$$@"'
  688. FileClose $0
  689. done_create_grass_command:
  690. ;Get the short form of the install path (to allow for paths with spaces)
  691. VAR /GLOBAL INST_DIR_SHORT
  692. GetFullPathName /SHORT $INST_DIR_SHORT $INSTALL_DIR
  693. ;create the $INSTALL_DIR\msys\etc\fstab with the main grass dir mount info
  694. ClearErrors
  695. FileOpen $0 $INSTALL_DIR\msys\etc\fstab w
  696. IfErrors done_create_fstab
  697. FileWrite $0 '$INST_DIR_SHORT /grass$\r$\n'
  698. FileClose $0
  699. done_create_fstab:
  700. ;Set the Unix-Like GIS_DATABASE Path
  701. Var /GLOBAL UNIX_LIKE_GIS_DATABASE_PATH
  702. ;replace \ with / in $GIS_DATABASE
  703. ${StrReplace} "$UNIX_LIKE_GIS_DATABASE_PATH" "\" "/" "$GIS_DATABASE"
  704. SetShellVarContext current
  705. ${If} ${FileExists} "$APPDATA\GRASS7\rc"
  706. DetailPrint "File $APPDATA\GRASS7\rc already exists. Skipping."
  707. ${Else}
  708. ;create $APPDATA\GRASS7\rc
  709. ClearErrors
  710. CreateDirectory $APPDATA\GRASS7
  711. FileOpen $0 $APPDATA\GRASS7\rc w
  712. IfErrors done_create_grass7_rc
  713. FileWrite $0 'GISDBASE: $UNIX_LIKE_GIS_DATABASE_PATH$\r$\n'
  714. FileWrite $0 'LOCATION_NAME: demolocation$\r$\n'
  715. FileWrite $0 'MAPSET: PERMANENT$\r$\n'
  716. FileClose $0
  717. done_create_grass7_rc:
  718. ${EndIf}
  719. ;replace gisbase = "/c/OSGeo4W/apps/grass/grass-7.0.svn" in grass70.py with $INSTDIR
  720. Push "$INSTDIR\etc\grass70.py" ; file to modify
  721. Push 'gisbase = "/c/OSGeo4W/apps/grass/grass-7.0.svn"' ; string that a line must begin with *WS Sensitive*
  722. Push 'gisbase = "$INSTDIR"' ; string to replace whole line with
  723. Call ReplaceLineStr
  724. ;replace config_projshare = "/c/OSGeo4W/share/proj" i n grass70.py with $INSTDIR\proj
  725. Push "$INSTDIR\etc\grass70.py" ; file to modify
  726. Push 'config_projshare = "/c/OSGeo4W/share/proj"' ; string that a line must begin with *WS Sensitive*
  727. Push 'config_projshare = "$INSTDIR\proj"' ; string to replace whole line with
  728. Call ReplaceLineStr
  729. SectionEnd
  730. Function DownloadDataSet
  731. IntOp $ARCHIVE_SIZE_MB $ARCHIVE_SIZE_KB / 1024
  732. StrCpy $DOWNLOAD_MESSAGE_ "The installer will download the $EXTENDED_ARCHIVE_NAME sample data set.$\r$\n"
  733. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$\r$\n"
  734. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_The archive is about $ARCHIVE_SIZE_MB MB and may take"
  735. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ several minutes to be downloaded.$\r$\n"
  736. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$\r$\n"
  737. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_The $EXTENDED_ARCHIVE_NAME will be copyed to:$\r$\n"
  738. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$GIS_DATABASE\$CUSTOM_UNTAR_FOLDER.$\r$\n"
  739. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_$\r$\n"
  740. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_Press OK to continue or Cancel to skip the download and complete the GRASS"
  741. StrCpy $DOWNLOAD_MESSAGE_ "$DOWNLOAD_MESSAGE_ installation without the $EXTENDED_ARCHIVE_NAME data set.$\r$\n"
  742. MessageBox MB_OKCANCEL "$DOWNLOAD_MESSAGE_" IDOK download IDCANCEL cancel_download
  743. download:
  744. SetShellVarContext current
  745. InitPluginsDir
  746. NSISdl::download "$HTTP_PATH/$ARCHIVE_NAME" "$TEMP\$ARCHIVE_NAME"
  747. Pop $0
  748. StrCmp $0 "success" download_ok download_failed
  749. download_ok:
  750. InitPluginsDir
  751. untgz::extract "-d" "$GIS_DATABASE" "$TEMP\$ARCHIVE_NAME"
  752. Pop $0
  753. StrCmp $0 "success" untar_ok untar_failed
  754. untar_ok:
  755. Rename "$GIS_DATABASE\$ORIGINAL_UNTAR_FOLDER" "$GIS_DATABASE\$CUSTOM_UNTAR_FOLDER"
  756. Delete "$TEMP\$ARCHIVE_NAME"
  757. Goto end
  758. download_failed:
  759. DetailPrint "$0" ;print error message to log
  760. MessageBox MB_OK "Download Failed.$\r$\nGRASS will be installed without the $EXTENDED_ARCHIVE_NAME sample data set."
  761. Goto end
  762. cancel_download:
  763. MessageBox MB_OK "Download Cancelled.$\r$\nGRASS will be installed without the $EXTENDED_ARCHIVE_NAME sample data set."
  764. Goto end
  765. untar_failed:
  766. DetailPrint "$0" ;print error message to log
  767. end:
  768. FunctionEnd
  769. Section /O "North Carolina (Wake County) Data Set" SecNorthCarolinaSDB
  770. ;Set the size (in KB) of the archive file
  771. StrCpy $ARCHIVE_SIZE_KB 138629
  772. ;Set the size (in KB) of the unpacked archive file
  773. AddSize 293314
  774. StrCpy $HTTP_PATH "http://grass.osgeo.org/sampledata"
  775. StrCpy $ARCHIVE_NAME "nc_spm_latest.tar.gz"
  776. StrCpy $EXTENDED_ARCHIVE_NAME "North Carolina (Wake County)"
  777. StrCpy $ORIGINAL_UNTAR_FOLDER "nc_spm_08"
  778. StrCpy $CUSTOM_UNTAR_FOLDER "North-Carolina"
  779. Call DownloadDataSet
  780. SectionEnd
  781. Section /O "South Dakota (Spearfish County) Data Set" SecSpearfishSDB
  782. ;Set the size (in KB) of the archive file
  783. StrCpy $ARCHIVE_SIZE_KB 20803
  784. ;Set the size (in KB) of the unpacked archive file
  785. AddSize 42171
  786. StrCpy $HTTP_PATH "http://grass.osgeo.org/sampledata"
  787. StrCpy $ARCHIVE_NAME "spearfish_grass60data-0.3.tar.gz"
  788. StrCpy $EXTENDED_ARCHIVE_NAME "South Dakota (Spearfish County)"
  789. StrCpy $ORIGINAL_UNTAR_FOLDER "spearfish60"
  790. StrCpy $CUSTOM_UNTAR_FOLDER "Spearfish60"
  791. Call DownloadDataSet
  792. SectionEnd
  793. ;----------------------------------------------------------------------------------------------------------------------------
  794. ;Uninstaller Section
  795. Section "Uninstall"
  796. ;remove files & folders
  797. RMDir /r "$INSTDIR"
  798. ;remove the Desktop ShortCut
  799. SetShellVarContext current
  800. Delete "$DESKTOP\GRASS ${VERSION_NUMBER}.lnk"
  801. Delete "$DESKTOP\GRASS ${VERSION_NUMBER} with MSYS.lnk"
  802. ;remove the Programs Start ShortCuts
  803. SetShellVarContext all
  804. RMDir /r "$SMPROGRAMS\${GRASS_BASE}"
  805. ;remove the $APPDATA\GRASS7 folder
  806. ;disabled, don't remove user settings
  807. SetShellVarContext current
  808. ;RMDir /r "$APPDATA\GRASS7"
  809. ${If} ${FileExists} "$APPDATA\GRASS7\addons\*.*"
  810. RMDir /r "$APPDATA\GRASS7\addons"
  811. ${EndIf}
  812. ;remove the Registry Entries
  813. DeleteRegKey HKLM "Software\${GRASS_BASE}"
  814. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GRASS_BASE}"
  815. SectionEnd
  816. ;----------------------------------------------------------------------------------------------------------------------------
  817. ;Installer Section Descriptions
  818. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  819. !insertmacro MUI_DESCRIPTION_TEXT ${SecGRASS} "Install GRASS ${VERSION_NUMBER}"
  820. !insertmacro MUI_DESCRIPTION_TEXT ${SecNorthCarolinaSDB} "Download and install the North Carolina (Wake County) sample data set"
  821. !insertmacro MUI_DESCRIPTION_TEXT ${SecSpearfishSDB} "Download and install the South Dakota (Spearfish County) sample data set"
  822. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  823. ;----------------------------------------------------------------------------------------------------------------------------