]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/include/detection.nsh
installer:
[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 #
15 # - MissingPrograms, (check if third-party programs are installed), uses:
16 #    SEARCH_MIKTEX
17 #    SEARCH_TEXLIVE
18 #
19 # - EditorCheck,
20 #    (test if an editor with syntax-highlighting for LaTeX-files is installed)
21 #
22 #--------------------------
23
24 #Var ReportReturn
25 #Var CommandLineOutput
26
27 Function SearchExternal
28   Call LaTeXActions # function from LaTeX.nsh
29   Call MissingPrograms
30 FunctionEnd
31
32 # ---------------------------------------
33
34 Function MissingPrograms
35   # check if third-party programs are installed
36
37   # initialize variable, is later set to True when a program was not found
38   ${if} $MissedProg != "True" # is already True when LaTeX is missing
39    StrCpy $MissedProg "False"
40   ${endif}
41
42   # test if Ghostscript is installed
43   GSloop:
44   EnumRegKey $1 HKLM "Software\AFPL Ghostscript" 0
45   ${if} $1 == ""
46    EnumRegKey $1 HKLM "Software\GPL Ghostscript" 0
47    ${if} $1 != ""
48     StrCpy $2 "True"
49    ${endif}
50   ${endif}
51   ${if} $1 != ""
52    ${if} $2 == "True"
53     ReadRegStr $3 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPL Ghostscript $1" "DisplayName"
54     StrCpy $0 "Software\GPL Ghostscript\$1"
55    ${else}
56     ReadRegStr $3 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AFPL Ghostscript $1" "DisplayName"
57     StrCpy $0 "Software\AFPL Ghostscript\$1"
58    ${endif}
59    ${if} $3 == "" # if nothing was found in the uninstall section
60     ReadRegStr $3 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" # check if Ghostscript was installed together with LyX
61    ${endif}
62    ${if} $3 == "" # if nothing was found in the uninstall section
63     DeleteRegKey HKLM "$0"
64     goto GSloop
65    ${else}
66     ReadRegStr $GhostscriptPath HKLM $0 "GS_DLL"
67     ${if} $GhostscriptPath != ""
68      StrCpy $GhostscriptPath "$GhostscriptPath" -12 # remove ending "gsdll32.dll"
69     ${else}
70      StrCpy $MissedProg "True"
71     ${endif}
72    ${endif} # if $3
73   ${else} # if $1
74    StrCpy $GhostscriptPath ""
75    StrCpy $MissedProg "True"
76   ${endif}
77
78   # test if Imagemagick is installed
79   #ReadRegStr $ImageMagickPath HKLM "Software\ImageMagick\Current" "BinPath"
80   #${if} $ImageMagickPath == ""
81   # StrCpy $MissedProg "True"
82   #${endif}
83
84   # test if Python is installed
85   # only use an existing python when it is version 2.5 or newer because some
86   # older Compaq and Dell PCs were delivered with outdated Python interpreters
87   # Python 3.x was reported not to work with LyX properly, see
88   # http://www.lyx.org/trac/ticket/7143
89   ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
90   ${if} $PythonPath == ""
91    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.6\InstallPath" ""
92   ${endif}
93   ${if} $PythonPath == ""
94    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.7\InstallPath" ""
95   ${endif}
96   ${if} $PythonPath != ""
97    StrCpy $PythonPath $PythonPath -1 # remove the "\" at the end
98    StrCpy $DelPythonFiles "True"
99   ${endif}
100
101   # test if a PostScript-viewer is installed, only check for GSview32
102   StrCpy $PSVPath ""
103   ReadRegStr $PSVPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview32.exe" "Path"
104
105   # test if an editor with syntax-highlighting for LaTeX-files is installed
106   Call EditorCheck
107
108   # test if an image editor is installed (due to LyX's bug 2654 first check for GIMP)
109   StrCpy $ImageEditorPath ""
110   ReadRegStr $ImageEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinGimp-2.0_is1" "DisplayIcon"
111   ${if} $ImageEditorPath != ""
112    StrCpy $ImageEditorPath "$ImageEditorPath" -13 # delete "\gimp-2.x.exe"
113   ${endif}
114   # check for Photoshop
115   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\Photoshop.exe" "Path"
116   ${if} $0 != ""
117    StrCpy $0 "$0" -1 # delete the last "\"
118    ${if} $ImageEditorPath != ""
119     StrCpy $ImageEditorPath "$ImageEditorPath;$0"
120    ${else}
121     StrCpy $ImageEditorPath $0
122    ${endif}
123   ${endif}
124
125   # test if and where the BibTeX-editor JabRef is installed
126   ReadRegStr $PathBibTeXEditor HKCU "Software\JabRef" "Path"
127   ${if} $PathBibTeXEditor == ""
128    ReadRegStr $PathBibTeXEditor HKLM "Software\JabRef" "Path"
129   ${endif}
130
131   ${IfNot} ${FileExists} "$PathBibTeXEditor\${BIN_BIBTEXEDITOR}"
132     StrCpy $PathBibTeXEditor ""
133     StrCpy $JabRefInstalled == "No"
134   ${else}
135    StrCpy $JabRefInstalled == "Yes"
136   ${endif}
137   
138   # test if Inkscape is installed
139   ReadRegStr $SVGPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Inkscape" "InstallLocation"
140   
141   # test if metafile2eps is installed
142   ReadRegStr $WMFPath HKLM "Software\Microsoft\Windows NT\CurrentVersion\Print\Printers\Metafile to EPS Converter" "Name"
143
144 FunctionEnd
145
146 # ---------------------------------------
147
148 Function EditorCheck
149   # test if an editor with syntax-highlighting for LaTeX-files is installed
150
151   # (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
152   StrCpy $EditorPath ""
153   StrCpy $0 ""
154   # check for jEdit
155   ReadRegStr $EditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\jEdit_is1" "InstallLocation"
156   ${if} $EditorPath != ""
157    StrCpy $EditorPath $EditorPath -1 # remove "\" from the end of the string
158   ${endif}
159   # check for PSPad
160   StrCpy $0 ""
161   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PSPad editor_is1" "InstallLocation"
162   ${if} $0 != ""
163    StrCpy $0 $0 -1
164    StrCpy $EditorPath "$EditorPath;$0"
165   ${endif}
166   # check for WinShell
167   StrCpy $0 ""
168   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinShell_is1" "InstallLocation"
169   ${if} $0 != ""
170    StrCpy $0 $0 -1
171    StrCpy $EditorPath "$EditorPath;$0"
172   ${endif}
173   # check for ConTEXT
174   StrCpy $0 ""
175   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ConTEXTEditor_is1" "InstallLocation"
176   ${if} $0 != ""
177    StrCpy $0 $0 -1
178    StrCpy $EditorPath "$EditorPath;$0"
179   ${endif}
180   # check for Crimson Editor
181   StrCpy $0 ""
182   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Crimson Editor" "UninstallString"
183   ${if} $0 != ""
184    StrCpy $0 $0 -14 # remove "\uninstall.exe"
185    StrCpy $EditorPath "$EditorPath;$0"
186   ${endif}
187   # check for Vim 6.x
188   StrCpy $0 ""
189   ReadRegStr $0 HKLM "Software\Classes\Applications\gvim.exe\shell\edit\command" ""
190   ${if} $0 != ""
191    StrCpy $0 $0 -13 # remove "gvim.exe "%1""
192    StrCpy $EditorPath "$EditorPath;$0"
193   ${endif}
194   # check for Vim 7.0
195   StrCpy $0 ""
196   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Vim 7.0" "UninstallString"
197   ${if} $0 != ""
198    StrCpy $0 $0 -18 # remove "\uninstall-gui.exe"
199    StrCpy $EditorPath "$EditorPath;$0"
200   ${endif}
201   # check for TeXnicCenter
202   StrCpy $0 ""
203   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "Inno Setup: App Path"
204   ${if} $0 != ""
205    StrCpy $EditorPath "$EditorPath;$0"
206   ${endif}
207   # check for LaTeXEditor
208   StrCpy $0 ""
209   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LaTeX Editor" "InstallLocation"
210   ${if} $0 != ""
211    StrCpy $EditorPath "$EditorPath;$0"
212   ${endif}
213   # check for WinEdt
214   StrCpy $0 ""
215   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinEdt_is1" "InstallLocation"
216   ${if} $0 != ""
217    StrCpy $0 $0 -1
218    StrCpy $EditorPath "$EditorPath;$0"
219   ${endif}
220   # check for LEd
221   StrCpy $0 ""
222   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LEd_is1" "InstallLocation"
223   ${if} $0 != ""
224    StrCpy $0 $0 -1
225    StrCpy $EditorPath "$EditorPath;$0"
226   ${endif}
227   # check for WinTeX
228   StrCpy $0 ""
229   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinTeX XP" "DisplayIcon"
230   ${if} $0 != ""
231    StrCpy $0 $0 -11 # remove "\wintex.exe"
232    StrCpy $EditorPath "$EditorPath;$0"
233   ${endif}
234
235 FunctionEnd