forked from gcompris/GCompris-gtk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcompris-installer.nsi.in
865 lines (724 loc) · 22.3 KB
/
gcompris-installer.nsi.in
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
; Installer script for win32 GCompris
; Copyed from GAIM By Herman Bloggs <hermanator12002@yahoo.com>
; Bruno Coudoin for GCompris
;
; NOTE: this .NSI script is intended for NSIS 2.0 (finale release).
;
;--------------------------------
;Global Variables
Var name
Var LANG_IS_SET
Var ISSILENT
Var STARTUP_RUN_KEY
;--------------------------------
;Configuration
;The name var is set in .onInit
Name $name
!define GCOMPRIS_VERSION "@VERSION@"
OutFile "gcompris-${GCOMPRIS_VERSION}.exe"
UninstallIcon ".\gcompris-uninstal.ico"
SetCompressor lzma
ShowInstDetails hide
ShowUninstDetails hide
SetDateSave on
; $name and $INSTDIR are set in .onInit function..
!include "MUI.nsh"
!include "Sections.nsh"
;--------------------------------
;Defines
!define GCOMPRIS_NSIS_INCLUDE_PATH ".\nsis"
!define GCOMPRIS_INSTALLER_DEPS "..\win32-dev\gcompris-inst-deps"
!define GCOMPRIS_REG_KEY "SOFTWARE\gcompris"
!define GCOMPRIS_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GCompris"
!define HKLM_APP_PATHS_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\gcompris.exe"
!define GCOMPRIS_STARTUP_RUN_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
!define GCOMPRIS_UNINST_EXE "gcompris-uninst.exe"
!define GCOMPRIS_REG_LANG "Installer Language"
;--------------------------------
;Modern UI Configuration
!define MUI_ICON ".\gcompris-install.ico"
!define MUI_UNICON ".\gcompris-uninstal.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP ".\nsis\gcompris-intro.bmp"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP ".\nsis\gcompris-header.bmp"
!define MUI_ABORTWARNING
;Finish Page config
!define MUI_FINISHPAGE_RUN "$INSTDIR\gcompris.exe"
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_LINK $(GcomprisFinishVisitWebSite)
!define MUI_FINISHPAGE_LINK_LOCATION "http://gcompris.net/"
;--------------------------------
;Pages
!insertmacro MUI_PAGE_WELCOME
; GCompris install dir page
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------
;Languages
@INSERT_TRANSLATIONS@
;--------------------------------
;Reserve Files
; Only need this if using bzip2 compression
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
!insertmacro MUI_RESERVEFILE_LANGDLL
ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Start Install Sections ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;--------------------------------
;Uninstall any old version of GCompris
Section -SecUninstallOldGcompris
; Check install rights..
Call CheckUserInstallRights
Pop $R0
;If gcompris is currently set to run on startup,
; save the section of the Registry where the setting is before uninstalling,
; so we can put it back after installing the new version
ClearErrors
ReadRegStr $STARTUP_RUN_KEY HKCU "${GCOMPRIS_STARTUP_RUN_KEY}" "Gcompris"
IfErrors +3
StrCpy $STARTUP_RUN_KEY "HKCU"
Goto +4
ReadRegStr $STARTUP_RUN_KEY HKLM "${GCOMPRIS_STARTUP_RUN_KEY}" "Gcompris"
IfErrors +2
StrCpy $STARTUP_RUN_KEY "HKLM"
StrCmp $R0 "HKLM" gcompris_hklm
StrCmp $R0 "HKCU" gcompris_hkcu done
gcompris_hkcu:
ReadRegStr $R1 HKCU ${GCOMPRIS_REG_KEY} ""
ReadRegStr $R2 HKCU ${GCOMPRIS_REG_KEY} "Version"
ReadRegStr $R3 HKCU "${GCOMPRIS_UNINSTALL_KEY}" "UninstallString"
Goto try_uninstall
gcompris_hklm:
ReadRegStr $R1 HKLM ${GCOMPRIS_REG_KEY} ""
ReadRegStr $R2 HKLM ${GCOMPRIS_REG_KEY} "Version"
ReadRegStr $R3 HKLM "${GCOMPRIS_UNINSTALL_KEY}" "UninstallString"
; If previous version exists .. remove
try_uninstall:
StrCmp $R1 "" done
; Version key started with 0.60a3. Prior versions can't be
; automaticlly uninstalled.
StrCmp $R2 "" uninstall_problem
; Check if we have uninstall string..
IfFileExists $R3 0 uninstall_problem
; Have uninstall string.. go ahead and uninstall.
; In this case just wipe out previous GCompris install dir..
; We get here because versions 0.60a1 and 0.60a2 don't have versions set in the registry
; and versions 0.60 and lower did not correctly set the uninstall reg string
; (the string was set in quotes)
MessageBox MB_YESNO $(GcomprisPromptWipeout) IDYES do_wipeout IDNO cancel_install
cancel_install:
Quit
SetOverwrite on
; Need to copy uninstaller outside of the install dir
ClearErrors
CopyFiles /SILENT $R3 "$TEMP\${GCOMPRIS_UNINST_EXE}"
SetOverwrite off
IfErrors uninstall_problem
; Ready to uninstall..
ClearErrors
ExecWait '"$TEMP\${GCOMPRIS_UNINST_EXE}" /S _?=$R1'
IfErrors exec_error
Delete "$TEMP\${GCOMPRIS_UNINST_EXE}"
Goto done
exec_error:
Delete "$TEMP\${GCOMPRIS_UNINST_EXE}"
Goto uninstall_problem
uninstall_problem:
; In this case just wipe out previous GCompris install dir..
; We get here because versions 0.60a1 and 0.60a2 don't have versions set in the registry
; and versions 0.60 and lower did not correctly set the uninstall reg string
; (the string was set in quotes)
IfSilent do_wipeout
MessageBox MB_YESNO "Uninstall previous version?" IDYES do_wipeout IDNO done
do_wipeout:
StrCmp $R0 "HKLM" gcompris_del_lm_reg gcompris_del_cu_reg
gcompris_del_cu_reg:
DeleteRegKey HKCU ${GCOMPRIS_REG_KEY}
gcompris_del_lm_reg:
DeleteRegKey HKLM ${GCOMPRIS_REG_KEY}
done:
SectionEnd
;--------------------------------
;GCompris Install Section
Section "GCompris" SecGcompris
SectionIn 1 RO
; Check install rights..
Call CheckUserInstallRights
Pop $R0
; Get GTK+ lib dir if we have it..
StrCmp $R0 "NONE" gcompris_none
StrCmp $R0 "HKLM" gcompris_hklm gcompris_hkcu
gcompris_hklm:
WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "" "$INSTDIR\gcompris.exe"
WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "Path" "$R1\bin"
WriteRegStr HKLM ${GCOMPRIS_REG_KEY} "" "$INSTDIR"
WriteRegStr HKLM ${GCOMPRIS_REG_KEY} "Version" "${GCOMPRIS_VERSION}"
WriteRegStr HKLM "${GCOMPRIS_UNINSTALL_KEY}" "DisplayName" "GCompris Uninstall"
WriteRegStr HKLM "${GCOMPRIS_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${GCOMPRIS_UNINST_EXE}"
; Sets scope of the desktop and Start Menu entries for all users.
SetShellVarContext "all"
Goto gcompris_install_files
gcompris_hkcu:
WriteRegStr HKCU ${GCOMPRIS_REG_KEY} "" "$INSTDIR"
WriteRegStr HKCU ${GCOMPRIS_REG_KEY} "Version" "${GCOMPRIS_VERSION}"
WriteRegStr HKCU "${GCOMPRIS_UNINSTALL_KEY}" "DisplayName" "GCompris Uninstall"
WriteRegStr HKCU "${GCOMPRIS_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${GCOMPRIS_UNINST_EXE}"
Goto gcompris_install_files
gcompris_none:
gcompris_install_files:
SetOutPath "$INSTDIR"
; GCompris files
SetOverwrite on
File /r .\win32-install-dir\*.*
; If this is under NT4, delete the SILC support stuff
; there is a bug that will prevent any account from connecting
; See https://lists.silcnet.org/pipermail/silc-devel/2005-January/001588.html
Call GetWindowsVersion
Pop $R2
StrCmp $R2 "NT 4.0" 0 nt4_done
Delete "$INSTDIR\plugins\libsilc.dll"
Delete "$INSTDIR\silcclient.dll"
Delete "$INSTDIR\silc.dll"
nt4_done:
CreateDirectory "$SMPROGRAMS\GCompris"
CreateShortCut "$SMPROGRAMS\GCompris\GCompris.lnk" "$INSTDIR\gcompris.exe"
CreateShortCut "$DESKTOP\GCompris.lnk" "$INSTDIR\gcompris.exe"
CreateShortCut "$SMPROGRAMS\GCompris\GCompris Admin.lnk" "$INSTDIR\gcompris.exe" `-a` "$INSTDIR\gcompris.exe" 1
CreateShortCut "$DESKTOP\GCompris Admin.lnk" "$INSTDIR\gcompris.exe" `-a` "$INSTDIR\gcompris.exe" 1
SetOutPath "$INSTDIR"
; If we don't have install rights.. we're done
StrCmp $R0 "NONE" done
CreateShortCut "$SMPROGRAMS\GCompris\Uninstall.lnk" "$INSTDIR\${GCOMPRIS_UNINST_EXE}"
SetOverwrite off
; Write out installer language
WriteRegStr HKCU "${GCOMPRIS_REG_KEY}" "${GCOMPRIS_REG_LANG}" "$LANGUAGE"
; write out uninstaller
SetOverwrite on
WriteUninstaller "$INSTDIR\${GCOMPRIS_UNINST_EXE}"
SetOverwrite off
; If we previously had gcompris setup to run on startup, make it do so again
StrCmp $STARTUP_RUN_KEY "HKCU" +1 +2
WriteRegStr HKCU "${GCOMPRIS_STARTUP_RUN_KEY}" "Gcompris" "$INSTDIR\gcompris.exe"
StrCmp $STARTUP_RUN_KEY "HKLM" +1 +2
WriteRegStr HKLM "${GCOMPRIS_STARTUP_RUN_KEY}" "Gcompris" "$INSTDIR\gcompris.exe"
done:
SectionEnd ; end of default GCompris section
;--------------------------------
;Uninstaller Section
Section Uninstall
Call un.CheckUserInstallRights
Pop $R0
StrCmp $R0 "NONE" no_rights
StrCmp $R0 "HKCU" try_hkcu try_hklm
try_hkcu:
ReadRegStr $R0 HKCU ${GCOMPRIS_REG_KEY} ""
StrCmp $R0 $INSTDIR 0 cant_uninstall
; HKCU install path matches our INSTDIR.. so uninstall
DeleteRegKey HKCU ${GCOMPRIS_REG_KEY}
DeleteRegKey HKCU "${GCOMPRIS_UNINSTALL_KEY}"
Goto cont_uninstall
try_hklm:
ReadRegStr $R0 HKLM ${GCOMPRIS_REG_KEY} ""
StrCmp $R0 $INSTDIR 0 try_hkcu
; HKLM install path matches our INSTDIR.. so uninstall
DeleteRegKey HKLM ${GCOMPRIS_REG_KEY}
DeleteRegKey HKLM "${GCOMPRIS_UNINSTALL_KEY}"
DeleteRegKey HKLM "${HKLM_APP_PATHS_KEY}"
; Sets start menu and desktop scope to all users..
SetShellVarContext "all"
cont_uninstall:
; The WinPrefs plugin may have left this behind..
DeleteRegValue HKCU "${GCOMPRIS_STARTUP_RUN_KEY}" "Gcompris"
DeleteRegValue HKLM "${GCOMPRIS_STARTUP_RUN_KEY}" "Gcompris"
; Remove Language preference info
DeleteRegKey HKCU ${GCOMPRIS_REG_KEY} ;${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
RMDir /r "$INSTDIR\etc"
RMDir /r "$INSTDIR\GTK"
RMDir /r "$INSTDIR\lib"
RMDir /r "$INSTDIR\share"
Delete "$INSTDIR\gcompris.exe"
Delete "$INSTDIR\${GCOMPRIS_UNINST_EXE}"
Delete "$INSTDIR\COPYING"
Delete "$INSTDIR\README"
Delete "$INSTDIR\SDL.dll"
Delete "$INSTDIR\SDL_mixer.dll"
Delete "$INSTDIR\cairo._cairo.pyd"
Delete "$INSTDIR\gtk._gtk.pyd"
Delete "$INSTDIR\_hashlib.pyd"
Delete "$INSTDIR\_socket.pyd"
Delete "$INSTDIR\_ssl.pyd"
Delete "$INSTDIR\_tkinter.pyd"
Delete "$INSTDIR\atk.pyd"
Delete "$INSTDIR\bz2.pyd"
Delete "$INSTDIR\freetype6.dll"
Delete "$INSTDIR\gnucap.exe"
Delete "$INSTDIR\bin\gnuchess.exe"
RMDir "$INSTDIR\bin"
Delete "$INSTDIR\gobject.pyd"
Delete "$INSTDIR\gspawn-win32-helper-console.exe"
Delete "$INSTDIR\gspawn-win32-helper.exe"
Delete "$INSTDIR\iconv.dll"
Delete "$INSTDIR\intl.dll"
Delete "$INSTDIR\jpeg62.dll"
Delete "$INSTDIR\libart_lgpl_2-2.dll"
Delete "$INSTDIR\libatk-1.0-0.dll"
Delete "$INSTDIR\libcairo-2.dll"
Delete "$INSTDIR\libfontconfig-1.dll"
Delete "$INSTDIR\libgdk-win32-2.0-0.dll"
Delete "$INSTDIR\libgdk_pixbuf-2.0-0.dll"
Delete "$INSTDIR\libglib-2.0-0.dll"
Delete "$INSTDIR\libgmodule-2.0-0.dll"
Delete "$INSTDIR\libgobject-2.0-0.dll"
Delete "$INSTDIR\libgthread-2.0-0.dll"
Delete "$INSTDIR\libgtk-win32-2.0-0.dll"
Delete "$INSTDIR\libiconv-2.dll"
Delete "$INSTDIR\libintl-2.dll"
Delete "$INSTDIR\libpango-1.0-0.dll"
Delete "$INSTDIR\libpangocairo-1.0-0.dll"
Delete "$INSTDIR\libpangoft2-1.0-0.dll"
Delete "$INSTDIR\libpangowin32-1.0-0.dll"
Delete "$INSTDIR\libreadline.dll"
Delete "$INSTDIR\libxml2.dll"
Delete "$INSTDIR\pango.pyd"
Delete "$INSTDIR\pangocairo.pyd"
Delete "$INSTDIR\pthreadGC.dll"
Delete "$INSTDIR\select.pyd"
Delete "$INSTDIR\setup.py"
Delete "$INSTDIR\sqlite3.dll"
Delete "$INSTDIR\unicodedata.pyd"
Delete "$INSTDIR\gio._gio.pyd"
Delete "$INSTDIR\glib._glib.pyd"
Delete "$INSTDIR\xmlparse.dll"
Delete "$INSTDIR\xmltok.dll"
Delete "$INSTDIR\zlib.pyd"
Delete "$INSTDIR\zlib1.dll"
Delete "$INSTDIR\README.mingw"
Delete "$INSTDIR\config.h.mingw"
Delete "$INSTDIR\libexpat.dll"
Delete "$INSTDIR\libgio-2.0-0.dll"
Delete "$INSTDIR\libogg-0.dll"
Delete "$INSTDIR\libpng14-14.dll"
Delete "$INSTDIR\libvorbis-0.dll"
Delete "$INSTDIR\libvorbisfile-3.dll"
Delete "$INSTDIR\pthreadGC2.dll"
Delete "$INSTDIR\README.translators"
Delete "$INSTDIR\_ctypes.pyd"
Delete "$INSTDIR\_sqlite3.pyd"
Delete "$INSTDIR\cairo._cairo.pyd"
Delete "$INSTDIR\gobject._gobject.pyd"
Delete "$INSTDIR\gtk._gtk.pyd"
Delete "$INSTDIR\libcroco-0.6-3.dll"
Delete "$INSTDIR\libexpat-1.dll"
Delete "$INSTDIR\libgio-2.0-0.dll"
Delete "$INSTDIR\libgsf-1-114.dll"
Delete "$INSTDIR\libjpeg-7.dll"
Delete "$INSTDIR\libogg-0.dll"
Delete "$INSTDIR\librsvg-2-2.dll"
Delete "$INSTDIR\libvorbis-0.dll"
Delete "$INSTDIR\libvorbisfile-3.dll"
Delete "$INSTDIR\libxml2-2.dll"
Delete "$INSTDIR\pthreadGC2.dll"
Delete "$INSTDIR\python27.dll"
Delete "$INSTDIR\python27.zip"
Delete "$INSTDIR\Microsoft.VC90.CRT\Microsoft.VC90.CRT.manifest"
Delete "$INSTDIR\Microsoft.VC90.CRT\msvcm90.dll"
Delete "$INSTDIR\Microsoft.VC90.CRT\msvcp90.dll"
Delete "$INSTDIR\Microsoft.VC90.CRT\msvcr90.dll"
RMDir "$INSTDIR\Microsoft.VC90.CRT"
Delete "$INSTDIR\manifest\gtk+-bundle_2.24.10-20120208_win32.mft"
Delete "$INSTDIR\manifest\libcroco_0.6.2-1_win32.mft"
Delete "$INSTDIR\manifest\libgsf_1.14.17-1_win32.mft"
Delete "$INSTDIR\manifest\librsvg_2.32.1-1_win32.mft"
Delete "$INSTDIR\manifest\librsvg-dev_2.32.1-1_win32.mft"
Delete "$INSTDIR\manifest\svg-gdk-pixbuf-loader_2.32.1-1_win32.mft"
Delete "$INSTDIR\manifest\svg-gtk-engine_2.32.1-1_win32.mft"
RMDir "$INSTDIR\manifest"
;Try to remove GCompris install dir .. if empty
RMDir "$INSTDIR"
; Shortcuts..
RMDir /r "$SMPROGRAMS\GCompris"
Delete "$DESKTOP\GCompris.lnk"
Delete "$DESKTOP\GCompris Admin.lnk"
Goto done
cant_uninstall:
IfSilent skip_mb
MessageBox MB_OK $(unGcomprisUninstallError1) IDOK
skip_mb:
Quit
no_rights:
IfSilent skip_mb1
MessageBox MB_OK $(unGcomprisUninstallError2) IDOK
skip_mb1:
Quit
done:
SectionEnd ; end of uninstall section
;--------------------------------
;Functions
Function CheckUserInstallRights
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "Power" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "User" 0 +3
StrCpy $1 "HKCU"
Goto done
StrCmp $1 "Guest" 0 +3
StrCpy $1 "NONE"
Goto done
; Unknown error
StrCpy $1 "NONE"
Goto done
Win9x:
StrCpy $1 "HKLM"
done:
Push $1
FunctionEnd
Function un.CheckUserInstallRights
ClearErrors
UserInfo::GetName
IfErrors Win9x
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "Power" 0 +3
StrCpy $1 "HKLM"
Goto done
StrCmp $1 "User" 0 +3
StrCpy $1 "HKCU"
Goto done
StrCmp $1 "Guest" 0 +3
StrCpy $1 "NONE"
Goto done
; Unknown error
StrCpy $1 "NONE"
Goto done
Win9x:
StrCpy $1 "HKLM"
done:
Push $1
FunctionEnd
;
; Usage:
; Push $0 ; Path string
; Call VerifyDir
; Pop $0 ; 0 - Bad path 1 - Good path
;
Function VerifyDir
Pop $0
Loop:
IfFileExists $0 dir_exists
StrCpy $1 $0 ; save last
Push $0
Call GetParent
Pop $0
StrLen $2 $0
; IfFileExists "C:" on xp returns true and on win2k returns false
; So we're done in such a case..
IntCmp $2 2 loop_done
; GetParent of "C:" returns ""
IntCmp $2 0 loop_done
Goto Loop
loop_done:
StrCpy $1 "$0\GcomprisFooB"
; Check if we can create dir on this drive..
ClearErrors
CreateDirectory $1
IfErrors DirBad DirGood
dir_exists:
ClearErrors
FileOpen $1 "$0\gcomprisfoo.bar" w
IfErrors PathBad PathGood
DirGood:
RMDir $1
Goto PathGood1
DirBad:
RMDir $1
Goto PathBad1
PathBad:
FileClose $1
Delete "$0\gcomprisfoo.bar"
PathBad1:
StrCpy $0 "0"
Push $0
Return
PathGood:
FileClose $1
Delete "$0\gcomprisfoo.bar"
PathGood1:
StrCpy $0 "1"
Push $0
FunctionEnd
Function .onVerifyInstDir
Push $INSTDIR
Call VerifyDir
Pop $0
StrCmp $0 "0" 0 dir_good
Abort
dir_good:
FunctionEnd
; GetParent
; input, top of stack (e.g. C:\Program Files\Poop)
; output, top of stack (replaces, with e.g. C:\Program Files)
; modifies no other variables.
;
; Usage:
; Push "C:\Program Files\Directory\Whatever"
; Call GetParent
; Pop $R0
; ; at this point $R0 will equal "C:\Program Files\Directory"
Function GetParent
Exch $0 ; old $0 is on top of stack
Push $1
Push $2
StrCpy $1 -1
loop:
StrCpy $2 $0 1 $1
StrCmp $2 "" exit
StrCmp $2 "\" exit
IntOp $1 $1 - 1
Goto loop
exit:
StrCpy $0 $0 $1
Pop $2
Pop $1
Exch $0 ; put $0 on top of stack, restore $0 to original value
FunctionEnd
Function RunCheck
System::Call 'kernel32::OpenMutex(i 2031617, b 0, t "gcompris_is_running") i .R0'
IntCmp $R0 0 done
MessageBox MB_OK|MB_ICONEXCLAMATION $(GcomprisIsRunning) IDOK
Abort
done:
FunctionEnd
Function un.RunCheck
System::Call 'kernel32::OpenMutex(i 2031617, b 0, t "gcompris_is_running") i .R0'
IntCmp $R0 0 done
MessageBox MB_OK|MB_ICONEXCLAMATION $(GcomprisIsRunning) IDOK
Abort
done:
FunctionEnd
Function .onInit
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "gcompris_installer_running") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION $(InstallerIsRunning)
Abort
Call RunCheck
StrCpy $name "GCompris ${GCOMPRIS_VERSION}"
StrCpy $ISSILENT "/NOUI"
; GTK installer has two silent states.. one with Message boxes, one without
; If gcompris installer was run silently, we want to supress gtk installer msg boxes.
IfSilent 0 set_gtk_normal
StrCpy $ISSILENT "/S"
set_gtk_normal:
Call ParseParameters
; Select Language
IntCmp $LANG_IS_SET 1 skip_lang
; Display Language selection dialog
!insertmacro MUI_LANGDLL_DISPLAY
skip_lang:
; If install path was set on the command, use it.
StrCmp $INSTDIR "" 0 instdir_done
; If gcompris is currently intalled, we should default to where it is currently installed
ClearErrors
ReadRegStr $INSTDIR HKCU "${GCOMPRIS_REG_KEY}" ""
IfErrors +2
StrCmp $INSTDIR "" 0 instdir_done
ReadRegStr $INSTDIR HKLM "${GCOMPRIS_REG_KEY}" ""
IfErrors +2
StrCmp $INSTDIR "" 0 instdir_done
Call CheckUserInstallRights
Pop $0
StrCmp $0 "HKLM" 0 user_dir
StrCpy $INSTDIR "$PROGRAMFILES\GCompris"
Goto instdir_done
user_dir:
StrCpy $2 "$SMPROGRAMS"
Push $2
Call GetParent
Call GetParent
Pop $2
StrCpy $INSTDIR "$2\GCompris"
instdir_done:
FunctionEnd
Function un.onInit
Call un.RunCheck
StrCpy $name "GCompris ${GCOMPRIS_VERSION}"
; Get stored language prefrence
ReadRegStr $LANGUAGE HKCU ${GCOMPRIS_REG_KEY} "${GCOMPRIS_REG_LANG}"
FunctionEnd
; GetParameters
; input, none
; output, top of stack (replaces, with e.g. whatever)
; modifies no other variables.
Function GetParameters
Push $R0
Push $R1
Push $R2
Push $R3
StrCpy $R2 1
StrLen $R3 $CMDLINE
;Check for quote or space
StrCpy $R0 $CMDLINE $R2
StrCmp $R0 '"' 0 +3
StrCpy $R1 '"'
Goto loop
StrCpy $R1 " "
loop:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 $R1 get
StrCmp $R2 $R3 get
Goto loop
get:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 " " get
StrCpy $R0 $CMDLINE "" $R2
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
; StrStr
; input, top of stack = string to search for
; top of stack-1 = string to search in
; output, top of stack (replaces with the portion of the string remaining)
; modifies no other variables.
;
; Usage:
; Push "this is a long ass string"
; Push "ass"
; Call StrStr
; Pop $R0
; ($R0 at this point is "ass string")
Function StrStr
Exch $R1 ; st=haystack,old$R1, $R1=needle
Exch ; st=old$R1,haystack
Exch $R2 ; st=old$R1,old$R2, $R2=haystack
Push $R3
Push $R4
Push $R5
StrLen $R3 $R1
StrCpy $R4 0
; $R1=needle
; $R2=haystack
; $R3=len(needle)
; $R4=cnt
; $R5=tmp
loop:
StrCpy $R5 $R2 $R3 $R4
StrCmp $R5 $R1 done
StrCmp $R5 "" done
IntOp $R4 $R4 + 1
Goto loop
done:
StrCpy $R1 $R2 "" $R4
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Exch $R1
FunctionEnd
;
; Parse the Command line
;
; Unattended install command line parameters
; /L=Language e.g.: /L=1033
;
Function ParseParameters
IntOp $LANG_IS_SET 0 + 0
Call GetParameters
Pop $R0
Push $R0
Push "L="
Call StrStr
Pop $R1
StrCmp $R1 "" next
StrCpy $R1 $R1 4 2 ; Strip first 2 chars of string
StrCpy $LANGUAGE $R1
IntOp $LANG_IS_SET 0 + 1
next:
FunctionEnd
; GetWindowsVersion
;
; Based on Yazno's function, http://yazno.tripod.com/powerpimpit/
; Updated by Joost Verburg
;
; Returns on top of stack
;
; Windows Version (95, 98, ME, NT x.x, 2000, XP, 2003)
; or
; '' (Unknown Windows Version)
;
; Usage:
; Call GetWindowsVersion
; Pop $R0
;
; at this point $R0 is "NT 4.0" or whatnot
Function GetWindowsVersion
Push $R0
Push $R1
ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
IfErrors 0 lbl_winnt
; we are not NT
ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber
StrCpy $R1 $R0 1
StrCmp $R1 '4' 0 lbl_error
StrCpy $R1 $R0 3
StrCmp $R1 '4.0' lbl_win32_95
StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98
lbl_win32_95:
StrCpy $R0 '95'
Goto lbl_done
lbl_win32_98:
StrCpy $R0 '98'
Goto lbl_done
lbl_win32_ME:
StrCpy $R0 'ME'
Goto lbl_done
lbl_winnt:
StrCpy $R1 $R0 1
StrCmp $R1 '3' lbl_winnt_x
StrCmp $R1 '4' lbl_winnt_x
StrCpy $R1 $R0 3
StrCmp $R1 '5.0' lbl_winnt_2000
StrCmp $R1 '5.1' lbl_winnt_XP
StrCmp $R1 '5.2' lbl_winnt_2003 lbl_error
lbl_winnt_x:
StrCpy $R0 "NT $R0" 6
Goto lbl_done
lbl_winnt_2000:
Strcpy $R0 '2000'
Goto lbl_done
lbl_winnt_XP:
Strcpy $R0 'XP'
Goto lbl_done
lbl_winnt_2003:
Strcpy $R0 '2003'
Goto lbl_done
lbl_error:
Strcpy $R0 ''
lbl_done:
Pop $R1
Exch $R0
FunctionEnd