Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6555 dpurdie 1
;------------------------------------------------------------------------------
2
;
3
;   NSIS Installer script file for jats-installer
4
;
5
;------------------------------------------------------------------------------
6
 
7
;------------------------------------------------------------------------------
8
;
9
;   Include Modern UI
10
;   Provides an Installer that is similar to many other Windows-XP installers
11
;
12
;------------------------------------------------------------------------------
13
 
14
!include "MUI2.nsh"
15
!include "WordFunc.nsh"
16
!include "FileFunc.nsh"
17
!include "LogicLib.nsh"
18
;*****************
19
; Include this if you want edit dialogs to ask questions
20
!include "VixPageEditDialogs.nsh"
21
;*****************
22
!include "VixMacros.nsh"
23
 
24
!insertmacro VersionCompare
25
 
26
; Use String Functions
27
;*****************
28
; Include this if you want to use the ${textreplace::ReplaceInFile} macro to replace tags in files
29
!include "TextReplace.nsh"
30
;*****************
31
;!include "StrFunc.nsh"
32
;${StrRep}
33
!include "nsis_path.nsh"
34
 
35
;------------------------------------------------------------------------------
36
;
37
;   Set installer parameters - shown on various dialogs during the installation.
38
;
39
;   The following fields are pre-set by JATS (but can be overriden) :
40
;       Name            Package name and version, shown as package description.
41
;       BrandingText    Company name, shown near the bottom of the file installation dialog.
42
;       Caption         Package name, shown on title bar of all dialogs.
43
;
44
;------------------------------------------------------------------------------
45
 
46
 
47
;------------------------------------------------------------------------------
48
;
49
;   Set installer properties - shown when user hovers over executeable or
50
;   right clicks on 'properties'.
51
;
52
;   The following fields are pre-set by JATS (but can be overriden) :
53
;       CompanyName
54
;       LegalTrademarks
55
;       LegalCopyright
56
;       FileVersion
57
;
58
;   The following field must be set :
59
;       FileDescription
60
;
61
;------------------------------------------------------------------------------
62
 
63
!define          PACKAGE_LONGNAME       "JATS Build Tool"
64
!define          PACKAGE_DESCRIPTION    "VIX JATS Build and Make tools"
65
 
66
; Fudge the name seen when the package is installed
67
!undef           GBE_PACKAGE
68
!define          GBE_PACKAGE            "Jats"
69
 
70
VIAddVersionKey "FileDescription" "${PACKAGE_DESCRIPTION}"
71
 
72
;------------------------------------------------------------------------------
73
;
74
;   Set the installation folder - 
75
;
76
;------------------------------------------------------------------------------
77
 
78
;       Start with a sane default in case the registry key is not set
79
 
80
;InstallDir "$PROGRAMFILES\Vix\Jats"
81
;InstallDir "$LOCALAPPDATA\Vix\Jats"
82
InstallDir "C:\Jats"
83
 
84
;       Get installation folder from registry if available
85
!define InstallDirReg "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GBE_PACKAGE}"
86
InstallDirRegKey HKLM "${InstallDirReg}" "InstallLocation"
87
 
88
 
89
;------------------------------------------------------------------------------
90
;
91
;   Request application privileges for Windows Vista/7
92
;   Need admin privileges to modify registry, otherwise use user
93
;------------------------------------------------------------------------------
94
 
95
RequestExecutionLevel admin
96
 
97
;------------------------------------------------------------------------------
98
;
99
;   Modern Interface Settings
100
;
101
;------------------------------------------------------------------------------
102
 
103
#!define MUI_ABORTWARNING
104
 !define MUI_ICON                       "${GBE_NSISDATA}\VixIcon.ico"
105
 !define MUI_UNICON                     "${GBE_NSISDATA}\VixIcon.ico"
106
 !define MUI_HEADERIMAGE
107
 !define MUI_HEADERIMAGE_BITMAP         "${GBE_NSISDATA}\VixHeader.bmp"
108
 !define MUI_WELCOMEFINISHPAGE_BITMAP   "${GBE_NSISDATA}\VixPanel40.bmp"
109
 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "${GBE_NSISDATA}\VixPanel40.bmp"
110
 !define MUI_FINISHPAGE_NOAUTOCLOSE
111
 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
112
 !define MUI_WELCOMEPAGE_TITLE_3LINES
113
 !define MUI_FINISHPAGE_TITLE_3LINES
114
 
115
;------------------------------------------------------------------------------
116
;
117
;   Pages
118
;   List of Pages for the Modern UI to show
119
;
120
;------------------------------------------------------------------------------
121
 
122
!insertmacro MUI_PAGE_WELCOME
123
!insertmacro MUI_PAGE_COMPONENTS
124
 
125
!define MUI_PAGE_CUSTOMFUNCTION_PRE CheckInstDirReg
126
!insertmacro MUI_PAGE_DIRECTORY
127
 
128
; User configuration
129
Var DpkgArchive
130
Var PerlPath
131
 
132
!define      VIX_PAGE_EDIT_TEXT     "JATS Configuration"
133
!define      VIX_PAGE_EDIT_SUBTEXT  "Specify Paths"
134
!define      VIX_PAGE_EDIT_TITLE    "Specify a directory that provides 'dpkg_archive'.$\r$\nNormally this will be a network share.$\r$\nThis installer will not mount this path."
135
!insertmacro VIX_PAGE_EDIT2 "dpkg_archive" $DpkgArchive "Perl Path" $PerlPath
136
 
137
!insertmacro MUI_PAGE_INSTFILES
138
 
139
 
140
!define MUI_FINISHPAGE_TEXT "JATS has been installed but may require some configuration by editing $INSTDIR\jats_config.bat"
141
 
142
!define MUI_FINISHPAGE_RUN_TEXT "Edit config with notepad"
143
!define MUI_FINISHPAGE_RUN "notepad.exe"
144
!define MUI_FINISHPAGE_RUN_PARAMETERS "$INSTDIR\jats_config.bat"
145
!define MUI_FINISHPAGE_RUN_NOTCHECKED
146
;!define MUI_FINISHPAGE_SHOWREADME_TEXT "Read Me"
147
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\jats.html"
148
!insertmacro MUI_PAGE_FINISH
149
 
150
!insertmacro MUI_UNPAGE_CONFIRM
151
!insertmacro MUI_UNPAGE_INSTFILES
152
 
153
;------------------------------------------------------------------------------
154
;
155
;   Languages
156
;   System will select default language
157
;
158
;------------------------------------------------------------------------------
159
 
160
!insertmacro MUI_LANGUAGE "English"
161
 
162
 
163
;------------------------------------------------------------------------------
164
;
165
;   Installer Sections
166
;   Each section will show up as a 'component', if that page is shown
167
;
168
;------------------------------------------------------------------------------
169
CRCCheck on ; (can be off)
170
 
171
;------------------------------------------------------------------------------
172
;
173
;   Display stuff
174
;
175
;------------------------------------------------------------------------------
176
Section -
177
 
178
    DetailPrint "INSTDIR: $INSTDIR"
179
    DetailPrint "dpkg_archive: $DpkgArchive"
180
    DetailPrint "Perl Dir: $PerlPath"
181
 
182
SectionEnd
183
 
184
;------------------------------------------------------------------------------
185
;
186
;   Install Prerequisites
187
;
188
;------------------------------------------------------------------------------
189
Section "Active State Perl 5.8.9" SecAsPerl
190
  ClearErrors
191
  DetailPrint "---- Install Prerequisites section"
192
  SetOutPath $INSTDIR
193
 
194
  File "ActivePerl-5.8.9.827-MSWin32-x86-291969.msi"
195
  ExecWait '"msiexec" /i "$INSTDIR\ActivePerl-5.8.9.827-MSWin32-x86-291969.msi"'
196
  ${IfThen} ${Errors} ${|} Abort "Error installing ActiveState Perl" ${|}
197
 
198
  Delete "$INSTDIR\ActivePerl-5.8.9.827-MSWin32-x86-291969.msi"
199
 
200
SectionEnd
201
 
202
;------------------------------------------------------------------------------
203
;
204
;   Section to Install application files & configure
205
;
206
;------------------------------------------------------------------------------
207
Section "Jats Script (required)" SecJats
208
 
209
    DetailPrint "---- Install Application section"
210
    ClearErrors
211
 
212
    StrCpy $0 "$PerlPath\bin\perl.exe"
213
    ${IfNot} ${FileExists} $0
214
        MessageBox MB_ICONEXCLAMATION|MB_OKCANCEL "$0 not found" /SD IDCANCEL IDOK +4
215
        DetailPrint "Abort: File not found: $0"
216
        Abort
217
    ${EndIf}
218
 
219
    ;   Does not appear to work on a network share
220
    ;   
221
    ;StrCpy $0 "$DpkgArchive"
222
    ;${IfNot} ${FileExists} $0 
223
    ;    MessageBox MB_ICONEXCLAMATION|MB_OKCANCEL "$0 not found" /SD IDCANCEL IDOK +4
224
    ;    DetailPrint "Abort: File not found: $0"
225
    ;    Abort
226
    ;${EndIf}
227
 
228
    SetOutPath "$INSTDIR"
229
    File "jats.bat"
230
    File "jats.html"
231
 
232
    ${If} ${FileExists} "jats_config.bat"
233
        DetailPrint "Retain original jats_config.bat"
234
        File /oname=jats_config_new.bat jats_config.bat
235
    ${Else}
236
        SetOverwrite off
237
        File "jats_config.bat"
238
        SetOverwrite on
239
    ${EndIf}
240
 
241
 
242
    ${IfThen} ${Errors} ${|} Abort "Error installing one or more application files" ${|}
243
 
244
    StrCpy $2 "$INSTDIR\jats.bat"
245
    DetailPrint "Configuring $2"
246
    ${textreplace::ReplaceInFile}  $2  $2  "<REPLACETAG-DPKG_ARCHIVE>"  $DpkgArchive   "/S=1" $1
247
    ${textreplace::ReplaceInFile}  $2  $2  "<REPLACETAG-PERLDIR>"  $PerlPath   "/S=1" $1
248
    ${textreplace::ReplaceInFile}  $2  $2  "<REPLACETAG-PACKAGE>"  ${GBE_PACKAGE}   "/S=1" $1
249
    ${textreplace::ReplaceInFile}  $2  $2  "<REPLACETAG-VERSION>"  ${GBE_VERSION_FULL}   "/S=1" $1
250
 
251
    StrCpy $2 "$INSTDIR\jats.html"
252
    DetailPrint "Configuring $2"
253
    ${textreplace::ReplaceInFile}  $2  $2  "<REPLACETAG-DPKG_ARCHIVE>"  $DpkgArchive   "/S=1" $1
254
    ${textreplace::ReplaceInFile}  $2  $2  "<REPLACETAG-INSTDIR>"       $INSTDIR   "/S=1" $1
255
    ${textreplace::ReplaceInFile}  $2  $2  "<REPLACETAG-PERLDIR>"  $PerlPath   "/S=1" $1
256
 
257
 
258
    ${IfThen} ${Errors} ${|} Abort "Error configuring $2" ${|}
259
 
260
 
261
SectionEnd
262
 
263
;------------------------------------------------------------------------------
264
;
265
;   Configuration section
266
;
267
;------------------------------------------------------------------------------
268
Section "-Config"
269
 
270
    DetailPrint "---- Install Config section"
271
    ; make sure plugings dir is initialised
272
    InitPluginsDir
273
    ClearErrors
274
 
275
    DetailPrint "Adding to Path"
276
    ${nsis_path::PrependSystemPath} "$INSTDIR"
277
 
278
    ${IfThen} ${Errors} ${|} Abort "Error Modifying PATH Environment" ${|}
279
 
280
    ; make sure windows knows about the change
281
    DetailPrint "Notify OS of change to PATH"
282
    SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=3000
283
 
284
SectionEnd
285
 
286
 
287
;------------------------------------------------------------------------------
288
;
289
;   Section to create the Core of the ininstaller 
290
;   This will be hidden and will be installed first
291
;
292
;------------------------------------------------------------------------------
293
Section "-Core"
294
 
295
    ; Create uninstaller and copy it into the install directory
296
    DetailPrint "---- Install -Core section"
297
 
298
    ; Use default uninstaller location and name and registry keys
299
    ; defines 
300
    ; VIX_UNISTALL_EXE          - The uninstaller location
301
    ; VIX_UNINSTALL_KEY         - The uninstall registry key where all the uninstall values are written
302
    ${VIX_CREATE_UNINSTALLER_AND_REGISTRY}
303
    ${IfThen} ${Errors} ${|} Abort "Error creating uninstaller information" ${|}
304
 
305
SectionEnd
306
 
307
 
308
;------------------------------------------------------------------------------
309
;
310
;   Uninstall Configuration section first
311
;
312
;------------------------------------------------------------------------------
313
Section "-un.Config"
314
 
315
    DetailPrint "---- Uninstall Config section"
316
    ClearErrors
317
 
318
    ; Remove path elements 
319
    DetailPrint "Remove from PATH: $INSTDIR"
320
    ${nsis_path::DeleteSystemPath} "$INSTDIR"
321
    ${IfThen} ${Errors} ${|} Abort "Error Modifying PATH Environment" ${|}
322
 
323
    DetailPrint "Notify OS of change to PATH"
324
    SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=3000
325
 
326
SectionEnd
327
 
328
;------------------------------------------------------------------------------
329
;
330
;   Uninstaller Sections
331
;   Uninstaller for files installed by the user
332
;
333
;------------------------------------------------------------------------------
334
 
335
Section "un.Application"
336
 
337
    DetailPrint "---- UnInstall Application section"
338
 
339
    ; Remove files that we installed
340
 
341
    Delete "$INSTDIR\jats.bat"
342
    Delete "$INSTDIR\jats.html"
343
    Delete "$INSTDIR\jats_config_new.bat"
344
    Delete "$INSTDIR\jats_config.bat"
345
 
346
    ; Dont recurse, just remove if empty
347
    RmDir $INSTDIR
348
 
349
    DetailPrint "---- UnInstall Application section done"
350
SectionEnd
351
 
352
 
353
;------------------------------------------------------------------------------
354
;
355
;   Uninistaller section to uninstall keys
356
;   That have been installed as a part of the core installer
357
;
358
;------------------------------------------------------------------------------
359
Section "-un.Core"
360
 
361
    DetailPrint "---- Uninstall -Core section"
362
 
363
    ; Delete Uninstaller and associated uninstall registry 
364
    ${VIX_REMOVE_UNINSTALLER_AND_REGISTRY}
365
 
366
    ; Dont recurse, just remove if empty
367
    RmDir $INSTDIR
368
    RmDir "$INSTDIR\.."
369
 
370
SectionEnd
371
 
372
 
373
;--------------------------------
374
;Descriptions
375
 
376
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
377
  !insertmacro MUI_DESCRIPTION_TEXT ${SecAsPerl} "ActiveState Perl is required in order to run Jats."
378
  !insertmacro MUI_DESCRIPTION_TEXT ${SecJats} "Install a batch file that will invoke JATS held on a network share"
379
!insertmacro MUI_FUNCTION_DESCRIPTION_END
380
 
381
;--------------------------------
382
Function .onInit
383
 
384
    StrCpy $DpkgArchive "v:\dpkg_archive"
385
    StrCpy $PerlPath "c:\perl"
386
    DetailPrint "---- On Init"
387
 
388
    IntOp $0 ${SF_SELECTED} | ${SF_RO}
389
    SectionSetFlags ${SecJats} $0
390
    Call TestForPerl
391
 
392
    ; If a version is already installed get & set install dir used in last install as defaults for this Install
393
    ; otherwise INSTDIR is left as is
394
    ; ***** IF INSTDIR IS FIXED THIS CAN BE REMOVED *****
395
    ;${VIX_SETINSTDIR_IFINSTALLED}
396
 
397
FunctionEnd
398
 
399
;--------------------------------
400
;   Check for an installation of Perl
401
;   Will not check that its suitable, just that Perl.exe exists
402
;   Will set $PerlPath and unselect SecAsPerl  
403
;
404
Function TestForPerl
405
    Push $1
406
    StrCpy $0 0
407
 
408
    StrCpy $1 "C:\Perl_5.8.9\bin\perl.exe"
409
    IfFileExists $1 Found 0
410
 
411
    StrCpy $1 "C:\Perl\bin\perl.exe"
412
    IfFileExists $1 Found 0
413
 
414
    StrCpy $1 "$$PROGRAMFILES\Perl\bin\perl.exe"
415
    IfFileExists $1 Found 0
416
 
417
    StrCpy $1 "$$PROGRAMFILES32\Perl\bin\perl.exe"
418
    IfFileExists $1 Found 0
419
 
420
    StrCpy $1 "$$PROGRAMFILES64\Perl\bin\perl.exe"
421
    IfFileExists $1 Found End
422
 
423
Found:
424
    StrCpy $PerlPath $1 -13
425
 
426
    SectionGetFlags ${SecAsPerl} $1
427
	IntOp $1 $1 ^ ${SF_SELECTED}
428
    SectionSetFlags ${SecAsPerl} $1
429
 
430
    StrCpy $0 1
431
 
432
End:
433
    Pop $1
434
 
435
FunctionEnd
436
 
437
;--------------------------------
438
;   Check if a previous version exists
439
;   This function is used to prevent the user from installing into multiple directories
440
Function CheckInstDirReg
441
 
442
  ReadRegStr $R0 HKLM "${InstallDirReg}" "InstallLocation"
443
  StrCmp $R0 "" NotFound
444
    IfFileExists $R0 0 NotFound
445
        Abort ## InstallLocation present: Skip directory page!
446
 
447
NotFound:
448
 
449
FunctionEnd