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