]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/include/detection.nsh
Win installer: new version with Qt 5.6.1
[features.git] / development / Win32 / packaging / installer / include / detection.nsh
1 /*
2
3 detection.nsh
4
5 Detection of external component locations
6
7 */
8
9 # This script contains the following functions:
10 #
11 # - SearchExternal, calls the functions:
12 #    LaTeXActions
13 #    MissingPrograms
14 #    FindDictionaries
15 #
16 # - MissingPrograms, (check if third-party programs are installed), uses:
17 #    SEARCH_MIKTEX
18 #    SEARCH_TEXLIVE
19 #
20 # - FindDictionaries (finds installed spellcheck and thesaurus dictionaries)
21 #
22 # - EditorCheck,
23 #    (test if an editor with syntax-highlighting for LaTeX-files is installed)
24 #
25 #--------------------------
26
27 Function SearchExternal
28   Call LaTeXActions # function from LaTeX.nsh
29   Call MissingPrograms
30   Call FindDictionaries # function from dictionaries.nsh
31 FunctionEnd
32
33 # ---------------------------------------
34
35 Function MissingPrograms
36   # check if third-party programs are installed
37
38   # test if Ghostscript is installed, check all cases:
39   # 1. 32bit Windows
40   # 2. 64bit Windows but 32bit Ghostscript
41   # 3. 64bit Windows and 64bit Ghostscript
42   StrCpy $3 0
43   StrCpy $4 "0"
44   ${if} ${RunningX64}
45    SetRegView 64
46   ${endif}
47   # case 1. and 3.
48   GSloop:
49   EnumRegKey $1 HKLM "Software\GPL Ghostscript" $3
50   ${if} $1 != ""
51    ReadRegStr $2 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPL Ghostscript $1" "DisplayName"
52    StrCpy $0 "Software\GPL Ghostscript\$1"
53    ${if} $2 == "" # if nothing was found in the uninstall section
54     ReadRegStr $2 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" # check if Ghostscript was installed together with LyX
55    ${endif}
56    ${if} $2 == "" # if nothing was found in the uninstall section
57     DeleteRegKey HKLM "$0"
58     goto GSloop
59    ${else}
60     ReadRegStr $GhostscriptPath HKLM $0 "GS_DLL"
61     ${if} $GhostscriptPath != ""
62      StrCpy $GhostscriptPath "$GhostscriptPath" -12 # remove ending "gsdll32.dll"
63     ${endif}
64     # there might be several versions installed and we want to use the newest one
65     IntOp $3 $3 + 1
66     goto GSloop
67    ${endif} # if $2
68   ${endif}
69   SetRegView 32
70   # repeat for case 2.
71   ${if} ${RunningX64}
72   ${andif} $GhostscriptPath == ""
73    StrCpy $3 0
74    # we have to assure that we only repeat once and not forever
75    ${if} $4 != "32"
76     StrCpy $4 "32"
77     goto GSloop
78    ${endif}
79   ${endif}
80
81   # test if Python is installed
82   # only use an existing python when it is version 2.5 or newer because some
83   # older Compaq and Dell PCs were delivered with outdated Python interpreters
84   # Python 3.x was reported not to work with LyX properly, see
85   # http://www.lyx.org/trac/ticket/7143
86   ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
87   ${if} $PythonPath == ""
88    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.6\InstallPath" ""
89   ${endif}
90   ${if} $PythonPath == ""
91    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.7\InstallPath" ""
92   ${endif}
93   ${if} $PythonPath != ""
94    StrCpy $PythonPath $PythonPath -1 # remove the "\" at the end
95    StrCpy $DelPythonFiles "True"
96   ${endif}
97   
98   # No test necessary for Acrobat or Adobe Reader because pdfview does this job
99   # each time it is called.
100   
101   # test if a PostScript-viewer is installed, only check for GSview
102   # check all cases:
103   # 1. 32bit Windows
104   # 2. 64bit Windows but 32bit GSview
105   # 3. 64bit Windows and 64bit GSview
106   ${if} ${RunningX64}
107    SetRegView 64
108    StrCpy $PSVPath ""
109    ReadRegStr $PSVPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview64.exe" "Path"
110    SetRegView 32
111   ${endif}
112   # repeat for case 1. and 2.
113   ${if} $PSVPath == ""
114    ReadRegStr $PSVPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview32.exe" "Path"
115   ${endif}
116
117   # test if an editor with syntax-highlighting for LaTeX-files is installed
118   Call EditorCheck
119
120   # test if an image editor is installed
121   StrCpy $ImageEditorPath ""
122   # first check for Gimp which is a 64bit application on x64 Windows
123   ${if} ${RunningX64}
124    SetRegView 64
125   ${endif}
126   ReadRegStr $ImageEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GIMP-2_is1" "InstallLocation"
127   ${if} $ImageEditorPath != ""
128    StrCpy $ImageEditorPath "$ImageEditorPathbin" # add the bin folder
129    StrCpy $ImageEditor "Gimp"
130   ${endif}
131   ${if} ${RunningX64}
132    SetRegView 32
133   ${endif}
134   # check for Photoshop
135   ReadRegStr $0 HKLM "Software\Classes\Applications\Photoshop.exe\shell\open\command" ""
136   ${if} $0 != ""
137    StrCpy $0 "$0" -20 # delete '\photoshop.exe" "%1"'
138    StrCpy $0 $0 "" 1 # remove the leading quote
139    ${if} $ImageEditorPath != ""
140     StrCpy $ImageEditorPath "$ImageEditorPath;$0"
141    ${else}
142     StrCpy $ImageEditorPath $0
143    ${endif}
144    StrCpy $ImageEditor "Photoshop"
145   ${endif}
146   # check for Krita
147   ReadRegStr $0 HKLM "SOFTWARE\Classes\Krita.Document\shell\open\command" ""
148   ${if} $0 != ""
149    StrCpy $0 "$0" -16 # delete '\krita.exe" "%1"'
150    StrCpy $0 $0 "" 1 # remove the leading quote
151    ${if} $ImageEditorPath != ""
152     StrCpy $ImageEditorPath "$ImageEditorPath;$0"
153    ${else}
154     StrCpy $ImageEditorPath $0
155    ${endif}
156    StrCpy $ImageEditor "Krita"
157   ${endif}
158
159   # test if and where the BibTeX-editor JabRef is installed
160   ReadRegStr $PathBibTeXEditor HKLM "Software\JabRef" "Path"
161   ${if} $PathBibTeXEditor == ""
162    ReadRegStr $PathBibTeXEditor HKCU "Software\JabRef" "Path"
163   ${endif}
164
165   ${ifnot} ${FileExists} "$PathBibTeXEditor\${BIN_BIBTEXEDITOR}"
166    StrCpy $PathBibTeXEditor ""
167    StrCpy $JabRefInstalled == "No"
168   ${else}
169    StrCpy $JabRefInstalled == "Yes"
170   ${endif}
171
172   # test if and where LilyPond is installed
173   ReadRegStr $LilyPondPath HKLM "Software\LilyPond" "Install_Dir"
174   ${if} $LilyPondPath != ""
175    StrCpy $LilyPondPath "$LilyPondPath\usr\bin" # add "\usr\bin"
176   ${endif}
177
178   # test if Inkscape is installed
179   ReadRegStr $SVGPath HKLM "SOFTWARE\Classes\inkscape.svg\DefaultIcon" ""
180   ${if} $SVGPath != ""
181    StrCpy $SVGPath $SVGPath "" 1 # remove the leading quote
182    StrCpy $SVGPath $SVGPath -14 # # delete '\inkscape.exe"'
183   ${endif}
184   ${if} $SVGPath == ""
185    # this was used before Inkscape 0.91:
186    ReadRegStr $SVGPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Inkscape" "InstallLocation"
187   ${endif}
188
189   # test if Gnumeric is installed
190   ReadRegStr $0 HKLM "Software\Classes\Applications\gnumeric.exe\shell\Open\command" ""
191   ${if} $0 != ""
192    StrCpy $0 $0 -18 # remove "gnumeric.exe" "%1""
193    StrCpy $0 $0 "" 1 # remove the leading quote
194    StrCpy $GnumericPath $0
195   ${endif}
196
197   # test if Pandoc is installed
198   # HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\John MacFarlane\Pandoc
199   ${if} ${RunningX64}
200    SetRegView 64 # the PATH is in the 64bit registry section
201   ${endif}
202   # check for the path to the pandoc.exe in Window's PATH variable
203   StrCpy $5 ""
204   StrCpy $Search "pandoc"
205   ReadRegStr $String HKCU "Environment" "PATH"
206   !insertmacro PATHCheck $5 "pandoc.exe" # macro from LyXUtils.nsh
207   # if it is not in the user-specific PATH it might be in the global PATH
208   ${if} $5 == "False"
209    ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
210    !insertmacro PATHCheck $5 "pandoc.exe" # macro from LyXUtils.nsh
211   ${endif}
212   SetRegView 32
213   ${if} $5 != "False"
214    StrCpy $PandocPath $5
215   ${endif}
216
217 FunctionEnd
218
219 # ---------------------------------------
220
221 Function EditorCheck
222   # test if an editor with syntax-highlighting for LaTeX-files is installed
223
224   # (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
225   StrCpy $EditorPath ""
226   StrCpy $0 ""
227   # check for jEdit which is a 64bit application on x64 Windows
228   ${if} ${RunningX64}
229    SetRegView 64
230   ${endif}
231   ReadRegStr $EditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\jEdit_is1" "InstallLocation"
232   ${if} $EditorPath != ""
233    StrCpy $EditorPath $EditorPath -1 # remove "\" from the end of the string
234   ${endif}
235   SetRegView 32
236   
237   # check for PSPad
238   StrCpy $0 ""
239   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PSPad editor_is1" "InstallLocation"
240   ${if} $0 != ""
241    StrCpy $0 $0 -1 # remove the "\"
242    StrCpy $EditorPath "$EditorPath;$0"
243   ${endif}
244   
245   # check for WinShell
246   StrCpy $0 ""
247   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinShell_is1" "InstallLocation"
248   ${if} $0 != ""
249    StrCpy $0 $0 -1 # remove the "\"
250    StrCpy $EditorPath "$EditorPath;$0"
251   ${endif}
252   
253   # check for Vim which is a 64bit application on x64 Windows
254   StrCpy $0 ""
255   ${if} ${RunningX64}
256    SetRegView 64
257   ${endif}
258   ReadRegStr $0 HKLM "Software\Vim\Gvim" "path"
259   ${if} $0 != ""
260    StrCpy $0 $0 -9 # remove "\gvim.exe"
261    StrCpy $EditorPath "$EditorPath;$0"
262   ${endif}
263   SetRegView 32
264   
265   # check for TeXnicCenter which can be a 64bit application on x64 Windows
266   StrCpy $0 ""
267   ${if} ${RunningX64}
268    SetRegView 64
269   ${endif}
270   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "InstallLocation"
271   ${if} $0 != ""
272    StrCpy $0 $0 -1 # remove the "\"
273    StrCpy $EditorPath "$EditorPath;$0"
274   ${else}
275    SetRegView 32
276    ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "InstallLocation"
277    ${if} $0 != ""
278     StrCpy $0 $0 -1 # remove the "\"
279     StrCpy $EditorPath "$EditorPath;$0"
280    ${endif}
281   ${endif}
282   SetRegView 32
283   
284   # check for WinEdt
285   StrCpy $0 ""
286   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinEdt 7" "InstallLocation"
287   ${if} $0 != ""
288    StrCpy $EditorPath "$EditorPath;$0"
289   ${endif}
290
291 FunctionEnd