]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/installer/LyXWinInstaller/MissingPrograms.nsh
30b2e889722f1aa4f6ebe6a2052de8d714cf908b
[lyx.git] / development / Win32 / packaging / installer / LyXWinInstaller / MissingPrograms.nsh
1 Function MissingPrograms
2
3   StrCpy $MissedProg "False"
4
5   ; test if MiKTeX is installed
6   ; read the PATH variable via the registry because NSIS' "$%Path%" variable is not updated when the PATH changes
7   ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
8   StrCpy $Search "miktex"
9   Call LaTeXCheck ; sets the path to the latex.exe to $LatexPath ; function from LyXUtils.nsh
10   ; check if MiKTeX 2.4 or 2.5 is installed
11   StrCpy $String ""
12   ReadRegStr $String HKLM "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Install Root"
13   ${if} $String != ""
14    StrCpy $MiKTeXVersion "2.4" ; needed later for the configuration of MiKTeX
15    StrCpy $LaTeXName "MiKTeX 2.4"
16   ${endif}
17   
18   ${if} $LatexPath == "" ; check if MiKTeX is installed only for the current user
19    ; check for MiKTeX 2.5
20    ReadRegStr $String HKCU "Environment" "Path"
21    StrCpy $Search "miktex"
22    Call LaTeXCheck ; function from LyXUtils.nsh
23    ${if} $LatexPath != ""
24     StrCpy $MiKTeXUser "HKCU" ; needed later to for a message about MiKTeX's install folder write permissions, see InstallActions-*.nsh
25    ${endif}
26    ; check for MiKTeX 2.4
27    StrCpy $String ""
28    ReadRegStr $String HKCU "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Install Root"
29    ${if} $String != ""
30     StrCpy $MiKTeXVersion "2.4"
31     StrCpy $LaTeXName "MiKTeX 2.4"
32    ${endif}
33   ${endif}
34   
35   ${if} $LatexPath != ""
36    StrCpy $MiKTeXInstalled "yes"
37    ${if} $LaTeXName != "MiKTeX 2.4"
38     StrCpy $LaTeXName "MiKTeX 2.5"
39    ${endif} 
40   ${endif}
41
42   ; test if TeXLive is installed
43   ; as described at TeXLives' homepage there should be an entry in the PATH
44   ${if} $LatexPath == ""
45    ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
46    StrCpy $Search "TeXLive"
47    Call LaTeXCheck ; function from LyXUtils.nsh
48   ${endif}
49   ; check for the current user Path variable (the case when it is a live CD/DVD)
50   ${if} $LatexPath == ""
51    ReadRegStr $String HKCU "Environment" "Path"
52    StrCpy $Search "texlive"
53    StrCpy $2 "TeXLive"
54    Call LaTeXCheck ; function from LyXUtils.nsh
55   ${endif}
56   ; check if the variable TLroot exists (the case when it is installed using the program "tlpmgui")
57   ${if} $LatexPath == ""
58    ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "TLroot"
59    ${if} $String == ""
60     ReadRegStr $String HKCU "Environment" "TLroot" ; the case when installed without admin permissions
61    ${endif}
62    StrCpy $LatexPath "$String\bin\win32"
63    ; check if the latex.exe exists in the $LatexPath folder
64    !insertmacro FileCheck $5 "latex.exe" "$LatexPath" ; macro from LyXUtils.nsh
65    ${if} $5 == "False"
66     StrCpy $LatexPath ""
67    ${endif}
68   ${endif}
69   ${if} $LatexPath != ""
70   ${andif} $LaTeXName != "MiKTeX 2.4"
71   ${andif} $LaTeXName != "MiKTeX 2.5"
72    StrCpy $LaTeXName "TeXLive"
73   ${endif} 
74
75   ; test if Ghostscript is installed
76   GSloop:
77   EnumRegKey $1 HKLM "Software\AFPL Ghostscript" 0
78   ${if} $1 == ""
79    EnumRegKey $1 HKLM "Software\GPL Ghostscript" 0
80    ${if} $1 != ""
81     StrCpy $2 "True"
82    ${endif}
83   ${endif}
84   ${if} $1 != ""
85    ${if} $2 == "True"
86     ReadRegStr $3 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPL Ghostscript $1" "DisplayName"
87     StrCpy $0 "Software\GPL Ghostscript\$1"
88    ${else}
89     ReadRegStr $3 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AFPL Ghostscript $1" "DisplayName"
90     StrCpy $0 "Software\AFPL Ghostscript\$1"
91    ${endif}
92    ${if} $3 == "" ; if nothing was found in the uninstall section
93     ReadRegStr $3 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" ; check if Ghostscript was installed together with LyX
94    ${endif}
95    ${if} $3 == "" ; if nothing was found in the uninstall section
96     DeleteRegKey HKLM "$0"
97     goto GSloop
98    ${else}
99     ReadRegStr $GhostscriptPath HKLM $0 "GS_DLL"
100     ${if} $GhostscriptPath != ""
101      StrCpy $GhostscriptPath "$GhostscriptPath" -12 ; remove ending "gsdll32.dll"
102     ${else}
103      StrCpy $MissedProg "True"
104     ${endif}
105    ${endif} ; if $3
106   ${else} ; if $1
107    StrCpy $GhostscriptPath ""
108    StrCpy $MissedProg "True"
109   ${endif}
110
111   ; test if Imagemagick is installed
112   ReadRegStr $ImageMagickPath HKLM "Software\ImageMagick\Current" "BinPath"
113   ${if} $ImageMagickPath == ""
114    StrCpy $MissedProg "True"
115   ${endif}
116
117   ; test if Aiksaurus is installed
118   !insertmacro FileCheck $5 "meanings.dat" "${AiksaurusDir}" ; macro from LyXUtils.nsh
119   ${if} $5 == "True"
120    StrCpy $AiksaurusPath "${AiksaurusDir}"
121   ${endif}
122 ;  ReadRegStr $AiksaurusPath HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "AIK_DATA_DIR"
123
124   ; test if Aspell is installed
125   StrCpy $5 ""
126   ReadRegStr $5 HKCU "SOFTWARE\Aspell" "Base Path"
127   ${if} $5 == ""
128    ReadRegStr $5 HKLM "SOFTWARE\Aspell" "Base Path"
129    StrCpy $AspellBaseReg "HKLM" ; used in the aspell installation section
130   ${else}
131    StrCpy $AspellBaseReg "HKCU"
132   ${endif}
133   ${if} $5 == ""
134    StrCpy $MissedProg "True"
135   ${else}
136    StrCpy $AspellPath "$5"
137   ${endif}
138
139   ; test if Python is installed
140   ; only use an existing python when it is version 2.5 because many Compaq and Dell PC are delivered
141   ; with outdated Python interpreters
142   ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
143   ${if} $PythonPath != ""
144    StrCpy $0 $PythonPath "" -1 ; remove the "\" at the end
145    StrCpy $DelPythonFiles "True"
146   ${endif}
147
148   ; test if Acrobat or Adobe Reader is used as PDF-viewer
149   ReadRegStr $String HKCR ".pdf" ""
150   ${if} $String != "AcroExch.Document" ; this name is only used by Acrobat and Adobe Reader
151    StrCpy $Acrobat "None"
152   ${endif}
153   ${if} $Acrobat != "None"
154    ReadRegStr $String HKCR "AcroExch.Document\shell\open\command" ""
155    StrCpy $Search "8" ; search for Acrobat or Adobe Reader 8 because then PDFViewWin8.exe is needed to view PDF-files
156    !insertmacro StrPointer $String $Search $Pointer ; macro from LyXUtils
157    ${if} $Pointer == "-1" ; if nothing was found
158     StrCpy $Acrobat "7"
159    ${else}
160     StrCpy $Acrobat "8"
161    ${endif}
162   ${endif}
163
164   ; test if a PostScript-viewer is installed, only check for GSview32
165   StrCpy $PSVPath ""
166   ReadRegStr $PSVPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview32.exe" "Path"
167
168   ; test if an editor with syntax-highlighting for LaTeX-files is installed (function in LyXUtils.nsh)
169   Call EditorCheck ; function from LyXUtils.nsh
170
171   ; test if an image editor is installed (due to LyX's bug 2654 first check for GIMP)
172   StrCpy $ImageEditorPath ""
173   ReadRegStr $ImageEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinGimp-2.0_is1" "DisplayIcon"
174   ${if} $ImageEditorPath != ""
175    StrCpy $ImageEditorPath "$ImageEditorPath" -13 ; delete "\gimp-2.x.exe"
176   ${endif}
177   ; check for Photoshop
178   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\Photoshop.exe" "Path"
179   ${if} $0 != ""
180    StrCpy $0 "$0" -1 ; delete the last "\"
181    ${if} $ImageEditorPath != ""
182     StrCpy $ImageEditorPath "$ImageEditorPath;$0"
183    ${else}
184     StrCpy $ImageEditorPath $0
185    ${endif}
186   ${endif}
187
188   ; test if the BibTeX-editor JabRef is installed
189   StrCpy $BibTeXEditorPath ""
190   ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.1" "UninstallString"
191   ${if} $BibTeXEditorPath == ""
192    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.2" "UninstallString"
193   ${endif}
194
195 FunctionEnd
196
197 Function MissingProgramsPage
198
199   ; generate the installer page - re-read empty page first
200   StrCpy $0 "2"
201   !insertmacro MUI_INSTALLOPTIONS_EXTRACT "io_missing_progs.ini"
202   !insertmacro MUI_HEADER_TEXT "$(MissProgHeader)" ""
203   
204   ${if} $MissedProg == "False"
205    !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field 6" "Text" "$(MissProgMessage)"
206   ${else}
207    !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field 1" "Text" "$(MissProgCap)"
208    ${if} ${INSTALLER_VERSION} == "Complete"
209     ${if} $LatexPath == ""
210      !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgLatex)"
211      IntOp $0 $0 + 1
212     ${endif}
213    ${endif}
214    ${if} $GhostscriptPath == ""
215     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgGhostscript)"
216     IntOp $0 $0 + 1
217    ${endif}
218    ${if} $ImageMagickPath == ""
219     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgImageMagick)"
220     IntOp $0 $0 + 1
221    ${endif}
222    ${if} $AspellPath == ""
223     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgAspell)"
224    ${endif}
225   ${endif}
226   
227   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "io_missing_progs.ini"
228
229 FunctionEnd
230
231 Function MissingProgramsPage_LeaveFunction
232
233 FunctionEnd