]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/include/init.nsh
finish new installer
[features.git] / development / Win32 / packaging / installer / include / init.nsh
1 /*
2
3 init.nsh
4
5 Initialization function
6
7 */
8
9 #--------------------------------
10 # Installer initialization
11
12 !macro PRINTER_INIT
13
14   ${If} ${AtLeastWinVista}
15     StrCpy $PrinterConf "printui.exe"
16   ${Else}
17     StrCpy $PrinterConf "rundll32.exe printui.dll,PrintUIEntry"
18   ${EndIf}
19
20 !macroend
21
22 Function .onInit
23
24   ${IfNot} ${IsNT}
25   ${OrIfNot} ${AtLeastWinXP}
26     MessageBox MB_OK|MB_ICONSTOP "${APP_NAME} ${APP_VERSION} requires Windows XP or later."
27     Quit
28   ${EndIf}
29   
30   # check that the installer is not currently running
31   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${BundleExeFile}.Instance") i .r1 ?e'
32   Pop $R0
33   ${if} $R0 != "0"
34    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
35    Abort
36   ${endif}
37   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${ExeFile}.Instance") i .r1 ?e'
38   Pop $R0
39   ${if} $R0 != "0"
40    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
41    Abort
42   ${endif}
43
44   # check if LyX is already installed
45   ReadRegStr $0 SHCTX "${APP_UNINST_KEY}" "Publisher"
46   ${if} $0 != ""
47    MessageBox MB_OK|MB_ICONSTOP "$(StillInstalled)"
48    Abort
49   ${endif}
50
51   !insertmacro PRINTER_INIT
52   !insertmacro MULTIUSER_INIT
53   
54   # this can be reset to "true" in section SecDesktop
55   StrCpy $CreateDesktopIcon "false"
56   StrCpy $CreateFileAssociations "false"
57  
58   ${IfNot} ${Silent}
59     # Show banner while installer is intializating 
60     Banner::show /NOUNLOAD "Checking system"
61   ${EndIf}
62  
63   Call SearchExternal
64   #Call InitExternal
65   
66   !if ${SETUPTYPE} == BUNDLE
67    # don't let the installer sections appear when the programs are already installed
68    ${if} $PathBibTeXEditor != ""
69     SectionSetText 3 "" # hides the corresponding uninstaller section, ${SecInstJabRef}
70    ${endif}
71   !endif
72   
73   ${IfNot} ${Silent}
74     Banner::destroy
75   ${EndIf}
76
77 FunctionEnd
78
79 # this function is called at first after starting the uninstaller
80 Function un.onInit
81
82   !insertmacro PRINTER_INIT
83   !insertmacro MULTIUSER_UNINIT
84
85   # Check that LyX is not currently running
86   FindProcDLL::FindProc "lyx.exe"
87   ${if} $R0 == "1"
88    MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
89    Abort
90   ${endif}
91
92   # set registry root key
93   ${if} $MultiUser.Privileges == "Admin"
94   ${orif} $MultiUser.Privileges == "Power"
95     SetShellVarContext all
96   ${else}
97    SetShellVarContext current
98   ${endif}
99
100   # Ascertain whether the user has sufficient privileges to uninstall.
101   # abort when LyX was installed with admin permissions but the user doesn't have administrator privileges
102   ReadRegStr $0 HKLM "${APP_UNINST_KEY}" "DisplayVersion"
103   ${if} $0 != ""
104   ${andif} $MultiUser.Privileges != "Admin"
105   ${andif} $MultiUser.Privileges != "Power"
106    MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)"
107    Abort
108   ${endif}
109   # abort when LyX couldn't be found in the registry
110   ${if} $0 == "" # check in HKCU
111    ReadRegStr $0 HKCU "${APP_UNINST_KEY}" "DisplayVersion"
112    ${if} $0 == ""
113      MessageBox MB_OK|MB_ICONEXCLAMATION "$(UnNotInRegistryLabel)"
114    ${endif}
115   ${endif}
116   
117   # Macro to investigate name of LyX's preferences folders to be able remove them
118   !insertmacro UnAppPreSuff $AppPre $AppSuff # macro from LyXUtils.nsh
119
120   # test if MiKTeX was installed together with LyX
121   ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
122   ${if} $0 == "Yes${APP_SERIES_KEY}"
123    SectionSetText 2 "MiKTeX" # names the corersponding uninstaller section
124    StrCpy $LaTeXInstalled "MiKTeX"
125    DeleteRegValue HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
126   ${else}
127    SectionSetText 2 "" # hides the corresponding uninstaller section
128   ${endif}
129   
130   # test if JabRef was installed together with LyX
131   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
132   ${if} $0 == "Yes${APP_SERIES_KEY}"
133    SectionSetText 3 "JabRef" # names the corersponding uninstaller section
134    StrCpy $JabRefInstalled "Yes"
135    DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
136   ${else}
137    SectionSetText 3 "" # hides the corresponding uninstaller section
138   ${endif}
139
140   # question message if the user really wants to uninstall LyX
141   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2 # continue if yes
142   Abort
143
144 FunctionEnd
145
146 #--------------------------------
147 # User initialization
148
149 Var ComponentPath
150 Var LyXLangName
151
152 # COMPONENT can be LaTeX, ImageMagick and Ghostscript
153 !macro EXTERNAL_INIT COMPONENT
154
155   # APP_REGKEY_SETUP = "Software\${APP_NAME}${APP_SERIES_KEY}\Setup"
156   # where ${APP_NAME}${APP_SERIES_KEY} is something like LyX16
157   ReadRegStr $ComponentPath SHELL_CONTEXT "${APP_REGKEY_SETUP}" "${COMPONENT} Path"
158   
159   # BIN_LATEX etc are defined in settings.nsh
160   ${If} ${FileExists} "$ComponentPath\${BIN_${COMPONENT}}"
161     # set variables like PathLaTeX
162     StrCpy $Path${COMPONENT} $ComponentPath
163   ${EndIf}
164
165 !macroend
166
167 Function InitUser
168
169   # Get directories of components from registry
170   
171   !insertmacro EXTERNAL_INIT LaTeX
172   
173   # Get LyX language
174   
175   ReadRegStr $LyXLangName SHELL_CONTEXT "${APP_REGKEY_SETUP}" "LyX Language"
176   
177   ${If} $LyXLangName != ""
178     StrCpy $LangName $LyXLangName
179   ${EndIf}
180   
181 FunctionEnd
182
183 #--------------------------------
184 # visible installer sections
185
186 Section "!${APP_NAME}" SecCore
187   SectionIn RO
188 SectionEnd
189 Section "$(SecFileAssocTitle)" SecFileAssoc
190   StrCpy $CreateFileAssociations "true"
191 SectionEnd
192 Section "$(SecDesktopTitle)" SecDesktop
193   StrCpy $CreateDesktopIcon "true"
194 SectionEnd
195
196 !if ${SETUPTYPE} == BUNDLE
197  Section /o "$(SecInstJabRefTitle)" SecInstJabRef
198   AddSize 5000
199   StrCpy $InstallJabRef "true"
200  SectionEnd
201 !endif
202
203 SectionGroup "Dictionaries" SecDictionaries
204
205 Section /o "Afrikaans" SecDAfrikaans
206  StrCpy $DictCodes "af_ZA$DictCodes"
207  AddSize 1440
208 SectionEnd
209
210 Section /o "Arabic" SecDArabic
211  StrCpy $DictCodes "ar_DZ$DictCodes"
212  AddSize 2500
213 SectionEnd
214
215 Section /o "Armenian" SecDArmenian
216  StrCpy $DictCodes "hy_AM$DictCodes"
217  AddSize 2000
218 SectionEnd
219
220 Section /o "Bahasa Indonesia" SecDIndonesian
221  StrCpy $DictCodes "id_ID$DictCodes"
222  AddSize 217
223 SectionEnd
224
225 Section /o "Bahasa Melayu" SecDMalayan
226  StrCpy $DictCodes "ms_MY$DictCodes"
227  AddSize 227
228 SectionEnd
229
230 Section /o "Belarusian" SecDBelarusian 
231  StrCpy $DictCodes "be_BY$DictCodes"
232  AddSize 1040
233 SectionEnd
234
235 Section /o "Brezhoneg" SecDBreton 
236  StrCpy $DictCodes "br_FR$DictCodes"
237  AddSize 11000
238 SectionEnd
239
240 Section /o "Bulgarian" SecDBulgarian
241  StrCpy $DictCodes "bg_BG$DictCodes"
242  AddSize 985
243 SectionEnd
244
245 Section /o "Català" SecDCatalanian
246  StrCpy $DictCodes "ca_ES$DictCodes"
247  AddSize 1210
248 SectionEnd
249
250 Section /o "Ce\9atina" SecDCzech
251  StrCpy $DictCodes "cs_CZ$DictCodes"
252  AddSize 2190
253 SectionEnd
254
255 Section /o "Cymraeg" SecDWelsh 
256  StrCpy $DictCodes "cy_GB$DictCodes"
257  AddSize 1540
258 SectionEnd
259
260 Section /o "Dansk" SecDDanish
261  StrCpy $DictCodes "da_DK$DictCodes"
262  AddSize 2470
263 SectionEnd
264
265 Section /o "German (A)" SecDGermanAT
266  StrCpy $DictCodes "de_AT$DictCodes"
267  AddSize 1000
268 SectionEnd
269
270 Section /o "German (CH)" SecDGermanCH
271  StrCpy $DictCodes "de_CH$DictCodes"
272  AddSize 1000
273 SectionEnd
274
275 Section "German (D)" SecDGermanD
276  # already installed by default
277  #StrCpy $DictCodes "de_DE$DictCodes"
278  AddSize 2650
279 SectionEnd
280
281 Section /o "Greek" SecDGreek
282  StrCpy $DictCodes "el_GR$DictCodes"
283  AddSize 6550
284 SectionEnd
285
286 Section /o "Eesti" SecDEstonian
287  StrCpy $DictCodes "et_EE$DictCodes"
288  AddSize 4400
289 SectionEnd
290
291 # enable this for LyX 2.1!
292 #Section /o "English (AU)" SecDEnglishAU
293 # StrCpy $DictCodes "en_AU$DictCodes"
294 # AddSize 587
295 #SectionEnd
296
297 Section /o "English (CA)" SecDEnglishCA
298  StrCpy $DictCodes "en_CA$DictCodes"
299  AddSize 690
300 SectionEnd
301
302 Section "English (GB)" SecDEnglishGB
303  # already installed by default
304  #StrCpy $DictCodes "en_GB$DictCodes"
305  AddSize 757
306 SectionEnd
307
308 # enable this for LyX 2.1!
309 #Section /o "English (NZ)" SecDEnglishNZ
310 # StrCpy $DictCodes "en_NZ$DictCodes"
311 # AddSize 551
312 #SectionEnd
313
314 Section "English (US)" SecDEnglishUS
315  # already installed by default
316  #StrCpy $DictCodes "en_US$DictCodes"
317  AddSize 688
318 SectionEnd
319
320 Section "Español (ES)" SecDSpanishES
321  # already installed by default
322  #StrCpy $DictCodes "es_ES$DictCodes"
323  AddSize 974
324 SectionEnd
325
326 Section "Español (MX)" SecDSpanishMX
327  # already installed by default
328  #StrCpy $DictCodes "es_MX$DictCodes"
329  AddSize 924
330 SectionEnd
331
332 Section /o "Esperanto" SecDEsperanto
333  StrCpy $DictCodes "eo_EO$DictCodes"
334  AddSize 389
335 SectionEnd
336
337 Section /o "Euskara" SecDBasque
338  StrCpy $DictCodes "eu_ES$DictCodes"
339  AddSize 4850
340 SectionEnd
341
342 Section /o "Farsi" SecDFarsi
343  StrCpy $DictCodes "fa_IR$DictCodes"
344  AddSize 6710
345 SectionEnd
346
347 Section "Français" SecDFrench
348  # already installed by default
349  #StrCpy $DictCodes "fr_FR$DictCodes"
350  AddSize 1200
351 SectionEnd
352
353 Section /o "Gaeilge" SecDGaelic
354  StrCpy $DictCodes "ga_IR$DictCodes"
355  AddSize 1090
356 SectionEnd
357
358 Section /o "Gàidhlig" SecDScottish
359  StrCpy $DictCodes "gd_GB$DictCodes"
360  AddSize 2460
361 SectionEnd
362
363 Section /o "Galego" SecDGalician
364  StrCpy $DictCodes "gl_ES$DictCodes"
365  AddSize 916
366 SectionEnd
367
368 Section /o "Hebrew" SecDHebrew
369  StrCpy $DictCodes "he_IL$DictCodes"
370  AddSize 3120
371 SectionEnd
372
373 Section /o "Hrvatski" SecDCroatian
374  StrCpy $DictCodes "hr_HR$DictCodes"
375  AddSize 2240
376 SectionEnd
377
378 Section /o "Magyar" SecDHungarian
379  StrCpy $DictCodes "hu_HU$DictCodes"
380  AddSize 3380
381 SectionEnd
382
383 Section /o "Interlingua" SecDInterlingua
384  StrCpy $DictCodes "ia_IA$DictCodes"
385  AddSize 649
386 SectionEnd
387
388 Section /o "Íslenska" SecDIcelandic
389  StrCpy $DictCodes "is_IS$DictCodes"
390  AddSize 2320
391 SectionEnd
392
393 Section /o "Italiano" SecDItalian
394  StrCpy $DictCodes "it_IT$DictCodes"
395  AddSize 1300
396 SectionEnd
397
398 Section /o "Kazakh" SecDKazakh
399  StrCpy $DictCodes "kk_KZ$DictCodes"
400  AddSize 2120
401 SectionEnd
402
403 Section /o "Korean" SecDKorean
404  StrCpy $DictCodes "ko_KR$DictCodes"
405  AddSize 15200
406 SectionEnd
407
408 Section /o "Latina" SecDLatin
409  StrCpy $DictCodes "la_LA$DictCodes"
410  AddSize 1250
411 SectionEnd
412
413 Section /o "Lietuviu" SecDLithuanian
414  StrCpy $DictCodes "lt_LT$DictCodes"
415  AddSize 1320
416 SectionEnd
417
418 Section /o "Latvie\9au" SecDLatvian
419  StrCpy $DictCodes "lv_LV$DictCodes"
420  AddSize 2140
421 SectionEnd
422
423 Section /o "Nederlands" SecDDutch
424  StrCpy $DictCodes "nl_NL$DictCodes"
425  AddSize 1820
426 SectionEnd
427
428 Section /o "Norsk (Bokmål)" SecDNorwegianNB
429  StrCpy $DictCodes "nb_NO$DictCodes"
430  AddSize 4890
431 SectionEnd
432
433 Section /o "Norsk (Nynorsk)" SecDNorwegianNN
434  StrCpy $DictCodes "nn_NO$DictCodes"
435  AddSize 2890
436 SectionEnd
437
438 Section /o "Polski" SecDPolish
439  StrCpy $DictCodes "pl_PL$DictCodes"
440  AddSize 4540
441 SectionEnd
442
443 Section /o "Português (BR)" SecDPortugueseBR
444  StrCpy $DictCodes "pt_BR$DictCodes"
445  AddSize 5280
446 SectionEnd
447
448 Section /o "Português (PT)" SecDPortuguesePT
449  StrCpy $DictCodes "pt_PT$DictCodes"
450  AddSize 1460
451 SectionEnd
452
453 Section /o "Româna" SecDRomanian
454  StrCpy $DictCodes "ro_RO$DictCodes"
455  AddSize 1930
456 SectionEnd
457
458 Section "Russian" SecDRussian
459  # already installed by default
460  #StrCpy $DictCodes "ru_RU$DictCodes"
461  AddSize 1920
462 SectionEnd
463
464 Section /o "Serb\9acina (Dolno)" SecDSorbianD
465  StrCpy $DictCodes "db_DE$DictCodes"
466  AddSize 904
467 SectionEnd
468
469 Section /o "Serb\9acina (Horno)" SecDSorbianH
470  StrCpy $DictCodes "hb_DE$DictCodes"
471  AddSize 740
472 SectionEnd
473
474 Section /o "Shqipe" SecDAlbanian
475  StrCpy $DictCodes "sq_AL$DictCodes"
476  AddSize 2400
477 SectionEnd
478
479 Section /o "Sloven\9acina" SecDSlowenian
480  StrCpy $DictCodes "sl_SI$DictCodes"
481  AddSize 2840
482 SectionEnd
483
484 Section /o "Slovenský" SecDSlowakian
485  StrCpy $DictCodes "sk_SK$ThesCodes"
486  AddSize 4090
487 SectionEnd
488
489 Section /o "Srpski" SecDSerbian
490  StrCpy $DictCodes "sr_RS$DictCodes"
491  AddSize 3460
492 SectionEnd
493
494 Section /o "Svenska" SecDSwedish
495  StrCpy $DictCodes "sv_SE$DictCodes"
496  AddSize 1030
497 SectionEnd
498  
499 Section /o "Thai" SecDThai
500  StrCpy $DictCodes "th_TH$DictCodes"
501  AddSize 351
502 SectionEnd
503
504 Section /o "Ukrainian" SecDUkrainian
505  StrCpy $DictCodes "uk_UA$DictCodes"
506  AddSize 2620
507 SectionEnd
508
509 Section /o "Vietnamese" SecDVietnamese
510  StrCpy $DictCodes "vi_VN$DictCodes"
511  AddSize 39600
512 SectionEnd
513
514 SectionGroupEnd
515
516 SectionGroup "Thesaurus" SecThesaurus
517
518 Section /o "Bulgarian" SecTBulgarian
519  StrCpy $ThesCodes "bg_BG$ThesCodes"
520  AddSize 3020
521 SectionEnd
522
523 Section /o "Català" SecTCatalan
524  StrCpy $ThesCodes "ca_ES$ThesCodes"
525  AddSize 731
526 SectionEnd
527
528 Section /o "Ce\9atina" SecTCzech
529  StrCpy $ThesCodes "cs_CZ$ThesCodes"
530  AddSize 635
531 SectionEnd
532
533 Section /o "Dansk" SecTDanish
534  StrCpy $ThesCodes "da_DK$ThesCodes"
535  AddSize 2360
536 SectionEnd
537
538 Section /o "Deutsch (D/A)" SecTGermanDA
539  StrCpy $ThesCodes "de_DE$ThesCodes"
540  AddSize 5360
541 SectionEnd
542
543 Section /o "Deutsch (CH)" SecTGermanCH
544  StrCpy $ThesCodes "de_CH$ThesCodes"
545  AddSize 5360
546 SectionEnd
547
548 Section /o "English (GB)" SecTEnglishGB
549  StrCpy $ThesCodes "en_GB$ThesCodes"
550  AddSize 20600
551 SectionEnd
552
553 Section /o "English (US/AU)" SecTEnglishUSAU
554  StrCpy $ThesCodes "en_US$ThesCodes"
555  AddSize 20600
556 SectionEnd
557
558 Section /o "Español" SecTSpanish
559  StrCpy $ThesCodes "es_ES$ThesCodes"
560  AddSize 2860
561 SectionEnd
562
563 Section /o "Français" SecTFrench
564  StrCpy $ThesCodes "fr_FR$ThesCodes"
565  AddSize 5060
566 SectionEnd
567
568 Section /o "Gaeilge" SecTGaelic
569  StrCpy $ThesCodes "ga_IR$ThesCodes"
570  AddSize 30600
571 SectionEnd
572
573 Section /o "Greek" SecTGreek
574  StrCpy $ThesCodes "el_GR$ThesCodes"
575  AddSize 903
576 SectionEnd
577
578 Section /o "Italiano" SecTItalian
579  StrCpy $ThesCodes "it_IT$ThesCodes"
580  AddSize 2640
581 SectionEnd
582
583 Section /o "Magyar" SecTHungarian
584  StrCpy $ThesCodes "hu_HU$ThesCodes"
585  AddSize 632
586 SectionEnd
587
588 Section /o "Norsk" SecTNorwegian
589  StrCpy $ThesCodes "no_NO$ThesCodes"
590  AddSize 2470
591 SectionEnd
592
593 Section /o "Polski" SecTPolish
594  StrCpy $ThesCodes "pl_PL$ThesCodes"
595  AddSize 5580
596 SectionEnd
597
598 Section /o "Português" SecTPortuguese
599  StrCpy $ThesCodes "pt_PT$ThesCodes"
600  AddSize 855
601 SectionEnd
602
603 Section /o "Româna" SecTRomanian
604  StrCpy $ThesCodes "ro_RO$ThesCodes"
605  AddSize 3640
606 SectionEnd
607
608 Section /o "Russian" SecTRussian
609  StrCpy $ThesCodes "ru_RU$ThesCodes"
610  AddSize 2080
611 SectionEnd
612
613 Section /o "Sloven\9acina" SecTSlowenian
614  StrCpy $ThesCodes "sl_SI$ThesCodes"
615  AddSize 107
616 SectionEnd
617
618 Section /o "Slovenský" SecTSlowakian
619  StrCpy $ThesCodes "sk_SK$ThesCodes"
620  AddSize 907
621 SectionEnd
622
623 Section /o "Svenska" SecTSwedish
624  StrCpy $ThesCodes "sv_SE$ThesCodes"
625  AddSize 720
626 SectionEnd
627
628 SectionGroupEnd
629
630 # Section descriptions
631 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
632 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
633 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} "$(SecFileAssocDescription)"
634 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
635 !if ${SETUPTYPE} == BUNDLE
636  !insertmacro MUI_DESCRIPTION_TEXT ${SecInstJabRef} "$(SecInstJabRefDescription)"
637 !endif
638 !insertmacro MUI_FUNCTION_DESCRIPTION_END
639