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