]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/include/detection.nsh
b0d4be742fba299920941d403e16420490a23216
[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   ${endif}
130   ${if} ${RunningX64}
131    SetRegView 32
132   ${endif}
133   # check for Photoshop
134   ReadRegStr $0 HKLM "Software\Classes\Applications\Photoshop.exe\shell\open\command" ""
135   ${if} $0 != ""
136    StrCpy $0 "$0" -20 # delete '\photoshop.exe" "%1"'
137    StrCpy $0 $0 "" 1 # remove the leading quote
138    ${if} $ImageEditorPath != ""
139     StrCpy $ImageEditorPath "$ImageEditorPath;$0"
140    ${else}
141     StrCpy $ImageEditorPath $0
142    ${endif}
143   ${endif}
144   
145   # test if and where the BibTeX-editor JabRef is installed
146   ReadRegStr $PathBibTeXEditor HKCU "Software\JabRef" "Path"
147   ${if} $PathBibTeXEditor == ""
148    ReadRegStr $PathBibTeXEditor HKLM "Software\JabRef" "Path"
149   ${endif}
150
151   ${ifnot} ${FileExists} "$PathBibTeXEditor\${BIN_BIBTEXEDITOR}"
152    StrCpy $PathBibTeXEditor ""
153    StrCpy $JabRefInstalled == "No"
154   ${else}
155    StrCpy $JabRefInstalled == "Yes"
156   ${endif}
157   
158   # test if and where LilyPond is installed
159   ReadRegStr $LilyPondPath HKLM "Software\LilyPond" "Install_Dir"
160   ${if} $LilyPondPath != ""
161    StrCpy $LilyPondPath "$LilyPondPath\usr\bin" # add "\usr\bin"
162   ${endif}
163   
164   # test if Inkscape is installed
165   ReadRegStr $SVGPath HKLM "SOFTWARE\Classes\inkscape.svg\DefaultIcon" ""
166   ${if} $SVGPath != ""
167    StrCpy $SVGPath $SVGPath "" 1 # remove the leading quote
168    StrCpy $SVGPath $SVGPath -14 # # delete '\inkscape.exe"'
169   ${endif}
170   ${if} $SVGPath == ""
171    # this was used before Inkscape 0.91:
172    ReadRegStr $SVGPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Inkscape" "InstallLocation"
173   ${endif}
174
175   # test if Gnumeric is installed
176   ReadRegStr $0 HKLM "Software\Classes\Applications\gnumeric.exe\shell\Open\command" ""
177   ${if} $0 != ""
178    StrCpy $0 $0 -18 # remove "gnumeric.exe" "%1""
179    StrCpy $0 $0 "" 1 # remove the leading quote
180    StrCpy $GnumericPath $0
181   ${endif}
182
183 FunctionEnd
184
185 # ---------------------------------------
186
187 Function EditorCheck
188   # test if an editor with syntax-highlighting for LaTeX-files is installed
189
190   # (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
191   StrCpy $EditorPath ""
192   StrCpy $0 ""
193   # check for jEdit which is a 64bit application on x64 Windows
194   ${if} ${RunningX64}
195    SetRegView 64
196   ${endif}
197   ReadRegStr $EditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\jEdit_is1" "InstallLocation"
198   ${if} $EditorPath != ""
199    StrCpy $EditorPath $EditorPath -1 # remove "\" from the end of the string
200   ${endif}
201   SetRegView 32
202   
203   # check for PSPad
204   StrCpy $0 ""
205   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PSPad editor_is1" "InstallLocation"
206   ${if} $0 != ""
207    StrCpy $0 $0 -1 # remove the "\"
208    StrCpy $EditorPath "$EditorPath;$0"
209   ${endif}
210   
211   # check for WinShell
212   StrCpy $0 ""
213   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinShell_is1" "InstallLocation"
214   ${if} $0 != ""
215    StrCpy $0 $0 -1 # remove the "\"
216    StrCpy $EditorPath "$EditorPath;$0"
217   ${endif}
218   
219   # check for Vim which is a 64bit application on x64 Windows
220   StrCpy $0 ""
221   ${if} ${RunningX64}
222    SetRegView 64
223   ${endif}
224   ReadRegStr $0 HKLM "Software\Vim\Gvim" "path"
225   ${if} $0 != ""
226    StrCpy $0 $0 -9 # remove "\gvim.exe"
227    StrCpy $EditorPath "$EditorPath;$0"
228   ${endif}
229   SetRegView 32
230   
231   # check for TeXnicCenter which can be a 64bit application on x64 Windows
232   StrCpy $0 ""
233   ${if} ${RunningX64}
234    SetRegView 64
235   ${endif}
236   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "InstallLocation"
237   ${if} $0 != ""
238    StrCpy $0 $0 -1 # remove the "\"
239    StrCpy $EditorPath "$EditorPath;$0"
240   ${else}
241    SetRegView 32
242    ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "InstallLocation"
243    ${if} $0 != ""
244     StrCpy $0 $0 -1 # remove the "\"
245     StrCpy $EditorPath "$EditorPath;$0"
246    ${endif}
247   ${endif}
248   SetRegView 32
249   
250   # check for WinEdt
251   StrCpy $0 ""
252   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinEdt 7" "InstallLocation"
253   ${if} $0 != ""
254    StrCpy $EditorPath "$EditorPath;$0"
255   ${endif}
256
257 FunctionEnd