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