Debian Codegraph @

regina.nsi.in

raw
1 ;
2 ; Regina Install Script, based on Modern Example Script Written by Joost Verburg
3 ; Requires: ${NSISDIR}\Contrib\Path\path.nsi
4 ; Run as:
5 ; makensis /DVERSION=x.x /DNODOTVER=xx regina.nsi
6 ; Note:
7 ; regina.nsi MUST be in the current directory!
8
9 !define LONGNAME "Regina Rexx ${MACH}" ;Long Name (for descriptions)
10 !define SHORTNAME "Regina" ;Short name (no slash) of package
11 !define REGISTRYNAME "ReginaRexx${MACH}" ;Name used in Windows registry; NO slashes
12 !define SFHOME "http://regina-rexx.sourceforge.net"
13 !define SFGROUP "28102"
14 !define UNINSTALLER "uninstall.exe"
15 !define DISPLAYICON "$INSTDIR\regina.exe,0"
16 !define KEYFILE "regina.exe"
17
18 !define MUI_ICON "${SRCDIR}\reginaw32.ico"
19 !define MUI_UNICON "uninstall.ico"
20
21 Name "${LONGNAME} ${VERSION}${VERSUPP}"
22
23 !include "MUI.nsh"
24 !include "x64.nsh"
25
26 !define MUI_CUSTOMPAGECOMMANDS
27
28 !define MUI_LICENSEPAGE
29 !define MUI_COMPONENTSPAGE
30 !define MUI_DIRECTORYPAGE
31 !define MUI_FINISHPAGE
32 !define MUI_FINISHPAGE_NOAUTOCLOSE
33
34 !define MUI_ABORTWARNING
35
36 !define MUI_UNINSTALLER
37 !define MUI_UNCONFIRMPAGE
38
39 !addplugindir ${SRCDIR}\nsis
40
41 ; VERSION ;Must be supplied on compile command line
42 ; NODOTVER ;Must be supplied on compile command line
43
44 ;--------------------------------
45 ;Configuration
46
47 ;General
48 OutFile "${SHORTNAME}${NODOTVER}${VERSUPP}${ARCH}.exe"
49 ShowInstdetails show
50 SetOverwrite on
51
52
53 ;License dialog
54 LicenseData "${SRCDIR}\COPYING-LIB"
55
56
57 ;Folder-select dialog
58 !if ${ARCH} == "w32"
59 InstallDir "$PROGRAMFILES\rexx.org\Regina"
60 !else
61 InstallDir "$PROGRAMFILES64\rexx.org\Regina"
62 !endif
63
64 LangString TEXT_IO_PAGETITLE_ADDPATH ${LANG_ENGLISH} "Add install directory"
65 LangString TEXT_IO_SUBTITLE_ADDPATH ${LANG_ENGLISH} " "
66 LangString TEXT_IO_PAGETITLE_ASSOC ${LANG_ENGLISH} "File Associations"
67 LangString TEXT_IO_SUBTITLE_ASSOC ${LANG_ENGLISH} "Associate file extensions with Regina"
68 LangString TEXT_IO_PAGETITLE_LANGUAGE ${LANG_ENGLISH} "Language for Error Messages"
69 LangString TEXT_IO_SUBTITLE_LANGUAGE ${LANG_ENGLISH} "Select the language for Regina error messages"
70 LangString TEXT_IO_PAGETITLE_STACK ${LANG_ENGLISH} "Regina Stack Service"
71 LangString TEXT_IO_SUBTITLE_STACK ${LANG_ENGLISH} "Install Regina Stack Service"
72 ;--------------------------------
73 ;Pages
74
75 !insertmacro MUI_PAGE_LICENSE "${SRCDIR}\COPYING-LIB"
76 !insertmacro MUI_PAGE_COMPONENTS
77 !insertmacro MUI_PAGE_DIRECTORY
78 Page custom SetCustomAddPath
79 Page custom SetCustomAssoc
80 Page custom SetCustomLanguage
81 Page custom SetCustomStack
82 !insertmacro MUI_PAGE_INSTFILES
83 !insertmacro MUI_PAGE_FINISH
84
85 ;--------------------------------
86 ;Language
87 !insertmacro MUI_LANGUAGE "English"
88
89 ;================
90 ;Variables
91 Var IsAdminUser
92
93 ;--------------------------------
94 ;Reserved files
95
96 ReserveFile "regina_ap.ini"
97 ReserveFile "regina_fa.ini"
98 ReserveFile "regina_ss.ini"
99 ReserveFile "regina_mt.ini"
100 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
101
102 ;========================================================================
103 ;Installer Sections
104
105 ;------------------------------------------------------------------------
106 ; Core
107
108 Section "${LONGNAME} Core (required)" SecMain
109 SectionIn 1 RO
110 [Core]
111 ; Add directory to PATH?
112 ReadIniStr $R0 "$PLUGINSDIR\regina_ap.ini" "Field 2" State
113 Strcmp $R0 0 nopath
114 ; add the $INSTDIR directory to the PATH if not already there
115 Push $INSTDIR
116 Push $IsAdminUser ; "true" or "false"
117 Push "PATH"
118 Call AddToPath
119 nopath:
120 ; Add REGINA_HOME?
121 ReadIniStr $R0 "$PLUGINSDIR\regina_ap.ini" "Field 3" State
122 Strcmp $R0 0 noenv
123 ; Set the REGINA_HOME environment variable
124 Push "REGINA_HOME"
125 Push $INSTDIR
126 Push $IsAdminUser ; "true" or "false"
127 Call WriteEnvStr
128 noenv:
129
130 CreateDirectory "$SMPROGRAMS\${LONGNAME}"
131 CreateShortCut "$SMPROGRAMS\${LONGNAME}\Uninstall ${SHORTNAME}.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
132 CreateShortCut "$SMPROGRAMS\${LONGNAME}\Release Notes.lnk" "$INSTDIR\README${NODOTVER}.txt" "" "$INSTDIR\README${NODOTVER}.txt" 0
133 CreateShortCut "$SMPROGRAMS\${LONGNAME}\README.lnk" "$INSTDIR\READMEW32.txt" "" "$INSTDIR\READMEW32.txt" 0
134 CreateShortCut "$SMPROGRAMS\${LONGNAME}\LICENSE.lnk" "$INSTDIR\LICENSE.txt" "" "$INSTDIR\LICENSE.txt" 0
135 ; Can't use CreateShortcut for URLs
136 WriteINIStr "$SMPROGRAMS\${LONGNAME}\Regina Rexx Home Page.url" "InternetShortcut" "URL" "http://regina-rexx.sourceforge.net"
137 ; Write the installation path into the registry
138 ; Write the uninstall keys
139 !include "${SRCDIR}\common\uninstaller.nsh"
140 ; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}" "DisplayName" "${LONGNAME}"
141 ; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}" "DisplayIcon" "${DISPLAYICON}"
142 ; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}" "HelpLink" "http://www.rexxla.org/support.html"
143 ; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}" "URLUpdateInfo" "http://sourceforge.net/project/showfiles.php?group_id=28102"
144 ; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}" "URLInfoAbout" "http://www.rexx.org/"
145 ; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}" "DisplayVersion" "${VERSION}"
146 ; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}" "Publisher" "Mark Hessling"
147 ; WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}" "UninstallString" '"$INSTDIR\${UNINSTALLER}"'
148 ; WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}" "InstallLocation" '"$INSTDIR"'
149 ; WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}" "UnInstallLocation" "$INSTDIR" ; dont quote it
150 ; WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}" "NoModify" 0x00000001
151 ; WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}" "NoRepair" 0x00000001
152 ; WriteUninstaller "$INSTDIR\${UNINSTALLER}"
153 ; Stack Service
154 ReadIniStr $R0 "$PLUGINSDIR\regina_ss.ini" "Field 4" State
155 ReadIniStr $R1 "$PLUGINSDIR\regina_ss.ini" "Field 5" State
156 Push $R0
157 Push $R1
158 Call InstallRxstack
159 StrCpy $5 0
160 ; add to PATHEXT flag
161 ReadIniStr $R2 "$PLUGINSDIR\regina_fa.ini" "Field 6" State
162 ; get state of each extension
163 ReadIniStr $R0 "$PLUGINSDIR\regina_fa.ini" "Field 2" State
164 ReadIniStr $R1 "$PLUGINSDIR\regina_fa.ini" "Field 2" Text
165 Push $R0
166 Push $R1
167 Push $R2
168 Call DoFileAssociation
169 ReadIniStr $R0 "$PLUGINSDIR\regina_fa.ini" "Field 3" State
170 ReadIniStr $R1 "$PLUGINSDIR\regina_fa.ini" "Field 3" Text
171 Push $R0
172 Push $R1
173 Push $R2
174 Call DoFileAssociation
175 ReadIniStr $R0 "$PLUGINSDIR\regina_fa.ini" "Field 4" State
176 ReadIniStr $R1 "$PLUGINSDIR\regina_fa.ini" "Field 4" Text
177 Push $R0
178 Push $R1
179 Push $R2
180 Call DoFileAssociation
181 ReadIniStr $R0 "$PLUGINSDIR\regina_fa.ini" "Field 5" State
182 ReadIniStr $R1 "$PLUGINSDIR\regina_fa.ini" "Field 5" Text
183 Push $R0
184 Push $R1
185 Push $R2
186 Call DoFileAssociation
187 Call DoFileAssociationDetails
188 Call DoLanguageDefault
189 SectionEnd
190
191 ;------------------------------------------------------------------------
192 ; Demos
193
194 Section "${LONGNAME} Demos" SecDemo
195 CreateDirectory "$SMPROGRAMS\${LONGNAME}\${LONGNAME} Demos"
196 [Demo]
197 SectionEnd
198
199 ;------------------------------------------------------------------------
200 ; Development tools
201
202 Section "${LONGNAME} Development Kit" SecDev
203 [Development]
204 SectionEnd
205
206 ;------------------------------------------------------------------------
207 ; Doco
208
209 Section "${LONGNAME} Documentation" SecDoc
210 [Doc]
211 SectionEnd
212
213 Section ""
214
215 ;Invisible section to display the Finish header
216 ; !insertmacro MUI_FINISHHEADER
217
218 SectionEnd
219
220 ;========================================================================
221 ;Installer Functions
222
223 Function .onInit
224 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "regina_ap.ini"
225 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "regina_fa.ini"
226 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "regina_ss.ini"
227 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "regina_mt.ini"
228 ;
229 ; Uninstall previous version if present
230 ;
231 !include "${SRCDIR}\common\oninit.nsh"
232 FunctionEnd
233
234 Function SetCustomAddPath
235 ${If} ${RunningX64}
236 !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_PAGETITLE_ADDPATH)" "$(TEXT_IO_SUBTITLE_ADDPATH)"
237 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "regina_ap.ini"
238 ${EndIf}
239 FunctionEnd
240
241 Function SetCustomAssoc
242 !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_PAGETITLE_ASSOC)" "$(TEXT_IO_SUBTITLE_ASSOC)"
243 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "regina_fa.ini"
244 FunctionEnd
245
246 Function SetCustomLanguage
247 !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_PAGETITLE_LANGUAGE)" "$(TEXT_IO_SUBTITLE_LANGUAGE)"
248 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "regina_mt.ini"
249 FunctionEnd
250
251 Function SetCustomStack
252 !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_PAGETITLE_STACK)" "$(TEXT_IO_SUBTITLE_STACK)"
253 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "regina_ss.ini"
254 FunctionEnd
255
256 Function .onMouseOverSection
257
258 !insertmacro MUI_DESCRIPTION_BEGIN
259
260 !insertmacro MUI_DESCRIPTION_TEXT ${SecMain} "Installs the core components of ${LONGNAME} to the application folder."
261 !insertmacro MUI_DESCRIPTION_TEXT ${SecDev} "Installs the files required to embed ${LONGNAME} into you C/C++ application."
262 !insertmacro MUI_DESCRIPTION_TEXT ${SecDemo} "Install sample ${LONGNAME} programs."
263 !insertmacro MUI_DESCRIPTION_TEXT ${SecDoc} "Install ${LONGNAME} documentation."
264
265 !insertmacro MUI_DESCRIPTION_END
266
267 FunctionEnd
268
269 Function DoFileAssociation
270 Pop $R2
271 Pop $R1
272 Pop $R0
273 Strcmp $R0 0 exitfa
274 Strcmp $R1 "" exitfa
275 ; do the association
276 DetailPrint "Registering $R1 extension to run with Regina"
277 IntOp $5 $5 + 1
278 WriteRegStr HKCR $R1 "" "Regina"
279 ; add to PATHEXT if $R2 \= 0
280 Strcmp $R2 0 exitfa
281 DetailPrint "Adding $R1 to PATHEXT"
282 Push $R1
283 Push $IsAdminUser ; "true" or "false" per admin user
284 Push "PATHEXT"
285 Call AddToPath
286 exitfa:
287 Return
288 FunctionEnd
289
290 Function DoFileAssociationDetails
291 StrCmp $5 0 exitfad
292 ; do the association details
293 WriteRegStr HKCR "Regina" "" "Regina Rexx Program"
294 WriteRegStr HKCR "Regina\shell" "" "open"
295 WriteRegStr HKCR "Regina\DefaultIcon" "" "$INSTDIR\regina.exe,0"
296 WriteRegStr HKCR "Regina\shell\open" "" "Run"
297 WriteRegStr HKCR "Regina\shell\open\command" "" '"$INSTDIR\regina.exe" -p "%1" %*'
298 WriteRegStr HKCR "Regina\shell\edit" "" "Edit"
299 WriteRegStr HKCR "Regina\shell\edit\command" "" 'notepad.exe "%1"'
300 exitfad:
301 Return
302 FunctionEnd
303
304 Function DoLanguageDefault
305 StrCpy $1 2
306 langStartLoop:
307 StrCpy $2 "Field $1"
308 ReadIniStr $R0 "$PLUGINSDIR\regina_mt.ini" $2 State
309 StrCmp $R0 1 langFound
310 IntOp $1 $1 + 1
311 StrCmp $1 9 langExit ; the "9" here must be 1 more than the last field number in regina_mt.ini
312 Goto langStartLoop
313 langFound:
314 ReadIniStr $R0 "$PLUGINSDIR\regina_mt.ini" $2 Text
315 ; do the language default
316 Push "REGINA_LANG_DIR"
317 Push "$INSTDIR"
318 Push $IsAdminUser ; "true" or "false"
319 Call WriteEnvStr
320 Push "REGINA_LANG"
321 Push "$R0"
322 Push $IsAdminUser ; "true" or "false"
323 Call WriteEnvStr
324 DetailPrint "$R0 set as default language for error messages"
325 langExit:
326 Return
327 FunctionEnd
328
329 Function InstallRxstack
330 Pop $R1
331 Pop $R0
332 Strcmp $R0 0 exitss
333 ; do the install of rxstack
334 DetailPrint "Installing Regina Stack Service"
335 nsExec::ExecToLog "$INSTDIR\rxstack -install"
336 Strcmp $R1 0 exitss
337 DetailPrint "Starting Regina Stack Service"
338 Services::SendServiceCommand 'start' 'Regina Stack'
339 Pop $R0
340 StrCmp $R0 'Ok' exitss
341 MessageBox MB_OK|MB_ICONEXCLAMATION|MB_TOPMOST "Failed to start the Regina Stack service:$\n$0" /SD IDOK
342 exitss:
343 FunctionEnd
344
345 ;========================================================================
346 ;Uninstaller Section
347
348 Section "Uninstall"
349
350 ; get rid of file associations
351 Push ".rexx"
352 Call un.DeleteFileAssociation
353 Push ".rex"
354 Call un.DeleteFileAssociation
355 Push ".rx"
356 Call un.DeleteFileAssociation
357 Push ".cmd"
358 Call un.DeleteFileAssociation
359 Push $INSTDIR
360 Push $IsAdminUser ; pushes "true" or "false"
361 Push "PATH"
362 Call un.RemoveFromPath
363 DeleteRegKey HKCR "Regina"
364 ; remove LANG environment variables
365 Push "REGINA_LANG_DIR"
366 Push $IsAdminUser ; pushes "true" or "false"
367 Call un.DeleteEnvStr
368 Push "REGINA_LANG"
369 Push $IsAdminUser ; pushes "true" or "false"
370 Call un.DeleteEnvStr
371 ; stop and remove the rxstack service - ignore if we get errors
372 Services::SendServiceCommand 'stop' 'Regina Stack'
373 Exec "$INSTDIR\rxstack -remove"
374 [Uninstall]
375
376 ; Remove the installation stuff
377 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORTNAME}"
378
379 ; remove shortcuts directory and everything in it
380 RMDir /r "$SMPROGRAMS\${LONGNAME}"
381
382 ; !insertmacro MUI_UNFINISHHEADER
383
384 SectionEnd
385
386 ;========================================================================
387 ;Uninstaller Functions
388
389 Function un.onInit
390 ;
391 ; UnInstall as All Users if an admin
392 ;
393 !include "${SRCDIR}\common\unoninit.nsh"
394 FunctionEnd
395
396 Function un.DeleteFileAssociation
397 Pop $R0
398 ReadRegStr $R1 HKCR "$R0" ""
399 StrCmp $R1 "Regina" 0 NoOwn ; only delete key if we own it
400 DeleteRegKey HKCR "$R0"
401 DetailPrint "Deleted file association for $R0"
402 Push $R0
403 Push $IsAdminUser ; pushes "true" or "false"
404 Push "PATHEXT"
405 Call un.RemoveFromPath
406 DetailPrint "Removed $R0 from PATHEXT"
407 NoOwn:
408 FunctionEnd
409
410 !include "${SRCDIR}\common\admin.nsh"
411 !include "${SRCDIR}\common\isnt.nsh"
412 !include "${SRCDIR}\common\path.nsh"
413 !include "${SRCDIR}\common\WriteEnv.nsh"
414
415 ;eof