~ml-launchpad/ubuntu/natty/gcompris/fix-for-777349

« back to all changes in this revision

Viewing changes to gcompris-installer.nsi

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2010-01-13 09:38:34 UTC
  • Revision ID: james.westby@ubuntu.com-20100113093834-kklcpda0cs0n3cxd
Tags: 9.0-0ubuntu5
Revert dependency on python-pysqlite2.  This module is now provided by
the python package, the alternative on python-pysqlite2 was included
only for backwards-compatibility with pre-jaunty versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
; Installer script for win32 Gcompris
 
2
; Copyed from GAIM By Herman Bloggs <hermanator12002@yahoo.com>
 
3
; Bruno Coudoin for GCompris
 
4
;
 
5
; NOTE: this .NSI script is intended for NSIS 2.0 (finale release).
 
6
;
 
7
 
 
8
;--------------------------------
 
9
;Global Variables
 
10
Var name
 
11
Var LANG_IS_SET
 
12
Var ISSILENT
 
13
Var STARTUP_RUN_KEY
 
14
 
 
15
;--------------------------------
 
16
;Configuration
 
17
 
 
18
;The name var is set in .onInit
 
19
Name $name
 
20
 
 
21
!define GCOMPRIS_VERSION                        "9.0"
 
22
 
 
23
OutFile "gcompris-${GCOMPRIS_VERSION}.exe"
 
24
 
 
25
UninstallIcon ".\gcompris-uninstal.ico"
 
26
 
 
27
SetCompressor lzma
 
28
ShowInstDetails hide
 
29
ShowUninstDetails hide
 
30
SetDateSave on
 
31
 
 
32
; $name and $INSTDIR are set in .onInit function..
 
33
 
 
34
!include "MUI.nsh"
 
35
!include "Sections.nsh"
 
36
 
 
37
;--------------------------------
 
38
;Defines
 
39
 
 
40
!define GCOMPRIS_NSIS_INCLUDE_PATH              ".\nsis"
 
41
!define GCOMPRIS_INSTALLER_DEPS                 "..\win32-dev\gcompris-inst-deps"
 
42
 
 
43
!define GCOMPRIS_REG_KEY                        "SOFTWARE\gcompris"
 
44
!define GCOMPRIS_UNINSTALL_KEY                  "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Gcompris"
 
45
!define HKLM_APP_PATHS_KEY                      "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\gcompris.exe"
 
46
!define GCOMPRIS_STARTUP_RUN_KEY                "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
 
47
!define GCOMPRIS_UNINST_EXE                     "gcompris-uninst.exe"
 
48
!define GCOMPRIS_REG_LANG                       "Installer Language"
 
49
 
 
50
;--------------------------------
 
51
;Modern UI Configuration
 
52
 
 
53
  !define MUI_ICON                              ".\gcompris.ico"
 
54
  !define MUI_UNICON                            ".\gcompris-uninstal.ico"
 
55
  !define MUI_WELCOMEFINISHPAGE_BITMAP          ".\nsis\gcompris-intro.bmp"
 
56
  !define MUI_HEADERIMAGE
 
57
  !define MUI_HEADERIMAGE_BITMAP                ".\nsis\gcompris-header.bmp"
 
58
 
 
59
  ; Alter License section
 
60
  !define MUI_LICENSEPAGE_BUTTON                $(GCOMPRIS_LICENSE_BUTTON)
 
61
  !define MUI_LICENSEPAGE_TEXT_BOTTOM           $(GCOMPRIS_LICENSE_BOTTOM_TEXT)
 
62
 
 
63
  !define MUI_COMPONENTSPAGE_SMALLDESC
 
64
  !define MUI_ABORTWARNING
 
65
 
 
66
  ;Finish Page config
 
67
  !define MUI_FINISHPAGE_RUN                    "$INSTDIR\gcompris.exe"
 
68
  !define MUI_FINISHPAGE_RUN_NOTCHECKED
 
69
  !define MUI_FINISHPAGE_LINK                   $(GCOMPRIS_FINISH_VISIT_WEB_SITE)
 
70
  !define MUI_FINISHPAGE_LINK_LOCATION          "http://gcompris.net/"
 
71
 
 
72
;--------------------------------
 
73
;Pages
 
74
 
 
75
  !insertmacro MUI_PAGE_WELCOME
 
76
  !insertmacro MUI_PAGE_LICENSE                 "./COPYING"
 
77
  !insertmacro MUI_PAGE_COMPONENTS
 
78
 
 
79
  ; Gcompris install dir page
 
80
  !insertmacro MUI_PAGE_DIRECTORY
 
81
 
 
82
  !insertmacro MUI_PAGE_INSTFILES
 
83
  !insertmacro MUI_PAGE_FINISH
 
84
 
 
85
  !insertmacro MUI_UNPAGE_WELCOME
 
86
  !insertmacro MUI_UNPAGE_CONFIRM
 
87
  !insertmacro MUI_UNPAGE_INSTFILES
 
88
  !insertmacro MUI_UNPAGE_FINISH
 
89
 
 
90
;--------------------------------
 
91
;Languages
 
92
 
 
93
  ;; English goes first because its the default. The rest are
 
94
  ;; in alphabetical order (at least the strings actually displayed
 
95
  ;; will be).
 
96
 
 
97
  !insertmacro MUI_LANGUAGE "English"
 
98
 
 
99
  !insertmacro MUI_LANGUAGE "Albanian"
 
100
  !insertmacro MUI_LANGUAGE "Bulgarian"
 
101
  !insertmacro MUI_LANGUAGE "Catalan"
 
102
  !insertmacro MUI_LANGUAGE "Czech"
 
103
  !insertmacro MUI_LANGUAGE "Danish"
 
104
  !insertmacro MUI_LANGUAGE "SimpChinese"
 
105
  !insertmacro MUI_LANGUAGE "TradChinese"
 
106
  !insertmacro MUI_LANGUAGE "German"
 
107
  !insertmacro MUI_LANGUAGE "Spanish"
 
108
  !insertmacro MUI_LANGUAGE "French"
 
109
  !insertmacro MUI_LANGUAGE "Hebrew"
 
110
  !insertmacro MUI_LANGUAGE "Italian"
 
111
  !insertmacro MUI_LANGUAGE "Japanese"
 
112
  !insertmacro MUI_LANGUAGE "Korean"
 
113
  !insertmacro MUI_LANGUAGE "Hungarian"
 
114
  !insertmacro MUI_LANGUAGE "Dutch"
 
115
  !insertmacro MUI_LANGUAGE "Norwegian"
 
116
  !insertmacro MUI_LANGUAGE "Polish"
 
117
  !insertmacro MUI_LANGUAGE "PortugueseBR"
 
118
  !insertmacro MUI_LANGUAGE "Portuguese"
 
119
  !insertmacro MUI_LANGUAGE "Romanian"
 
120
  !insertmacro MUI_LANGUAGE "Russian"
 
121
  !insertmacro MUI_LANGUAGE "Serbian"
 
122
  !insertmacro MUI_LANGUAGE "Slovak"
 
123
  !insertmacro MUI_LANGUAGE "Slovenian"
 
124
  !insertmacro MUI_LANGUAGE "Finnish"
 
125
  !insertmacro MUI_LANGUAGE "Swedish"
 
126
 
 
127
;--------------------------------
 
128
;Translations
 
129
 
 
130
  !define GCOMPRIS_DEFAULT_LANGFILE "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\english.nsh"
 
131
 
 
132
  !include "${GCOMPRIS_NSIS_INCLUDE_PATH}\langmacros.nsh"
 
133
 
 
134
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "ALBANIAN"               "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\albanian.nsh"
 
135
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "BULGARIAN"              "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\bulgarian.nsh"
 
136
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "CATALAN"                "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\catalan.nsh"
 
137
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "CZECH"          "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\czech.nsh"
 
138
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "DANISH"         "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\danish.nsh"
 
139
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "DUTCH"          "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\dutch.nsh"
 
140
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "ENGLISH"                "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\english.nsh"
 
141
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "FINNISH"                "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\finnish.nsh"
 
142
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "FRENCH"         "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\french.nsh"
 
143
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "GERMAN"         "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\german.nsh"
 
144
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "HEBREW"         "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\hebrew.nsh"
 
145
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "HUNGARIAN"              "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\hungarian.nsh"
 
146
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "ITALIAN"                "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\italian.nsh"
 
147
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "JAPANESE"               "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\japanese.nsh"
 
148
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "KOREAN"         "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\korean.nsh"
 
149
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "NORWEGIAN"              "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\norwegian.nsh"
 
150
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "POLISH"         "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\polish.nsh"
 
151
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "PORTUGUESE"             "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\portuguese.nsh"
 
152
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "PORTUGUESEBR"   "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\portuguese-br.nsh"
 
153
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "ROMANIAN"               "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\romanian.nsh"
 
154
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "RUSSIAN"                "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\russian.nsh"
 
155
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "SERBIAN"                "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\serbian-latin.nsh"
 
156
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "SIMPCHINESE"    "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\simp-chinese.nsh"
 
157
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "SLOVAK"         "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\slovak.nsh"
 
158
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "SLOVENIAN"              "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\slovenian.nsh"
 
159
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "SPANISH"                "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\spanish.nsh"
 
160
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "SWEDISH"                "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\swedish.nsh"
 
161
  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "TRADCHINESE"    "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\trad-chinese.nsh"
 
162
 
 
163
;--------------------------------
 
164
;Reserve Files
 
165
  ; Only need this if using bzip2 compression
 
166
 
 
167
  !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
 
168
  !insertmacro MUI_RESERVEFILE_LANGDLL
 
169
  ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
 
170
 
 
171
 
 
172
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
173
;; Start Install Sections ;;
 
174
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
175
 
 
176
;--------------------------------
 
177
;Uninstall any old version of Gcompris
 
178
 
 
179
Section -SecUninstallOldGcompris
 
180
  ; Check install rights..
 
181
  Call CheckUserInstallRights
 
182
  Pop $R0
 
183
 
 
184
  ;If gcompris is currently set to run on startup,
 
185
  ;  save the section of the Registry where the setting is before uninstalling,
 
186
  ;  so we can put it back after installing the new version
 
187
  ClearErrors
 
188
  ReadRegStr $STARTUP_RUN_KEY HKCU "${GCOMPRIS_STARTUP_RUN_KEY}" "Gcompris"
 
189
  IfErrors +3
 
190
  StrCpy $STARTUP_RUN_KEY "HKCU"
 
191
  Goto +4
 
192
  ReadRegStr $STARTUP_RUN_KEY HKLM "${GCOMPRIS_STARTUP_RUN_KEY}" "Gcompris"
 
193
  IfErrors +2
 
194
  StrCpy $STARTUP_RUN_KEY "HKLM"
 
195
 
 
196
  StrCmp $R0 "HKLM" gcompris_hklm
 
197
  StrCmp $R0 "HKCU" gcompris_hkcu done
 
198
 
 
199
  gcompris_hkcu:
 
200
      ReadRegStr $R1 HKCU ${GCOMPRIS_REG_KEY} ""
 
201
      ReadRegStr $R2 HKCU ${GCOMPRIS_REG_KEY} "Version"
 
202
      ReadRegStr $R3 HKCU "${GCOMPRIS_UNINSTALL_KEY}" "UninstallString"
 
203
      Goto try_uninstall
 
204
 
 
205
  gcompris_hklm:
 
206
      ReadRegStr $R1 HKLM ${GCOMPRIS_REG_KEY} ""
 
207
      ReadRegStr $R2 HKLM ${GCOMPRIS_REG_KEY} "Version"
 
208
      ReadRegStr $R3 HKLM "${GCOMPRIS_UNINSTALL_KEY}" "UninstallString"
 
209
 
 
210
  ; If previous version exists .. remove
 
211
  try_uninstall:
 
212
    StrCmp $R1 "" done
 
213
      ; Version key started with 0.60a3. Prior versions can't be
 
214
      ; automaticlly uninstalled.
 
215
      StrCmp $R2 "" uninstall_problem
 
216
        ; Check if we have uninstall string..
 
217
        IfFileExists $R3 0 uninstall_problem
 
218
          ; Have uninstall string.. go ahead and uninstall.
 
219
 
 
220
          ; In this case just wipe out previous Gcompris install dir..
 
221
          ; We get here because versions 0.60a1 and 0.60a2 don't have versions set in the registry
 
222
          ; and versions 0.60 and lower did not correctly set the uninstall reg string
 
223
          ; (the string was set in quotes)
 
224
          MessageBox MB_YESNO $(GCOMPRIS_PROMPT_WIPEOUT) IDYES do_wipeout IDNO cancel_install
 
225
          cancel_install:
 
226
            Quit
 
227
 
 
228
          SetOverwrite on
 
229
          ; Need to copy uninstaller outside of the install dir
 
230
          ClearErrors
 
231
          CopyFiles /SILENT $R3 "$TEMP\${GCOMPRIS_UNINST_EXE}"
 
232
          SetOverwrite off
 
233
          IfErrors uninstall_problem
 
234
            ; Ready to uninstall..
 
235
            ClearErrors
 
236
            ExecWait '"$TEMP\${GCOMPRIS_UNINST_EXE}" /S _?=$R1'
 
237
            IfErrors exec_error
 
238
              Delete "$TEMP\${GCOMPRIS_UNINST_EXE}"
 
239
              Goto done
 
240
 
 
241
            exec_error:
 
242
              Delete "$TEMP\${GCOMPRIS_UNINST_EXE}"
 
243
              Goto uninstall_problem
 
244
 
 
245
        uninstall_problem:
 
246
          ; In this case just wipe out previous Gcompris install dir..
 
247
          ; We get here because versions 0.60a1 and 0.60a2 don't have versions set in the registry
 
248
          ; and versions 0.60 and lower did not correctly set the uninstall reg string
 
249
          ; (the string was set in quotes)
 
250
          IfSilent do_wipeout
 
251
          MessageBox MB_YESNO "Uninstall previous version?" IDYES do_wipeout IDNO done
 
252
 
 
253
          do_wipeout:
 
254
            StrCmp $R0 "HKLM" gcompris_del_lm_reg gcompris_del_cu_reg
 
255
            gcompris_del_cu_reg:
 
256
              DeleteRegKey HKCU ${GCOMPRIS_REG_KEY}
 
257
              Goto uninstall_prob_cont
 
258
            gcompris_del_lm_reg:
 
259
              DeleteRegKey HKLM ${GCOMPRIS_REG_KEY}
 
260
 
 
261
            uninstall_prob_cont:
 
262
              RMDir /r "$R1"
 
263
 
 
264
  done:
 
265
SectionEnd
 
266
 
 
267
 
 
268
;--------------------------------
 
269
;Gcompris Install Section
 
270
 
 
271
Section $(GCOMPRIS_SECTION_TITLE) SecGcompris
 
272
  SectionIn 1 RO
 
273
 
 
274
  ; Check install rights..
 
275
  Call CheckUserInstallRights
 
276
  Pop $R0
 
277
 
 
278
  ; Get GTK+ lib dir if we have it..
 
279
 
 
280
  StrCmp $R0 "NONE" gcompris_none
 
281
  StrCmp $R0 "HKLM" gcompris_hklm gcompris_hkcu
 
282
 
 
283
  gcompris_hklm:
 
284
    WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "" "$INSTDIR\gcompris.exe"
 
285
    WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "Path" "$R1\bin"
 
286
    WriteRegStr HKLM ${GCOMPRIS_REG_KEY} "" "$INSTDIR"
 
287
    WriteRegStr HKLM ${GCOMPRIS_REG_KEY} "Version" "${GCOMPRIS_VERSION}"
 
288
    WriteRegStr HKLM "${GCOMPRIS_UNINSTALL_KEY}" "DisplayName" $(GCOMPRIS_UNINSTALL_DESC)
 
289
    WriteRegStr HKLM "${GCOMPRIS_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${GCOMPRIS_UNINST_EXE}"
 
290
    ; Sets scope of the desktop and Start Menu entries for all users.
 
291
    SetShellVarContext "all"
 
292
    Goto gcompris_install_files
 
293
 
 
294
  gcompris_hkcu:
 
295
    WriteRegStr HKCU ${GCOMPRIS_REG_KEY} "" "$INSTDIR"
 
296
    WriteRegStr HKCU ${GCOMPRIS_REG_KEY} "Version" "${GCOMPRIS_VERSION}"
 
297
    WriteRegStr HKCU "${GCOMPRIS_UNINSTALL_KEY}" "DisplayName" $(GCOMPRIS_UNINSTALL_DESC)
 
298
    WriteRegStr HKCU "${GCOMPRIS_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${GCOMPRIS_UNINST_EXE}"
 
299
    Goto gcompris_install_files
 
300
 
 
301
  gcompris_none:
 
302
 
 
303
  gcompris_install_files:
 
304
    SetOutPath "$INSTDIR"
 
305
    ; Gcompris files
 
306
    SetOverwrite on
 
307
    File /r .\win32-install-dir\*.*
 
308
 
 
309
    ; If this is under NT4, delete the SILC support stuff
 
310
    ; there is a bug that will prevent any account from connecting
 
311
    ; See https://lists.silcnet.org/pipermail/silc-devel/2005-January/001588.html
 
312
    Call GetWindowsVersion
 
313
    Pop $R2
 
314
    StrCmp $R2 "NT 4.0" 0 nt4_done
 
315
    Delete "$INSTDIR\plugins\libsilc.dll"
 
316
    Delete "$INSTDIR\silcclient.dll"
 
317
    Delete "$INSTDIR\silc.dll"
 
318
 
 
319
    nt4_done:
 
320
 
 
321
    CreateDirectory "$SMPROGRAMS\Gcompris"
 
322
    CreateShortCut "$SMPROGRAMS\Gcompris\Gcompris.lnk" "$INSTDIR\gcompris.exe"
 
323
    CreateShortCut "$DESKTOP\Gcompris.lnk" "$INSTDIR\gcompris.exe"
 
324
    CreateShortCut "$SMPROGRAMS\Gcompris\Gcompris Admin.lnk" "$INSTDIR\gcompris.exe" `-a` "$INSTDIR\gcompris.exe" 1
 
325
    CreateShortCut "$DESKTOP\Gcompris Admin.lnk" "$INSTDIR\gcompris.exe" `-a` "$INSTDIR\gcompris.exe" 1
 
326
    SetOutPath "$INSTDIR"
 
327
 
 
328
    ; If we don't have install rights.. we're done
 
329
    StrCmp $R0 "NONE" done
 
330
    CreateShortCut "$SMPROGRAMS\Gcompris\Uninstall.lnk" "$INSTDIR\${GCOMPRIS_UNINST_EXE}"
 
331
    SetOverwrite off
 
332
 
 
333
    ; Write out installer language
 
334
    WriteRegStr HKCU "${GCOMPRIS_REG_KEY}" "${GCOMPRIS_REG_LANG}" "$LANGUAGE"
 
335
 
 
336
    ; write out uninstaller
 
337
    SetOverwrite on
 
338
    WriteUninstaller "$INSTDIR\${GCOMPRIS_UNINST_EXE}"
 
339
    SetOverwrite off
 
340
 
 
341
    ; If we previously had gcompris setup to run on startup, make it do so again
 
342
    StrCmp $STARTUP_RUN_KEY "HKCU" +1 +2
 
343
    WriteRegStr HKCU "${GCOMPRIS_STARTUP_RUN_KEY}" "Gcompris" "$INSTDIR\gcompris.exe"
 
344
    StrCmp $STARTUP_RUN_KEY "HKLM" +1 +2
 
345
    WriteRegStr HKLM "${GCOMPRIS_STARTUP_RUN_KEY}" "Gcompris" "$INSTDIR\gcompris.exe"
 
346
 
 
347
  done:
 
348
SectionEnd ; end of default Gcompris section
 
349
 
 
350
;--------------------------------
 
351
;Uninstaller Section
 
352
 
 
353
 
 
354
Section Uninstall
 
355
  Call un.CheckUserInstallRights
 
356
  Pop $R0
 
357
  StrCmp $R0 "NONE" no_rights
 
358
  StrCmp $R0 "HKCU" try_hkcu try_hklm
 
359
 
 
360
  try_hkcu:
 
361
    ReadRegStr $R0 HKCU ${GCOMPRIS_REG_KEY} ""
 
362
    StrCmp $R0 $INSTDIR 0 cant_uninstall
 
363
      ; HKCU install path matches our INSTDIR.. so uninstall
 
364
      DeleteRegKey HKCU ${GCOMPRIS_REG_KEY}
 
365
      DeleteRegKey HKCU "${GCOMPRIS_UNINSTALL_KEY}"
 
366
      Goto cont_uninstall
 
367
 
 
368
  try_hklm:
 
369
    ReadRegStr $R0 HKLM ${GCOMPRIS_REG_KEY} ""
 
370
    StrCmp $R0 $INSTDIR 0 try_hkcu
 
371
      ; HKLM install path matches our INSTDIR.. so uninstall
 
372
      DeleteRegKey HKLM ${GCOMPRIS_REG_KEY}
 
373
      DeleteRegKey HKLM "${GCOMPRIS_UNINSTALL_KEY}"
 
374
      DeleteRegKey HKLM "${HKLM_APP_PATHS_KEY}"
 
375
      ; Sets start menu and desktop scope to all users..
 
376
      SetShellVarContext "all"
 
377
 
 
378
  cont_uninstall:
 
379
    ; The WinPrefs plugin may have left this behind..
 
380
    DeleteRegValue HKCU "${GCOMPRIS_STARTUP_RUN_KEY}" "Gcompris"
 
381
    DeleteRegValue HKLM "${GCOMPRIS_STARTUP_RUN_KEY}" "Gcompris"
 
382
    ; Remove Language preference info
 
383
    DeleteRegKey HKCU ${GCOMPRIS_REG_KEY} ;${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
 
384
 
 
385
    RMDir /r "$INSTDIR\etc"
 
386
    RMDir /r "$INSTDIR\GTK"
 
387
    RMDir /r "$INSTDIR\lib"
 
388
    RMDir /r "$INSTDIR\share"
 
389
    Delete "$INSTDIR\gcompris.exe"
 
390
    Delete "$INSTDIR\${GCOMPRIS_UNINST_EXE}"
 
391
    Delete "$INSTDIR\COPYING"
 
392
    Delete "$INSTDIR\Changelog"
 
393
    Delete "$INSTDIR\README"
 
394
    Delete "$INSTDIR\SDL.dll"
 
395
    Delete "$INSTDIR\SDL_mixer.dll"
 
396
    Delete "$INSTDIR\_cairo.pyd"
 
397
    Delete "$INSTDIR\_gtk.pyd"
 
398
    Delete "$INSTDIR\_socket.pyd"
 
399
    Delete "$INSTDIR\_ssl.pyd"
 
400
    Delete "$INSTDIR\_sqlite.pyd"
 
401
    Delete "$INSTDIR\_tkinter.pyd"
 
402
    Delete "$INSTDIR\atk.pyd"
 
403
    Delete "$INSTDIR\bz2.pyd"
 
404
    Delete "$INSTDIR\freetype6.dll"
 
405
    Delete "$INSTDIR\gnucap.exe"
 
406
    Delete "$INSTDIR\gnuchess.exe"
 
407
    Delete "$INSTDIR\gobject.pyd"
 
408
    Delete "$INSTDIR\gspawn-win32-helper.exe"
 
409
    Delete "$INSTDIR\iconv.dll"
 
410
    Delete "$INSTDIR\intl.dll"
 
411
    Delete "$INSTDIR\jpeg62.dll"
 
412
    Delete "$INSTDIR\libart_lgpl_2-2.dll"
 
413
    Delete "$INSTDIR\libatk-1.0-0.dll"
 
414
    Delete "$INSTDIR\libcairo-2.dll"
 
415
    Delete "$INSTDIR\libfontconfig-1.dll"
 
416
    Delete "$INSTDIR\libgdk-win32-2.0-0.dll"
 
417
    Delete "$INSTDIR\libgdk_pixbuf-2.0-0.dll"
 
418
    Delete "$INSTDIR\libglib-2.0-0.dll"
 
419
    Delete "$INSTDIR\libgmodule-2.0-0.dll"
 
420
    Delete "$INSTDIR\libgnomecanvas-2-0.dll"
 
421
    Delete "$INSTDIR\libgobject-2.0-0.dll"
 
422
    Delete "$INSTDIR\libgthread-2.0-0.dll"
 
423
    Delete "$INSTDIR\libgtk-win32-2.0-0.dll"
 
424
    Delete "$INSTDIR\libiconv-2.dll"
 
425
    Delete "$INSTDIR\libintl-2.dll"
 
426
    Delete "$INSTDIR\libpango-1.0-0.dll"
 
427
    Delete "$INSTDIR\libpangocairo-1.0-0.dll"
 
428
    Delete "$INSTDIR\libpangoft2-1.0-0.dll"
 
429
    Delete "$INSTDIR\libpangowin32-1.0-0.dll"
 
430
    Delete "$INSTDIR\libpng13.dll"
 
431
    Delete "$INSTDIR\libreadline.dll"
 
432
    Delete "$INSTDIR\libxml2.dll"
 
433
    Delete "$INSTDIR\msvcr71.dll"
 
434
    Delete "$INSTDIR\pango.pyd"
 
435
    Delete "$INSTDIR\pangocairo.pyd"
 
436
    Delete "$INSTDIR\pthreadGC.dll"
 
437
    Delete "$INSTDIR\python24.dll"
 
438
    Delete "$INSTDIR\python24.zip"
 
439
    Delete "$INSTDIR\select.pyd"
 
440
    Delete "$INSTDIR\setup.py"
 
441
    Delete "$INSTDIR\sqlite3.dll"
 
442
    Delete "$INSTDIR\unicodedata.pyd"
 
443
    Delete "$INSTDIR\xmlparse.dll"
 
444
    Delete "$INSTDIR\xmltok.dll"
 
445
    Delete "$INSTDIR\zlib.pyd"
 
446
    Delete "$INSTDIR\zlib1.dll"
 
447
    Delete "$INSTDIR\README.mingw"
 
448
 
 
449
    ;Try to remove Gcompris install dir .. if empty
 
450
    RMDir "$INSTDIR"
 
451
 
 
452
    ; Shortcuts..
 
453
    RMDir /r "$SMPROGRAMS\Gcompris"
 
454
    Delete "$DESKTOP\Gcompris.lnk"
 
455
    Delete "$DESKTOP\Gcompris Admin.lnk"
 
456
 
 
457
    Goto done
 
458
 
 
459
  cant_uninstall:
 
460
    IfSilent skip_mb
 
461
    MessageBox MB_OK $(un.GCOMPRIS_UNINSTALL_ERROR_1) IDOK
 
462
    skip_mb:
 
463
    Quit
 
464
 
 
465
  no_rights:
 
466
    IfSilent skip_mb1
 
467
    MessageBox MB_OK $(un.GCOMPRIS_UNINSTALL_ERROR_2) IDOK
 
468
    skip_mb1:
 
469
    Quit
 
470
 
 
471
  done:
 
472
SectionEnd ; end of uninstall section
 
473
 
 
474
;--------------------------------
 
475
;Descriptions
 
476
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
 
477
  !insertmacro MUI_DESCRIPTION_TEXT ${SecGcompris} \
 
478
        $(GCOMPRIS_SECTION_DESCRIPTION)
 
479
!insertmacro MUI_FUNCTION_DESCRIPTION_END
 
480
 
 
481
;--------------------------------
 
482
;Functions
 
483
 
 
484
Function CheckUserInstallRights
 
485
        ClearErrors
 
486
        UserInfo::GetName
 
487
        IfErrors Win9x
 
488
        Pop $0
 
489
        UserInfo::GetAccountType
 
490
        Pop $1
 
491
 
 
492
        StrCmp $1 "Admin" 0 +3
 
493
                StrCpy $1 "HKLM"
 
494
                Goto done
 
495
        StrCmp $1 "Power" 0 +3
 
496
                StrCpy $1 "HKLM"
 
497
                Goto done
 
498
        StrCmp $1 "User" 0 +3
 
499
                StrCpy $1 "HKCU"
 
500
                Goto done
 
501
        StrCmp $1 "Guest" 0 +3
 
502
                StrCpy $1 "NONE"
 
503
                Goto done
 
504
        ; Unknown error
 
505
        StrCpy $1 "NONE"
 
506
        Goto done
 
507
 
 
508
        Win9x:
 
509
                StrCpy $1 "HKLM"
 
510
 
 
511
        done:
 
512
        Push $1
 
513
FunctionEnd
 
514
 
 
515
Function un.CheckUserInstallRights
 
516
        ClearErrors
 
517
        UserInfo::GetName
 
518
        IfErrors Win9x
 
519
        Pop $0
 
520
        UserInfo::GetAccountType
 
521
        Pop $1
 
522
 
 
523
        StrCmp $1 "Admin" 0 +3
 
524
                StrCpy $1 "HKLM"
 
525
                Goto done
 
526
        StrCmp $1 "Power" 0 +3
 
527
                StrCpy $1 "HKLM"
 
528
                Goto done
 
529
        StrCmp $1 "User" 0 +3
 
530
                StrCpy $1 "HKCU"
 
531
                Goto done
 
532
        StrCmp $1 "Guest" 0 +3
 
533
                StrCpy $1 "NONE"
 
534
                Goto done
 
535
        ; Unknown error
 
536
        StrCpy $1 "NONE"
 
537
        Goto done
 
538
 
 
539
        Win9x:
 
540
                StrCpy $1 "HKLM"
 
541
 
 
542
        done:
 
543
        Push $1
 
544
FunctionEnd
 
545
 
 
546
;
 
547
; Usage:
 
548
;   Push $0 ; Path string
 
549
;   Call VerifyDir
 
550
;   Pop $0 ; 0 - Bad path  1 - Good path
 
551
;
 
552
Function VerifyDir
 
553
  Pop $0
 
554
  Loop:
 
555
    IfFileExists $0 dir_exists
 
556
    StrCpy $1 $0 ; save last
 
557
    Push $0
 
558
    Call GetParent
 
559
    Pop $0
 
560
    StrLen $2 $0
 
561
    ; IfFileExists "C:" on xp returns true and on win2k returns false
 
562
    ; So we're done in such a case..
 
563
    IntCmp $2 2 loop_done
 
564
    ; GetParent of "C:" returns ""
 
565
    IntCmp $2 0 loop_done
 
566
    Goto Loop
 
567
 
 
568
  loop_done:
 
569
    StrCpy $1 "$0\GcomprisFooB"
 
570
    ; Check if we can create dir on this drive..
 
571
    ClearErrors
 
572
    CreateDirectory $1
 
573
    IfErrors DirBad DirGood
 
574
 
 
575
  dir_exists:
 
576
    ClearErrors
 
577
    FileOpen $1 "$0\gcomprisfoo.bar" w
 
578
    IfErrors PathBad PathGood
 
579
 
 
580
    DirGood:
 
581
      RMDir $1
 
582
      Goto PathGood1
 
583
 
 
584
    DirBad:
 
585
      RMDir $1
 
586
      Goto PathBad1
 
587
 
 
588
    PathBad:
 
589
      FileClose $1
 
590
      Delete "$0\gcomprisfoo.bar"
 
591
      PathBad1:
 
592
      StrCpy $0 "0"
 
593
      Push $0
 
594
      Return
 
595
 
 
596
    PathGood:
 
597
      FileClose $1
 
598
      Delete "$0\gcomprisfoo.bar"
 
599
      PathGood1:
 
600
      StrCpy $0 "1"
 
601
      Push $0
 
602
FunctionEnd
 
603
 
 
604
Function .onVerifyInstDir
 
605
  Push $INSTDIR
 
606
  Call VerifyDir
 
607
  Pop $0
 
608
  StrCmp $0 "0" 0 dir_good
 
609
    Abort
 
610
  dir_good:
 
611
FunctionEnd
 
612
 
 
613
; GetParent
 
614
; input, top of stack  (e.g. C:\Program Files\Poop)
 
615
; output, top of stack (replaces, with e.g. C:\Program Files)
 
616
; modifies no other variables.
 
617
;
 
618
; Usage:
 
619
;   Push "C:\Program Files\Directory\Whatever"
 
620
;   Call GetParent
 
621
;   Pop $R0
 
622
;   ; at this point $R0 will equal "C:\Program Files\Directory"
 
623
Function GetParent
 
624
   Exch $0 ; old $0 is on top of stack
 
625
   Push $1
 
626
   Push $2
 
627
   StrCpy $1 -1
 
628
   loop:
 
629
     StrCpy $2 $0 1 $1
 
630
     StrCmp $2 "" exit
 
631
     StrCmp $2 "\" exit
 
632
     IntOp $1 $1 - 1
 
633
   Goto loop
 
634
   exit:
 
635
     StrCpy $0 $0 $1
 
636
     Pop $2
 
637
     Pop $1
 
638
     Exch $0 ; put $0 on top of stack, restore $0 to original value
 
639
FunctionEnd
 
640
 
 
641
 
 
642
Function RunCheck
 
643
  System::Call 'kernel32::OpenMutex(i 2031617, b 0, t "gcompris_is_running") i .R0'
 
644
  IntCmp $R0 0 done
 
645
  MessageBox MB_OK|MB_ICONEXCLAMATION $(GCOMPRIS_IS_RUNNING) IDOK
 
646
    Abort
 
647
  done:
 
648
FunctionEnd
 
649
 
 
650
Function un.RunCheck
 
651
  System::Call 'kernel32::OpenMutex(i 2031617, b 0, t "gcompris_is_running") i .R0'
 
652
  IntCmp $R0 0 done
 
653
  MessageBox MB_OK|MB_ICONEXCLAMATION $(GCOMPRIS_IS_RUNNING) IDOK
 
654
    Abort
 
655
  done:
 
656
FunctionEnd
 
657
 
 
658
Function .onInit
 
659
  System::Call 'kernel32::CreateMutexA(i 0, i 0, t "gcompris_installer_running") i .r1 ?e'
 
660
  Pop $R0
 
661
  StrCmp $R0 0 +3
 
662
    MessageBox MB_OK|MB_ICONEXCLAMATION $(INSTALLER_IS_RUNNING)
 
663
    Abort
 
664
  Call RunCheck
 
665
  StrCpy $name "Gcompris ${GCOMPRIS_VERSION}"
 
666
  StrCpy $ISSILENT "/NOUI"
 
667
 
 
668
  ; GTK installer has two silent states.. one with Message boxes, one without
 
669
  ; If gcompris installer was run silently, we want to supress gtk installer msg boxes.
 
670
  IfSilent 0 set_gtk_normal
 
671
      StrCpy $ISSILENT "/S"
 
672
  set_gtk_normal:
 
673
 
 
674
  Call ParseParameters
 
675
 
 
676
  ; Select Language
 
677
  IntCmp $LANG_IS_SET 1 skip_lang
 
678
    ; Display Language selection dialog
 
679
    !insertmacro MUI_LANGDLL_DISPLAY
 
680
    skip_lang:
 
681
 
 
682
  ; If install path was set on the command, use it.
 
683
  StrCmp $INSTDIR "" 0 instdir_done
 
684
 
 
685
  ;  If gcompris is currently intalled, we should default to where it is currently installed
 
686
  ClearErrors
 
687
  ReadRegStr $INSTDIR HKCU "${GCOMPRIS_REG_KEY}" ""
 
688
  IfErrors +2
 
689
  StrCmp $INSTDIR "" 0 instdir_done
 
690
  ReadRegStr $INSTDIR HKLM "${GCOMPRIS_REG_KEY}" ""
 
691
  IfErrors +2
 
692
  StrCmp $INSTDIR "" 0 instdir_done
 
693
 
 
694
  Call CheckUserInstallRights
 
695
  Pop $0
 
696
 
 
697
  StrCmp $0 "HKLM" 0 user_dir
 
698
    StrCpy $INSTDIR "$PROGRAMFILES\Gcompris"
 
699
    Goto instdir_done
 
700
  user_dir:
 
701
    StrCpy $2 "$SMPROGRAMS"
 
702
    Push $2
 
703
    Call GetParent
 
704
    Call GetParent
 
705
    Pop $2
 
706
    StrCpy $INSTDIR "$2\Gcompris"
 
707
 
 
708
  instdir_done:
 
709
 
 
710
FunctionEnd
 
711
 
 
712
Function un.onInit
 
713
  Call un.RunCheck
 
714
  StrCpy $name "Gcompris ${GCOMPRIS_VERSION}"
 
715
 
 
716
  ; Get stored language prefrence
 
717
  ReadRegStr $LANGUAGE HKCU ${GCOMPRIS_REG_KEY} "${GCOMPRIS_REG_LANG}"
 
718
 
 
719
FunctionEnd
 
720
 
 
721
 
 
722
; GetParameters
 
723
; input, none
 
724
; output, top of stack (replaces, with e.g. whatever)
 
725
; modifies no other variables.
 
726
 
 
727
Function GetParameters
 
728
 
 
729
   Push $R0
 
730
   Push $R1
 
731
   Push $R2
 
732
   Push $R3
 
733
 
 
734
   StrCpy $R2 1
 
735
   StrLen $R3 $CMDLINE
 
736
 
 
737
   ;Check for quote or space
 
738
   StrCpy $R0 $CMDLINE $R2
 
739
   StrCmp $R0 '"' 0 +3
 
740
     StrCpy $R1 '"'
 
741
     Goto loop
 
742
   StrCpy $R1 " "
 
743
 
 
744
   loop:
 
745
     IntOp $R2 $R2 + 1
 
746
     StrCpy $R0 $CMDLINE 1 $R2
 
747
     StrCmp $R0 $R1 get
 
748
     StrCmp $R2 $R3 get
 
749
     Goto loop
 
750
 
 
751
   get:
 
752
     IntOp $R2 $R2 + 1
 
753
     StrCpy $R0 $CMDLINE 1 $R2
 
754
     StrCmp $R0 " " get
 
755
     StrCpy $R0 $CMDLINE "" $R2
 
756
 
 
757
   Pop $R3
 
758
   Pop $R2
 
759
   Pop $R1
 
760
   Exch $R0
 
761
 
 
762
FunctionEnd
 
763
 
 
764
 ; StrStr
 
765
 ; input, top of stack = string to search for
 
766
 ;        top of stack-1 = string to search in
 
767
 ; output, top of stack (replaces with the portion of the string remaining)
 
768
 ; modifies no other variables.
 
769
 ;
 
770
 ; Usage:
 
771
 ;   Push "this is a long ass string"
 
772
 ;   Push "ass"
 
773
 ;   Call StrStr
 
774
 ;   Pop $R0
 
775
 ;  ($R0 at this point is "ass string")
 
776
 
 
777
Function StrStr
 
778
   Exch $R1 ; st=haystack,old$R1, $R1=needle
 
779
   Exch    ; st=old$R1,haystack
 
780
   Exch $R2 ; st=old$R1,old$R2, $R2=haystack
 
781
   Push $R3
 
782
   Push $R4
 
783
   Push $R5
 
784
   StrLen $R3 $R1
 
785
   StrCpy $R4 0
 
786
   ; $R1=needle
 
787
   ; $R2=haystack
 
788
   ; $R3=len(needle)
 
789
   ; $R4=cnt
 
790
   ; $R5=tmp
 
791
   loop:
 
792
     StrCpy $R5 $R2 $R3 $R4
 
793
     StrCmp $R5 $R1 done
 
794
     StrCmp $R5 "" done
 
795
     IntOp $R4 $R4 + 1
 
796
     Goto loop
 
797
   done:
 
798
   StrCpy $R1 $R2 "" $R4
 
799
   Pop $R5
 
800
   Pop $R4
 
801
   Pop $R3
 
802
   Pop $R2
 
803
   Exch $R1
 
804
FunctionEnd
 
805
 
 
806
;
 
807
; Parse the Command line
 
808
;
 
809
; Unattended install command line parameters
 
810
; /L=Language e.g.: /L=1033
 
811
;
 
812
Function ParseParameters
 
813
  IntOp $LANG_IS_SET 0 + 0
 
814
  Call GetParameters
 
815
  Pop $R0
 
816
  Push $R0
 
817
  Push "L="
 
818
  Call StrStr
 
819
  Pop $R1
 
820
  StrCmp $R1 "" next
 
821
  StrCpy $R1 $R1 4 2 ; Strip first 2 chars of string
 
822
  StrCpy $LANGUAGE $R1
 
823
  IntOp $LANG_IS_SET 0 + 1
 
824
  next:
 
825
FunctionEnd
 
826
 
 
827
; GetWindowsVersion
 
828
;
 
829
; Based on Yazno's function, http://yazno.tripod.com/powerpimpit/
 
830
; Updated by Joost Verburg
 
831
;
 
832
; Returns on top of stack
 
833
;
 
834
; Windows Version (95, 98, ME, NT x.x, 2000, XP, 2003)
 
835
; or
 
836
; '' (Unknown Windows Version)
 
837
;
 
838
; Usage:
 
839
;   Call GetWindowsVersion
 
840
;   Pop $R0
 
841
;
 
842
; at this point $R0 is "NT 4.0" or whatnot
 
843
Function GetWindowsVersion
 
844
 
 
845
  Push $R0
 
846
  Push $R1
 
847
 
 
848
  ReadRegStr $R0 HKLM \
 
849
  "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
 
850
 
 
851
  IfErrors 0 lbl_winnt
 
852
 
 
853
  ; we are not NT
 
854
  ReadRegStr $R0 HKLM \
 
855
  "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber
 
856
 
 
857
  StrCpy $R1 $R0 1
 
858
  StrCmp $R1 '4' 0 lbl_error
 
859
 
 
860
  StrCpy $R1 $R0 3
 
861
 
 
862
  StrCmp $R1 '4.0' lbl_win32_95
 
863
  StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98
 
864
 
 
865
  lbl_win32_95:
 
866
    StrCpy $R0 '95'
 
867
  Goto lbl_done
 
868
 
 
869
  lbl_win32_98:
 
870
    StrCpy $R0 '98'
 
871
  Goto lbl_done
 
872
 
 
873
  lbl_win32_ME:
 
874
    StrCpy $R0 'ME'
 
875
  Goto lbl_done
 
876
 
 
877
  lbl_winnt:
 
878
    StrCpy $R1 $R0 1
 
879
 
 
880
    StrCmp $R1 '3' lbl_winnt_x
 
881
    StrCmp $R1 '4' lbl_winnt_x
 
882
 
 
883
    StrCpy $R1 $R0 3
 
884
 
 
885
    StrCmp $R1 '5.0' lbl_winnt_2000
 
886
    StrCmp $R1 '5.1' lbl_winnt_XP
 
887
    StrCmp $R1 '5.2' lbl_winnt_2003 lbl_error
 
888
 
 
889
  lbl_winnt_x:
 
890
    StrCpy $R0 "NT $R0" 6
 
891
  Goto lbl_done
 
892
 
 
893
  lbl_winnt_2000:
 
894
    Strcpy $R0 '2000'
 
895
  Goto lbl_done
 
896
 
 
897
  lbl_winnt_XP:
 
898
    Strcpy $R0 'XP'
 
899
  Goto lbl_done
 
900
 
 
901
  lbl_winnt_2003:
 
902
    Strcpy $R0 '2003'
 
903
  Goto lbl_done
 
904
 
 
905
  lbl_error:
 
906
    Strcpy $R0 ''
 
907
  lbl_done:
 
908
 
 
909
  Pop $R1
 
910
  Exch $R0
 
911
FunctionEnd
 
912