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