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