~ubuntu-branches/ubuntu/trusty/gramps/trusty-proposed

« back to all changes in this revision

Viewing changes to windows/nsis/gramps.nsi

  • Committer: Package Import Robot
  • Author(s): Ross Gammon
  • Date: 2014-02-03 17:28:04 UTC
  • mfrom: (39.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20140203172804-76y7nwxiw92zhlnj
Tags: 4.0.3+dfsg-1
* New upstream release (Closes: #720858)
* To-do notes improved and made persistent (Closes: #680692)
* Applied patch to setup.py to fix resource path problem
* Applied patch to disable the optional HTML View & prevent a crash
* Remove sourceless javascript files (Closes: #736436)
* Gramps uses Bat Mitzva internally (Closes: #502532)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Gramps - a GTK+ based genealogy program
 
3
#
 
4
# Copyright (C) 2006-2008 Steve Hall <digitect dancingpaper com>
 
5
# Copyright (C) 2008 Stephen George
 
6
#
 
7
# This program is free software; you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free Software Foundation; either version 2 of the License, or
 
10
# (at your option) any later version.
 
11
#
 
12
# This program is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
# GNU General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with this program; if not, write to the Free Software
 
19
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
20
#
 
21
# $Id$
 
22
#
 
23
# Description: Nullsoft Installer (NSIS) file to build Windows installer:
 
24
#
 
25
# Requires:    NSIS version 2.0 or later.
 
26
# Notes:
 
27
# o WARNING: if you make changes to this script, look out for $INSTDIR
 
28
#   to be valid, because this line is very dangerous:  RMDir /r $INSTDIR
 
29
# o WARNING: Except the uninstaller. That re-paths for some reason.
 
30
#
 
31
 
 
32
# ToDo {{{1
 
33
#
 
34
# o More refined dependency checking (versioning)
 
35
# o Add .gramps and .gpkg as extensions
 
36
#   * => Need separate icons for them?
 
37
#
 
38
# 1}}}
 
39
#               Installer Attributes
 
40
# 0. Base Settings {{{1
 
41
 
 
42
# version numbers
 
43
!define GRAMPS_VER_MAJOR $%VERSION%
 
44
!define GRAMPS_VER_MINOR $%VERSIONSUB%
 
45
!define GRAMPS_VER_POINT $%VERSIONPT%
 
46
!define GRAMPS_VER_BUILD $%VERSIONBUILD%
 
47
 
 
48
; HM NIS Edit Wizard helper defines
 
49
!define PRODUCT_NAME "GRAMPS"
 
50
!define PRODUCT_VERSION ${GRAMPS_VER_MAJOR}.${GRAMPS_VER_MINOR}.${GRAMPS_VER_POINT}-${GRAMPS_VER_BUILD}
 
51
!define PRODUCT_PUBLISHER "The GRAMPS project"
 
52
!define PRODUCT_WEB_SITE "http://gramps-project.org"
 
53
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
 
54
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
 
55
 
 
56
!define DESKTOP_LINK "$DESKTOP\${PRODUCT_NAME} ${PRODUCT_VERSION}.lnk"
 
57
 
 
58
# adds Native Language Support
 
59
!define HAVE_NLS
 
60
 
 
61
# output file
 
62
Name ${PRODUCT_NAME}
 
63
OutFile gramps-${PRODUCT_VERSION}.exe
 
64
 
 
65
# self ensure we don't have a corrupted file
 
66
CRCCheck on
 
67
 
 
68
# compression
 
69
SetCompress auto
 
70
# zlib good, bzip2 better, lzma best (and slowest, whew.)
 
71
SetCompressor lzma
 
72
# reference existing store if possible
 
73
SetDatablockOptimize on
 
74
# UPX
 
75
# comment next line if you don't have UPX (http://upx.sourceforge.net)
 
76
!packhdr temp.dat "upx --best --compress-icons=0 temp.dat"
 
77
 
 
78
SetOverwrite try
 
79
 
 
80
# don't allow installation into C:\ directory
 
81
AllowRootDirInstall false
 
82
 
 
83
# install details color scheme
 
84
InstallColors /windows
 
85
# background
 
86
BGGradient off
 
87
 
 
88
# adds an XP manifest
 
89
XPStyle on
 
90
 
 
91
# default install path
 
92
InstallDir $PROGRAMFILES\gramps
 
93
 
 
94
# Remember install folder
 
95
InstallDirRegKey HKCU "Software\${PRODUCT_NAME}" ""
 
96
 
 
97
# Remember the installer language
 
98
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
 
99
!define MUI_LANGDLL_REGISTRY_KEY "Software\${PRODUCT_NAME}"
 
100
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
 
101
 
 
102
# types of installs we can perform
 
103
InstType Typical
 
104
InstType Minimal
 
105
InstType Full
 
106
 
 
107
SilentInstall normal
 
108
 
 
109
# 1. Header file (Begin Modern User Interface)  {{{1
 
110
!include "MUI.nsh"
 
111
 
 
112
# 2. Interface Configuration {{{1
 
113
 
 
114
# installer/uninstaller icons (these must match in size!)
 
115
#!define MUI_ICON "classic-install.ico"
 
116
#!define MUI_UNICON "classic-uninstall.ico"
 
117
 
 
118
# splash, header graphics (same for both!)
 
119
!define MUI_HEADERIMAGE
 
120
#!define MUI_HEADERIMAGE_BITMAP "win.bmp"
 
121
#!define MUI_WELCOMEFINISHPAGE_BITMAP "nsis-splash.bmp"
 
122
 
 
123
!define MUI_LICENSEPAGE_BUTTON $(^AgreeBtn)
 
124
!define MUI_LICENSEPAGE_RADIOBUTTONS
 
125
!define MUI_LICENSEPAGE_RADIOBUTTONS_TEXT_ACCEPT $(^AcceptBtn)
 
126
!define MUI_LICENSEPAGE_RADIOBUTTONS_TEXT_DECLINE $(^DontAcceptBtn)
 
127
 
 
128
#!define MUI_COMPONENTSPAGE_CHECKBITMAP "nsis-checkboxes.bmp"
 
129
# use small description box below components (not adjacent)
 
130
!define MUI_COMPONENTSPAGE_SMALLDESC
 
131
 
 
132
!define MUI_DIRECTORYPAGE_TEXT_TOP $(^DirText)
 
133
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION $(^DirBrowseText)
 
134
!define MUI_DIRECTORYPAGE_VERIFYONLEAVE
 
135
 
 
136
!define MUI_FINISHPAGE_RUN "$3"
 
137
!define MUI_FINISHPAGE_RUN_PARAMETERS "$\"$INSTDIR\gramps.py$\""
 
138
 
 
139
!define MUI_ABORTWARNING
 
140
 
 
141
# 3. Pages {{{1
 
142
 
 
143
!insertmacro MUI_PAGE_WELCOME
 
144
 
 
145
!insertmacro MUI_PAGE_LICENSE "..\COPYING"
 
146
 
 
147
!insertmacro MUI_PAGE_COMPONENTS
 
148
!insertmacro MUI_PAGE_DIRECTORY
 
149
!insertmacro MUI_PAGE_INSTFILES
 
150
!insertmacro MUI_PAGE_FINISH
 
151
 
 
152
 
 
153
# Uninstaller
 
154
 
 
155
!insertmacro MUI_UNPAGE_CONFIRM
 
156
!insertmacro MUI_UNPAGE_INSTFILES
 
157
 
 
158
# 4. Custom functions {{{1
 
159
 
 
160
# 5. Language files {{{1
 
161
# Languages
 
162
# TODO: These are pretty badly broken at the moment.
 
163
# Note: This appears to be due to building on Win95 which does not
 
164
#       support Unicode:
 
165
#       (http://nsis.sf.net/archive/nsisweb.php?page=247&instances=0,235)
 
166
#
 
167
#   So what happens if we use only ASCII?
 
168
#
 
169
#!insertmacro MUI_LANGUAGE "Arabic"
 
170
#!insertmacro MUI_LANGUAGE "Bulgarian"
 
171
#!insertmacro MUI_LANGUAGE "Catalan"
 
172
#!insertmacro MUI_LANGUAGE "Croatian"
 
173
#!insertmacro MUI_LANGUAGE "Czech"
 
174
#!insertmacro MUI_LANGUAGE "Default"
 
175
#!insertmacro MUI_LANGUAGE "Estonian"
 
176
#!insertmacro MUI_LANGUAGE "Farsi"
 
177
#!insertmacro MUI_LANGUAGE "Finnish"
 
178
#!insertmacro MUI_LANGUAGE "Greek"
 
179
#!insertmacro MUI_LANGUAGE "Hebrew"
 
180
#!insertmacro MUI_LANGUAGE "Hungarian"
 
181
#!insertmacro MUI_LANGUAGE "Indonesian"
 
182
#!insertmacro MUI_LANGUAGE "Japanese"
 
183
#!insertmacro MUI_LANGUAGE "Korean"
 
184
#!insertmacro MUI_LANGUAGE "Latvian"
 
185
#!insertmacro MUI_LANGUAGE "Lithuanian"
 
186
#!insertmacro MUI_LANGUAGE "Macedonian"
 
187
#!insertmacro MUI_LANGUAGE "Norwegian"
 
188
#!insertmacro MUI_LANGUAGE "Polish"
 
189
#!insertmacro MUI_LANGUAGE "Romanian"
 
190
#!insertmacro MUI_LANGUAGE "Russian"
 
191
#!insertmacro MUI_LANGUAGE "Serbian"
 
192
#!insertmacro MUI_LANGUAGE "SerbianLatin"
 
193
#!insertmacro MUI_LANGUAGE "SimpChinese"
 
194
#!insertmacro MUI_LANGUAGE "Slovak"
 
195
#!insertmacro MUI_LANGUAGE "Slovenian"
 
196
#!insertmacro MUI_LANGUAGE "Swedish"
 
197
#!insertmacro MUI_LANGUAGE "Thai"
 
198
#!insertmacro MUI_LANGUAGE "TradChinese"
 
199
#!insertmacro MUI_LANGUAGE "Turkish"
 
200
#!insertmacro MUI_LANGUAGE "Ukrainian"
 
201
 
 
202
!insertmacro MUI_LANGUAGE "Danish"
 
203
!insertmacro MUI_LANGUAGE "Dutch"
 
204
!insertmacro MUI_LANGUAGE "English"
 
205
!insertmacro MUI_LANGUAGE "French"
 
206
!insertmacro MUI_LANGUAGE "German"
 
207
!insertmacro MUI_LANGUAGE "Italian"
 
208
!insertmacro MUI_LANGUAGE "Portuguese"
 
209
!insertmacro MUI_LANGUAGE "PortugueseBR"
 
210
!insertmacro MUI_LANGUAGE "Spanish"
 
211
 
 
212
# 6. Reserve Files  {{{1
 
213
 
 
214
# 1}}}
 
215
#               7a. Sections
 
216
#    Program Files {{{1
 
217
######################################################################
 
218
 
 
219
Section "Program files (required)" Main
 
220
SectionIn 1 2 3 RO
 
221
 
 
222
    Call WarnDirExists
 
223
 
 
224
    SetOutPath $INSTDIR
 
225
    File /r ..\src\*.*
 
226
    File ..\COPYING
 
227
    File ..\NEWS
 
228
    File ..\FAQ
 
229
    File ..\AUTHORS
 
230
    #File /r ..\nsis\gramps.ico
 
231
    WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "" "$INSTDIR"
 
232
    WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "version" ${PRODUCT_VERSION}
 
233
 
 
234
SectionEnd
 
235
 
 
236
#    Menus and shortcuts {{{1
 
237
 
 
238
SubSection "Menus and shortcuts" MenusAndIcons
 
239
 
 
240
Section "Add GRAMPS to the Start Menu" MenuStart
 
241
SectionIn 1 3
 
242
    # determines "Start In" location for shortcuts
 
243
    SetOutPath $INSTDIR
 
244
 
 
245
    StrCpy $0 "GRAMPS"
 
246
 
 
247
    IfFileExists "$SMPROGRAMS\$0" 0 skipStartMenuRemove
 
248
    RMDir /r "$SMPROGRAMS\$0\"
 
249
    skipStartMenuRemove:
 
250
 
 
251
    CreateDirectory "$SMPROGRAMS\$0\"
 
252
    CreateShortCut "$SMPROGRAMS\$0\GRAMPS ${PRODUCT_VERSION}.lnk" "$3" "$\"$INSTDIR\gramps.py$\"" "$INSTDIR\images\ped24.ico" "0" "" "" "GRAMPS"
 
253
    WriteINIStr "$SMPROGRAMS\$0\GRAMPS Website.url" "InternetShortcut" "URL" "http://www.gramps-project.org/"
 
254
    CreateShortCut "$SMPROGRAMS\$0\Uninstall GRAMPS.lnk" "$\"$INSTDIR\uninstall.exe$\"" "" "" "0" "" "" "Uninstall GRAMPS"
 
255
 
 
256
SectionEnd
 
257
 
 
258
Section "Add Desktop icon" Desktop
 
259
#SectionIn 1 3
 
260
# determines "Start In" location for shortcuts
 
261
SetOutPath $INSTDIR
 
262
CreateShortCut "${DESKTOP_LINK}" "$3" "$\"$INSTDIR\gramps.py$\"" "$INSTDIR\images\ped24.ico" "0" "" "" "GRAMPS"
 
263
SectionEnd
 
264
 
 
265
SubSectionEnd
 
266
 
 
267
#    Language Files {{{1
 
268
 
 
269
Section "Language Files" LangFiles
 
270
# off by default
 
271
#SectionIn 1 3
 
272
 
 
273
    #CreateDirectory $INSTDIR\lang
 
274
    SetOutPath $INSTDIR
 
275
    File /r ..\po\*.mo
 
276
 
 
277
    #MessageBox MB_OK "Setting up languages..."
 
278
    # setup
 
279
    ; switches:
 
280
    ; -c
 
281
    ; -t :: setup the language files
 
282
    ; -r
 
283
    ;
 
284
    ; pythonw grampsSetup.py -c -t
 
285
    #Exec '"$3" $\"$INSTDIR\grampsSetup.py -c -t -r$\"'
 
286
 
 
287
SectionEnd
 
288
 
 
289
#    File Association {{{1
 
290
 
 
291
#    FileAssoc.nsh macro {{{2
 
292
;
 
293
; FileAssoc.nsh (http://nsis.sourceforge.net/FileAssoc)
 
294
; File association helper macros
 
295
; Written by Saivert
 
296
;
 
297
; Features automatic backup system and UPDATEFILEASSOC macro for
 
298
; shell change notification.
 
299
;
 
300
; |> How to use <|
 
301
; To associate a file with an application so you can double-click it in explorer, use
 
302
; the APP_ASSOCIATE macro like this:
 
303
;
 
304
;   Example:
 
305
;   !insertmacro APP_ASSOCIATE \
 
306
;      "txt" \
 
307
;      "myapp.textfile" \
 
308
;      "myapp tiny description" \
 
309
;     "$INSTDIR\myapp.exe,0" \
 
310
;     "Open with myapp" \
 
311
;     "$INSTDIR\myapp.exe $\"%1$\""
 
312
;
 
313
; Never insert the APP_ASSOCIATE macro multiple times, it is only ment
 
314
; to associate an application with a single file and using the
 
315
; the "open" verb as default. To add more verbs (actions) to a file
 
316
; use the APP_ASSOCIATE_ADDVERB macro.
 
317
;
 
318
;   Example:
 
319
;   !insertmacro APP_ASSOCIATE_ADDVERB "myapp.textfile" "edit" "Edit with myapp" \
 
320
;     "$INSTDIR\myapp.exe /edit $\"%1$\""
 
321
;
 
322
; To have access to more options when registering the file association use the
 
323
; APP_ASSOCIATE_EX macro. Here you can specify the verb and what verb is to be the
 
324
; standard action (default verb).
 
325
;
 
326
; And finally: To remove the association from the registry use the APP_UNASSOCIATE
 
327
; macro. Here is another example just to wrap it up:
 
328
;   !insertmacro APP_UNASSOCIATE "txt" "myapp.textfile"
 
329
;
 
330
; |> Note <|
 
331
; When defining your file class string always use the short form of your application title
 
332
; then a period (dot) and the type of file. This keeps the file class sort of unique.
 
333
;   Examples:
 
334
;   Winamp.Playlist
 
335
;   NSIS.Script
 
336
;   Photoshop.JPEGFile
 
337
;
 
338
; |> Tech info <|
 
339
; The registry key layout for a file association is:
 
340
; HKEY_CLASSES_ROOT
 
341
;     <applicationID> = <"description">
 
342
;         shell
 
343
;             <verb> = <"menu-item text">
 
344
;                 command = <"command string">
 
345
;
 
346
 
 
347
!macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION ICON COMMANDTEXT COMMAND
 
348
    ; Backup the previously associated file class
 
349
    ReadRegStr $R0 HKCR ".${EXT}" ""
 
350
    WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0"
 
351
 
 
352
    WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}"
 
353
    WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}`
 
354
    WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}`
 
355
    WriteRegStr HKCR "${FILECLASS}\shell" "" "open"
 
356
    WriteRegStr HKCR "${FILECLASS}\shell\open" "" `${COMMANDTEXT}`
 
357
    WriteRegStr HKCR "${FILECLASS}\shell\open\command" "" `${COMMAND}`
 
358
!macroend
 
359
 
 
360
!macro APP_ASSOCIATE_EX EXT FILECLASS DESCRIPTION ICON VERB DEFAULTVERB SHELLNEW COMMANDTEXT COMMAND
 
361
    ; Backup the previously associated file class
 
362
    ReadRegStr $R0 HKCR ".${EXT}" ""
 
363
    WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0"
 
364
 
 
365
    WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}"
 
366
    StrCmp "${SHELLNEW}" "0" +2
 
367
    WriteRegStr HKCR ".${EXT}\ShellNew" "NullFile" ""
 
368
 
 
369
    WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}`
 
370
    WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}`
 
371
    WriteRegStr HKCR "${FILECLASS}\shell" "" `${DEFAULTVERB}`
 
372
    WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}`
 
373
    WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}`
 
374
!macroend
 
375
 
 
376
!macro APP_ASSOCIATE_ADDVERB FILECLASS VERB COMMANDTEXT COMMAND
 
377
    WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}`
 
378
    WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}`
 
379
!macroend
 
380
 
 
381
!macro APP_ASSOCIATE_REMOVEVERB FILECLASS VERB
 
382
    DeleteRegKey HKCR `${FILECLASS}\shell\${VERB}`
 
383
!macroend
 
384
 
 
385
 
 
386
!macro APP_UNASSOCIATE EXT FILECLASS
 
387
    ; Backup the previously associated file class
 
388
    ReadRegStr $R0 HKCR ".${EXT}" `${FILECLASS}_backup`
 
389
    WriteRegStr HKCR ".${EXT}" "" "$R0"
 
390
 
 
391
    DeleteRegKey HKCR `${FILECLASS}`
 
392
!macroend
 
393
 
 
394
!macro APP_ASSOCIATE_GETFILECLASS OUTPUT EXT
 
395
    ReadRegStr ${OUTPUT} HKCR ".${EXT}" ""
 
396
!macroend
 
397
 
 
398
 
 
399
; !defines for use with SHChangeNotify
 
400
!ifdef SHCNE_ASSOCCHANGED
 
401
!undef SHCNE_ASSOCCHANGED
 
402
!endif
 
403
!define SHCNE_ASSOCCHANGED 0x08000000
 
404
!ifdef SHCNF_FLUSH
 
405
!undef SHCNF_FLUSH
 
406
!endif
 
407
!define SHCNF_FLUSH        0x1000
 
408
 
 
409
!macro UPDATEFILEASSOC
 
410
; Using the system.dll plugin to call the SHChangeNotify Win32 API function so we
 
411
; can update the shell.
 
412
    System::Call "shell32::SHChangeNotify(i,i,i,i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_FLUSH}, 0, 0)"
 
413
!macroend
 
414
 
 
415
;EOF
 
416
 
 
417
# 2}}}
 
418
 
 
419
Section "File Association" FileAssoc
 
420
SectionIn 1 3
 
421
# depends on FileAssoc.nsh, by Saivert (http://nsis.sourceforge.net/FileAssoc)
 
422
 
 
423
    # .grdb
 
424
    !insertmacro APP_ASSOCIATE \
 
425
      "grdb" \
 
426
      "application/x-gramps-database" \
 
427
      "GRAMPS database file" \
 
428
     "$INSTDIR\images\ped24.ico" \
 
429
     "Open with GRAMPS" \
 
430
     "$\"$3$\" $\"$INSTDIR\gramps.py$\" $\"%1$\""
 
431
 
 
432
    # .gramps
 
433
    !insertmacro APP_ASSOCIATE \
 
434
      "gramps" \
 
435
      "application/x-gramps-file" \
 
436
      "GRAMPS application file" \
 
437
     "$INSTDIR\images\ped24.ico" \
 
438
     "Open with GRAMPS" \
 
439
     "$\"$3$\" $\"$INSTDIR\gramps.py$\" $\"%1$\""
 
440
 
 
441
    # .gpkg
 
442
    !insertmacro APP_ASSOCIATE \
 
443
      "gpkg" \
 
444
      "application/x-gramps-package" \
 
445
      "GRAMPS package file" \
 
446
     "$INSTDIR\images\ped24.ico" \
 
447
     "Open with GRAMPS" \
 
448
     "$\"$3$\" $\"$INSTDIR\gramps.py$\" $\"%1$\""
 
449
 
 
450
    # .ged
 
451
    !insertmacro APP_ASSOCIATE \
 
452
      "ged" \
 
453
      "application/x-gramps-gedcom" \
 
454
      "GEnealogical Data COMmunication (GEDCOM) file" \
 
455
     "$INSTDIR\images\ped24.ico" \
 
456
     "Open with GRAMPS" \
 
457
     "$\"$3$\" $\"$INSTDIR\gramps.py$\" $\"%1$\""
 
458
 
 
459
SectionEnd
 
460
 
 
461
#    Uninstall {{{1
 
462
######################################################################
 
463
 
 
464
Section Uninstall
 
465
 
 
466
    # ask first
 
467
    MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 \
 
468
        "Completely remove installation? $\n\
 
469
        (Delete folder $INSTDIR ) " \
 
470
        IDNO unQuit IDYES unContinue
 
471
 
 
472
    unQuit:
 
473
    Abort
 
474
 
 
475
    unContinue:
 
476
    ClearErrors
 
477
    RMDir /r $INSTDIR
 
478
    Call un.StartMenu
 
479
    Call un.Desktop
 
480
    DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
 
481
   
 
482
    DeleteRegKey HKLM "SOFTWARE\${PRODUCT_NAME}"   
 
483
 
 
484
    unEnd:
 
485
 
 
486
SectionEnd
 
487
 
 
488
# 1}}}
 
489
#               7b. Functions
 
490
#    Installer {{{1
 
491
#####################################################################
 
492
 
 
493
Function .onInit
 
494
 
 
495
#MessageBox MB_OK "Testing dependencies..."
 
496
 
 
497
    ; look for pythonw.exe
 
498
    ; NOTE: This is set to $3 if it exists.
 
499
 
 
500
    ; on path
 
501
    SearchPath $3 pythonw.exe
 
502
#MessageBox MB_OK "DEBUG: Testing pythonw.exe on path...$\n$\nFound:  $\"$3$\""
 
503
    IfFileExists $3 HavePython 0
 
504
 
 
505
    ; registry keys (these are confirmed possibilities)
 
506
    ; reg key
 
507
    ReadRegStr $3 HKLM 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\python.exe' ""
 
508
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
509
    IfFileExists $3 HavePython 0
 
510
    ; reg key (updated on 2.5 upgrade)
 
511
    ReadRegStr $3 HKCR 'Python.File\shell\open\command' ""
 
512
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
513
    IfFileExists $3 HavePython 0
 
514
    ; reg key (updated on 2.5 upgrade)
 
515
    ReadRegStr $3 HKCU 'Software\Classes\Python.File\shell\open\command' ""
 
516
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
517
    IfFileExists $3 HavePython 0
 
518
    ; reg key
 
519
    ReadRegStr $3 HKCU 'Software\Microsoft\Windows\Current version\App Paths\Python.exe' ""
 
520
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
521
    IfFileExists $3 HavePython 0
 
522
    ; reg key
 
523
    ReadRegStr $3 HKCU 'Software\Microsoft\Windows\ShellNoRoam\MUICache (data:python)' ""
 
524
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
525
    IfFileExists $3 HavePython 0
 
526
    ; reg key (Python version 2.5)
 
527
    ReadRegStr $3 HKCU 'Software\Python\PythonCore\2.5\InstallPath' ""
 
528
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
529
    IfFileExists $3 HavePython 0
 
530
    ; reg key (Python version 2.4)
 
531
    ReadRegStr $3 HKCU 'Software\Python\PythonCore\2.4\InstallPath' ""
 
532
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
533
    IfFileExists $3 HavePython 0
 
534
    # these hold compound paths
 
535
    #; reg key (Python version 2.5)
 
536
    #ReadRegStr $3 HKCU 'Software\Python\PythonCore\2.5\PythonPath' ""
 
537
    #StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
538
    #IfFileExists $3 HavePython 0
 
539
    #; reg key (Python version 2.4)
 
540
    #ReadRegStr $3 HKCU 'Software\Python\PythonCore\2.4\PythonPath' ""
 
541
    #StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
542
    #IfFileExists $3 HavePython 0
 
543
 
 
544
    ; Keys not prone to be properly updated on upgrades
 
545
    ; reg key
 
546
    ReadRegStr $3 HKCR 'Applications\python.exe\shell\open\command' ""
 
547
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
548
    IfFileExists $3 HavePython 0
 
549
    ; reg key (not updated on 2.5 upgrade)
 
550
    ReadRegStr $3 HKLM 'SOFTWARE\Python\PythonCore\2.5\PythonPath' ""
 
551
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
552
    IfFileExists $3 HavePython 0
 
553
    ; reg key
 
554
    ReadRegStr $3 HKLM 'SOFTWARE\Python\PythonCore\2.4\PythonPath' ""
 
555
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
556
    IfFileExists $3 HavePython 0
 
557
    ; reg key
 
558
    ReadRegStr $3 HKLM 'SOFTWARE\Python\PythonCore\2.5' ""
 
559
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
560
    IfFileExists $3 HavePython 0
 
561
    ; reg key
 
562
    ReadRegStr $3 HKLM 'SOFTWARE\Python\PythonCore\2.4' ""
 
563
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
564
    IfFileExists $3 HavePython 0
 
565
    ; reg key
 
566
    ReadRegStr $3 HKLM 'SOFTWARE\Python\PythonCore\2.5\InstallPath' ""
 
567
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
568
    IfFileExists $3 HavePython 0
 
569
    ; reg key
 
570
    ReadRegStr $3 HKLM 'SOFTWARE\Python\PythonCore\2.4\InstallPath' ""
 
571
    StrCpy $3 "$3pythonw.exe"  ; append "pythonw.exe"
 
572
    IfFileExists $3 HavePython 0
 
573
 
 
574
 
 
575
    ; TODO: request path from user/browse (can NSIS do this?)
 
576
        #MessageBox MB_OK "GRAMPS requires Python to be installed, please see:$\n \
 
577
        #  $\n \
 
578
        #  http://gramps-project.org/windows/ $\n \
 
579
        #  $\n \
 
580
        #  for installation help. Unable to continue installation."
 
581
        #Abort
 
582
        MessageBox MB_OK "Python not found."
 
583
        StrCpy $4 "flag"
 
584
        HavePython:
 
585
 
 
586
 
 
587
    ; extract gcheck
 
588
    SetOutPath $TEMP
 
589
 
 
590
    File gcheck.py
 
591
    ; set INI output location ($1)
 
592
    StrCpy $1 "$TEMP\gramps-install.ini"
 
593
 
 
594
    ; run gcheck
 
595
    ExecWait '"$3" $TEMP\gcheck.py $1'
 
596
 
 
597
    ; verify INI created
 
598
    IfFileExists $1 YesINI 0
 
599
        #MessageBox MB_OK "Dependency test INI creation failed, unable to continue."
 
600
        #Abort
 
601
        MessageBox MB_OK "Dependency test INI creation failed."
 
602
        StrCpy $4 "flag"
 
603
        YesINI:
 
604
 
 
605
    ; verify environment test results
 
606
    ; GTK+ and pygtk
 
607
    ReadINIStr $0 $1 tests gtk
 
608
    StrCmp $0 "yes" HaveGTK 0
 
609
 
 
610
        ; TODO: if no, perhaps just have GTK+ installed, check registry
 
611
        ; reg key
 
612
        ReadRegStr $3 HKCU 'Environment\GTK_BASEPATH' ""
 
613
        IfFileExists $3\*.* NoHavePyGTK 0
 
614
        ; reg key
 
615
        ReadRegStr $3 HKCU 'Software\GTK\2.0\Path' ""
 
616
        IfFileExists $3\*.* NoHavePyGTK 0
 
617
        ; reg key
 
618
        ReadRegStr $3 HKLM 'Software\GTK\2.0\Path' ""
 
619
        IfFileExists $3\*.* NoHavePyGTK 0
 
620
        ; reg key
 
621
        ReadRegStr $3 HKLM 'Software\GTK\2.0\DllPath' ""
 
622
        IfFileExists $3\*.* NoHavePyGTK 0
 
623
 
 
624
        ; if we make it this far, we don't have GTK+
 
625
        #MessageBox MB_OK "GRAMPS requires GTK+ and PyGTK to be installed, please see:$\n \
 
626
        #  $\n \
 
627
        #  http://gramps-project.org/windows/ $\n \
 
628
        #  $\n \
 
629
        #  for installation help. Unable to continue installation."
 
630
        #Abort
 
631
        MessageBox MB_OK "GTK+ and PyGTK not found."
 
632
        StrCpy $4 "flag"
 
633
 
 
634
        NoHavePyGTK:
 
635
        #MessageBox MB_OK "PyGTK import failed (GTK+ found on system), please see:$\n \
 
636
        #  $\n \
 
637
        #  http://gramps-project.org/windows/ $\n \
 
638
        #  $\n \
 
639
        #  for installation help. Unable to continue installation."
 
640
        #Abort
 
641
        MessageBox MB_OK "PyGTK not found."
 
642
        StrCpy $4 "flag"
 
643
 
 
644
        HaveGTK:
 
645
 
 
646
    # NOTE: we can not detect just pygtk via gcheck.py
 
647
 
 
648
    ; glade
 
649
    ReadINIStr $0 $1 tests glade
 
650
    StrCmp $0 "yes" Haveglade 0
 
651
        #MessageBox MB_OK "glade not installed, unable to continue."
 
652
        #Abort
 
653
        MessageBox MB_OK "Glade not found."
 
654
        StrCpy $4 "flag"
 
655
        Haveglade:
 
656
    ; pycairo
 
657
    ReadINIStr $0 $1 tests pycairo
 
658
    StrCmp $0 "yes" Havepycairo 0
 
659
        #MessageBox MB_OK "pycairo not installed, unable to continue."
 
660
        #Abort
 
661
        MessageBox MB_OK "pycairo not found."
 
662
        StrCpy $4 "flag"
 
663
        Havepycairo:
 
664
 
 
665
    #!insertmacro MUI_LANGDLL_DISPLAY
 
666
 
 
667
    StrCmp $4 "flag" +1 DependantsOK
 
668
    MessageBox MB_OK "At least one dependency was not found, unable to continue."
 
669
    Abort
 
670
 
 
671
    DependantsOK:
 
672
 
 
673
    Call RemovePrevious
 
674
   
 
675
    # default install directory ($INSTDIR)
 
676
    StrCpy $INSTDIR $PROGRAMFILES\gramps
 
677
 
 
678
FunctionEnd
 
679
 
 
680
Function .onInstSuccess
 
681
 
 
682
    # write uninstaller
 
683
    WriteUninstaller $INSTDIR\uninstall.exe
 
684
    WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
 
685
    WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninstall.exe"
 
686
    WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
 
687
    WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
 
688
    WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
 
689
#Does not display icon on win2000?    WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\images\ped24.ico"
 
690
FunctionEnd
 
691
 
 
692
Function .onInstFailed
 
693
    MessageBox MB_OK|MB_ICONEXCLAMATION "Installation failed."
 
694
FunctionEnd
 
695
 
 
696
Function RemovePrevious
 
697
    #check if gramps exists in registry
 
698
    ClearErrors
 
699
    Var /GLOBAL PreviousPath
 
700
    ReadRegStr $PreviousPath HKLM "SOFTWARE\${PRODUCT_NAME}" ""
 
701
    # do some tests to find an installed version
 
702
    ifErrors NoPreviousVersion
 
703
        IfFileExists $PreviousPath\uninstall.exe 0 NoPreviousVersion #Check uninstall.exe from previous version exists on HD
 
704
        Var /GLOBAL PreviousVersion
 
705
        ReadRegStr $PreviousVersion HKLM "SOFTWARE\${PRODUCT_NAME}" "Version"
 
706
        #  query OK to delete old version
 
707
        MessageBox MB_OKCANCEL|MB_ICONQUESTION|MB_DEFBUTTON2 \
 
708
        "${PRODUCT_NAME} $PreviousVersion is already installed$\n$\nClick 'OK' to uninstall previous version or 'Cancel' to continue anyway" \
 
709
        IDCANCEL NoPreviousVersion
 
710
        #  uninstall old version
 
711
        CopyFiles $PreviousPath\uninstall.exe $TEMP
 
712
        ExecWait '"$TEMP\uninstall.exe" _?=$PreviousPath' $0
 
713
        StrCpy $INSTDIR $PreviousPath #set the previous path as the default install path <= worth while or not?
 
714
        ;DetailPrint "uninstaller set error level $0"
 
715
    NoPreviousVersion:
 
716
FunctionEnd
 
717
 
 
718
Function WarnDirExists
 
719
    # warn if dir already exists
 
720
    IfFileExists $INSTDIR\*.* DirExists DirExistsOK
 
721
    DirExists:
 
722
    MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 \
 
723
        "Install over existing installation?" \
 
724
        IDYES DirExistsOK
 
725
    Quit
 
726
    DirExistsOK:
 
727
FunctionEnd
 
728
 
 
729
#    Uninstaller {{{1
 
730
#####################################################################
 
731
 
 
732
Function un.onUnInstSuccess
 
733
 
 
734
FunctionEnd
 
735
 
 
736
Function un.StartMenu
 
737
 
 
738
    IfFileExists "$SMPROGRAMS\GRAMPS" 0 unStartMenuFine
 
739
    RMDir /r "$SMPROGRAMS\GRAMPS\"
 
740
    unStartMenuFine:
 
741
 
 
742
FunctionEnd
 
743
 
 
744
Function un.Desktop
 
745
 
 
746
    IfFileExists "${DESKTOP_LINK}" 0 unNoDesktop
 
747
    Delete "${DESKTOP_LINK}"
 
748
    unNoDesktop:
 
749
 
 
750
FunctionEnd
 
751
 
 
752
# 1}}}
 
753
# 8. Section Descriptions {{{1
 
754
######################################################################
 
755
# (must be last)
 
756
 
 
757
    LangString DESC_Main ${LANG_ENGLISH} "Main program files (required)."
 
758
    LangString DESC_MenusAndIcons ${LANG_ENGLISH} "General Desktop and Start Menu shortcut options."
 
759
    LangString DESC_Desktop ${LANG_ENGLISH} "Add icon to the Desktop."
 
760
    LangString DESC_MenuStart ${LANG_ENGLISH} "Add icons to the Start Menu."
 
761
    LangString DESC_LangFiles ${LANG_ENGLISH} "Set up non-English languages."
 
762
    LangString DESC_FileAssoc ${LANG_ENGLISH} "Associate GRAMPS with .grdb, .gramps, .gpkg, and .ged files."
 
763
 
 
764
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
 
765
 
 
766
    !insertmacro MUI_DESCRIPTION_TEXT ${Main} $(DESC_Main)
 
767
    !insertmacro MUI_DESCRIPTION_TEXT ${MenusAndIcons} $(DESC_MenusAndIcons)
 
768
    !insertmacro MUI_DESCRIPTION_TEXT ${Desktop} $(DESC_Desktop)
 
769
    !insertmacro MUI_DESCRIPTION_TEXT ${MenuStart} $(DESC_MenuStart)
 
770
    !insertmacro MUI_DESCRIPTION_TEXT ${LangFiles} $(DESC_LangFiles)
 
771
    !insertmacro MUI_DESCRIPTION_TEXT ${FileAssoc} $(DESC_FileAssoc)
 
772
 
 
773
!insertmacro MUI_FUNCTION_DESCRIPTION_END
 
774
 
 
775
# 1}}}
 
776
# vim:foldmethod=marker:noexpandtab