]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/include/detection.nsh
Win installer: update to JabRef 3.x
[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 2.x is installed
160   ReadRegStr $PathBibTeXEditor HKCU "Software\JabRef" "Path"
161   ${if} $PathBibTeXEditor == ""
162    ReadRegStr $PathBibTeXEditor HKLM "Software\JabRef" "Path"
163   ${endif}
164   # since JabRef 3.x the pathes are different
165   # there is currently a bug in the Jabref installer that prevents to install it without admin permissions
166   # therefore only check the admin installation
167   ${if} $PathBibTeXEditor == ""
168    ReadRegStr $PathBibTeXEditor HKLM "SOFTWARE\Classes\JabRef\shell\open\command" ""
169    StrCpy $PathBibTeXEditor $PathBibTeXEditor -17 # remove '\JabRef.exe" "%1"'
170    StrCpy $PathBibTeXEditor $PathBibTeXEditor "" 1 # remove the leading quote
171   ${endif}
172   ${if} $PathBibTeXEditor == ""
173    # $Documents is the path to the documents folder of the current user (contains the user name)
174    StrCpy $PathBibTeXEditor $Documents -10 # remove '\Documents'
175    StrCpy $PathBibTeXEditor "$PathBibTeXEditor\JabRef"
176   ${endif}
177
178   ${ifnot} ${FileExists} "$PathBibTeXEditor\${BIN_BIBTEXEDITOR}"
179    StrCpy $PathBibTeXEditor ""
180    StrCpy $JabRefInstalled == "No"
181   ${else}
182    StrCpy $JabRefInstalled == "Yes"
183   ${endif}
184
185   # test if and where LilyPond is installed
186   ReadRegStr $LilyPondPath HKLM "Software\LilyPond" "Install_Dir"
187   ${if} $LilyPondPath != ""
188    StrCpy $LilyPondPath "$LilyPondPath\usr\bin" # add "\usr\bin"
189   ${endif}
190
191   # test if Inkscape is installed
192   ReadRegStr $SVGPath HKLM "SOFTWARE\Classes\inkscape.svg\DefaultIcon" ""
193   ${if} $SVGPath != ""
194    StrCpy $SVGPath $SVGPath "" 1 # remove the leading quote
195    StrCpy $SVGPath $SVGPath -14 # # delete '\inkscape.exe"'
196   ${endif}
197   ${if} $SVGPath == ""
198    # this was used before Inkscape 0.91:
199    ReadRegStr $SVGPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Inkscape" "InstallLocation"
200   ${endif}
201
202   # test if Gnumeric is installed
203   ReadRegStr $0 HKLM "Software\Classes\Applications\gnumeric.exe\shell\Open\command" ""
204   ${if} $0 != ""
205    StrCpy $0 $0 -18 # remove "gnumeric.exe" "%1""
206    StrCpy $0 $0 "" 1 # remove the leading quote
207    StrCpy $GnumericPath $0
208   ${endif}
209
210   # test if Pandoc is installed
211   # HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\John MacFarlane\Pandoc
212   ${if} ${RunningX64}
213    SetRegView 64 # the PATH is in the 64bit registry section
214   ${endif}
215   # check for the path to the pandoc.exe in Window's PATH variable
216   StrCpy $5 ""
217   StrCpy $Search "pandoc"
218   ReadRegStr $String HKCU "Environment" "PATH"
219   !insertmacro PATHCheck $5 "pandoc.exe" # macro from LyXUtils.nsh
220   # if it is not in the user-specific PATH it might be in the global PATH
221   ${if} $5 == "False"
222    ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
223    !insertmacro PATHCheck $5 "pandoc.exe" # macro from LyXUtils.nsh
224   ${endif}
225   SetRegView 32
226   ${if} $5 != "False"
227    StrCpy $PandocPath $5
228   ${endif}
229
230 FunctionEnd
231
232 # ---------------------------------------
233
234 Function EditorCheck
235   # test if an editor with syntax-highlighting for LaTeX-files is installed
236
237   # (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
238   StrCpy $EditorPath ""
239   StrCpy $0 ""
240   # check for jEdit which is a 64bit application on x64 Windows
241   ${if} ${RunningX64}
242    SetRegView 64
243   ${endif}
244   ReadRegStr $EditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\jEdit_is1" "InstallLocation"
245   ${if} $EditorPath != ""
246    StrCpy $EditorPath $EditorPath -1 # remove "\" from the end of the string
247   ${endif}
248   SetRegView 32
249   
250   # check for PSPad
251   StrCpy $0 ""
252   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PSPad editor_is1" "InstallLocation"
253   ${if} $0 != ""
254    StrCpy $0 $0 -1 # remove the "\"
255    StrCpy $EditorPath "$EditorPath;$0"
256   ${endif}
257   
258   # check for WinShell
259   StrCpy $0 ""
260   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinShell_is1" "InstallLocation"
261   ${if} $0 != ""
262    StrCpy $0 $0 -1 # remove the "\"
263    StrCpy $EditorPath "$EditorPath;$0"
264   ${endif}
265   
266   # check for Vim which is a 64bit application on x64 Windows
267   StrCpy $0 ""
268   ${if} ${RunningX64}
269    SetRegView 64
270   ${endif}
271   ReadRegStr $0 HKLM "Software\Vim\Gvim" "path"
272   ${if} $0 != ""
273    StrCpy $0 $0 -9 # remove "\gvim.exe"
274    StrCpy $EditorPath "$EditorPath;$0"
275   ${endif}
276   SetRegView 32
277   
278   # check for TeXnicCenter which can be a 64bit application on x64 Windows
279   StrCpy $0 ""
280   ${if} ${RunningX64}
281    SetRegView 64
282   ${endif}
283   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "InstallLocation"
284   ${if} $0 != ""
285    StrCpy $0 $0 -1 # remove the "\"
286    StrCpy $EditorPath "$EditorPath;$0"
287   ${else}
288    SetRegView 32
289    ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "InstallLocation"
290    ${if} $0 != ""
291     StrCpy $0 $0 -1 # remove the "\"
292     StrCpy $EditorPath "$EditorPath;$0"
293    ${endif}
294   ${endif}
295   SetRegView 32
296   
297   # check for WinEdt
298   StrCpy $0 ""
299   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinEdt 7" "InstallLocation"
300   ${if} $0 != ""
301    StrCpy $EditorPath "$EditorPath;$0"
302   ${endif}
303
304 FunctionEnd