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