]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/include/detection.nsh
installer: some simplifications
[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   ${if} ${RunningX64}
44    SetRegView 64
45   ${endif}
46   # case 1. and 3.
47   GSloop:
48   EnumRegKey $1 HKLM "Software\GPL Ghostscript" $3
49   ${if} $1 != ""
50    ReadRegStr $2 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPL Ghostscript $1" "DisplayName"
51    StrCpy $0 "Software\GPL Ghostscript\$1"
52    ${if} $2 == "" # if nothing was found in the uninstall section
53     ReadRegStr $2 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" # check if Ghostscript was installed together with LyX
54    ${endif}
55    ${if} $2 == "" # if nothing was found in the uninstall section
56     DeleteRegKey HKLM "$0"
57     goto GSloop
58    ${else}
59     ReadRegStr $GhostscriptPath HKLM $0 "GS_DLL"
60     ${if} $GhostscriptPath != ""
61      StrCpy $GhostscriptPath "$GhostscriptPath" -12 # remove ending "gsdll32.dll"
62     ${endif}
63     # there might be several versions installed and we want to use the newest one
64     IntOp $3 $3 + 1
65     goto GSloop
66    ${endif} # if $2
67   ${endif}
68   SetRegView 32
69   # repeat for case 2.
70   ${if} ${RunningX64}
71   ${andif} $GhostscriptPath == ""
72    StrCpy $3 0
73    # we have to assure that we only repeat once and not forever
74    ${if} $4 != "32"
75     StrCpy $4 "32"
76     goto GSloop
77    ${endif}
78   ${endif}
79
80   # test if Python is installed
81   # only use an existing python when it is version 2.5 or newer because some
82   # older Compaq and Dell PCs were delivered with outdated Python interpreters
83   # Python 3.x was reported not to work with LyX properly, see
84   # http://www.lyx.org/trac/ticket/7143
85   ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
86   ${if} $PythonPath == ""
87    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.6\InstallPath" ""
88   ${endif}
89   ${if} $PythonPath == ""
90    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.7\InstallPath" ""
91   ${endif}
92   ${if} $PythonPath != ""
93    StrCpy $PythonPath $PythonPath -1 # remove the "\" at the end
94    StrCpy $DelPythonFiles "True"
95   ${endif}
96   
97   # No test necessary for Acrobat or Adobe Reader because pdfview does this job
98   # each time it is called.
99   
100   # test if a PostScript-viewer is installed, only check for GSview
101   # check all cases:
102   # 1. 32bit Windows
103   # 2. 64bit Windows but 32bit GSview
104   # 3. 64bit Windows and 64bit GSview
105   ${if} ${RunningX64}
106    SetRegView 64
107    StrCpy $PSVPath ""
108    ReadRegStr $PSVPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview64.exe" "Path"
109    SetRegView 32
110   ${endif}
111   # repeat for case 1. and 2.
112   ${if} $PSVPath == ""
113    ReadRegStr $PSVPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview32.exe" "Path"
114   ${endif}
115
116   # test if an editor with syntax-highlighting for LaTeX-files is installed
117   Call EditorCheck
118
119   # test if an image editor is installed
120   StrCpy $ImageEditorPath ""
121   # first check for Gimp which is a 64bit application on x64 Windows
122   ${if} ${RunningX64}
123    SetRegView 64
124   ${endif}
125   ReadRegStr $ImageEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GIMP-2_is1" "InstallLocation"
126   ${if} $ImageEditorPath != ""
127    StrCpy $ImageEditorPath "$ImageEditorPathbin" # add the bin folder
128   ${endif}
129   ${if} ${RunningX64}
130    SetRegView 32
131   ${endif}
132   # check for Photoshop
133   ReadRegStr $0 HKLM "Software\Classes\Applications\Photoshop.exe\shell\open\command" ""
134   ${if} $0 != ""
135    StrCpy $0 "$0" -20 # delete '\photoshop.exe" "%1"'
136    StrCpy $0 $0 "" 1 # remove the leading quote
137    ${if} $ImageEditorPath != ""
138     StrCpy $ImageEditorPath "$ImageEditorPath;$0"
139    ${else}
140     StrCpy $ImageEditorPath $0
141    ${endif}
142   ${endif}
143   
144   # test if and where the BibTeX-editor JabRef is installed
145   ReadRegStr $PathBibTeXEditor HKCU "Software\JabRef" "Path"
146   ${if} $PathBibTeXEditor == ""
147    ReadRegStr $PathBibTeXEditor HKLM "Software\JabRef" "Path"
148   ${endif}
149
150   ${ifnot} ${FileExists} "$PathBibTeXEditor\${BIN_BIBTEXEDITOR}"
151    StrCpy $PathBibTeXEditor ""
152    StrCpy $JabRefInstalled == "No"
153   ${else}
154    StrCpy $JabRefInstalled == "Yes"
155   ${endif}
156   
157   # test if and where LilyPond is installed
158   ReadRegStr $LilyPondPath HKLM "Software\LilyPond" "Install_Dir"
159   ${if} $LilyPondPath != ""
160    StrCpy $LilyPondPath "$LilyPondPath\usr\bin" # add "\usr\bin"
161   ${endif}
162   
163   # test if Inkscape is installed
164   ReadRegStr $SVGPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Inkscape" "InstallLocation"
165   
166   # test if Gnumeric is installed
167   ReadRegStr $0 HKLM "Software\Classes\Applications\gnumeric.exe\shell\Open\command" ""
168   ${if} $0 != ""
169    StrCpy $0 $0 -18 # remove "gnumeric.exe" "%1""
170    StrCpy $0 $0 "" 1 # remove the leading quote
171    StrCpy $GnumericPath $0
172   ${endif}
173
174 FunctionEnd
175
176 # ---------------------------------------
177
178 Function EditorCheck
179   # test if an editor with syntax-highlighting for LaTeX-files is installed
180
181   # (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
182   StrCpy $EditorPath ""
183   StrCpy $0 ""
184   # check for jEdit which is a 64bit application on x64 Windows
185   ${if} ${RunningX64}
186    SetRegView 64
187   ${endif}
188   ReadRegStr $EditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\jEdit_is1" "InstallLocation"
189   ${if} $EditorPath != ""
190    StrCpy $EditorPath $EditorPath -1 # remove "\" from the end of the string
191   ${endif}
192   SetRegView 32
193   
194   # check for PSPad
195   StrCpy $0 ""
196   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PSPad editor_is1" "InstallLocation"
197   ${if} $0 != ""
198    StrCpy $0 $0 -1 # remove the "\"
199    StrCpy $EditorPath "$EditorPath;$0"
200   ${endif}
201   
202   # check for WinShell
203   StrCpy $0 ""
204   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinShell_is1" "InstallLocation"
205   ${if} $0 != ""
206    StrCpy $0 $0 -1 # remove the "\"
207    StrCpy $EditorPath "$EditorPath;$0"
208   ${endif}
209   
210   # check for Vim which is a 64bit application on x64 Windows
211   StrCpy $0 ""
212   ${if} ${RunningX64}
213    SetRegView 64
214   ${endif}
215   ReadRegStr $0 HKLM "Software\Vim\Gvim" "path"
216   ${if} $0 != ""
217    StrCpy $0 $0 -9 # remove "\gvim.exe"
218    StrCpy $EditorPath "$EditorPath;$0"
219   ${endif}
220   SetRegView 32
221   
222   # check for TeXnicCenter which can be a 64bit application on x64 Windows
223   StrCpy $0 ""
224   ${if} ${RunningX64}
225    SetRegView 64
226   ${endif}
227   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "InstallLocation"
228   ${if} $0 != ""
229    StrCpy $0 $0 -1 # remove the "\"
230    StrCpy $EditorPath "$EditorPath;$0"
231   ${else}
232    SetRegView 32
233    ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "InstallLocation"
234    ${if} $0 != ""
235     StrCpy $0 $0 -1 # remove the "\"
236     StrCpy $EditorPath "$EditorPath;$0"
237    ${endif}
238   ${endif}
239   SetRegView 32
240   
241   # check for WinEdt
242   StrCpy $0 ""
243   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinEdt 7" "InstallLocation"
244   ${if} $0 != ""
245    StrCpy $EditorPath "$EditorPath;$0"
246   ${endif}
247
248 FunctionEnd