]> 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   # 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 $0 $0 "" 1 # remove the leading quote
140    StrCpy $GnumericPath $0
141   ${endif}
142
143 FunctionEnd
144
145 # ---------------------------------------
146
147 Function EditorCheck
148   # test if an editor with syntax-highlighting for LaTeX-files is installed
149
150   # (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
151   StrCpy $EditorPath ""
152   StrCpy $0 ""
153   # check for jEdit
154   ReadRegStr $EditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\jEdit_is1" "InstallLocation"
155   ${if} $EditorPath != ""
156    StrCpy $EditorPath $EditorPath -1 # remove "\" from the end of the string
157   ${endif}
158   # check for PSPad
159   StrCpy $0 ""
160   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PSPad editor_is1" "InstallLocation"
161   ${if} $0 != ""
162    StrCpy $0 $0 -1
163    StrCpy $EditorPath "$EditorPath;$0"
164   ${endif}
165   # check for WinShell
166   StrCpy $0 ""
167   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinShell_is1" "InstallLocation"
168   ${if} $0 != ""
169    StrCpy $0 $0 -1
170    StrCpy $EditorPath "$EditorPath;$0"
171   ${endif}
172   # check for ConTEXT
173   StrCpy $0 ""
174   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ConTEXTEditor_is1" "InstallLocation"
175   ${if} $0 != ""
176    StrCpy $0 $0 -1
177    StrCpy $EditorPath "$EditorPath;$0"
178   ${endif}
179   # check for Crimson Editor
180   StrCpy $0 ""
181   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Crimson Editor" "UninstallString"
182   ${if} $0 != ""
183    StrCpy $0 $0 -14 # remove "\uninstall.exe"
184    StrCpy $EditorPath "$EditorPath;$0"
185   ${endif}
186   # check for Vim 6.x
187   StrCpy $0 ""
188   ReadRegStr $0 HKLM "Software\Classes\Applications\gvim.exe\shell\edit\command" ""
189   ${if} $0 != ""
190    StrCpy $0 $0 -13 # remove "gvim.exe "%1""
191    StrCpy $EditorPath "$EditorPath;$0"
192   ${endif}
193   # check for Vim 7.0
194   StrCpy $0 ""
195   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Vim 7.0" "UninstallString"
196   ${if} $0 != ""
197    StrCpy $0 $0 -18 # remove "\uninstall-gui.exe"
198    StrCpy $EditorPath "$EditorPath;$0"
199   ${endif}
200   # check for TeXnicCenter
201   StrCpy $0 ""
202   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "Inno Setup: App Path"
203   ${if} $0 != ""
204    StrCpy $EditorPath "$EditorPath;$0"
205   ${endif}
206   # check for LaTeXEditor
207   StrCpy $0 ""
208   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LaTeX Editor" "InstallLocation"
209   ${if} $0 != ""
210    StrCpy $EditorPath "$EditorPath;$0"
211   ${endif}
212   # check for WinEdt
213   StrCpy $0 ""
214   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinEdt_is1" "InstallLocation"
215   ${if} $0 != ""
216    StrCpy $0 $0 -1
217    StrCpy $EditorPath "$EditorPath;$0"
218   ${endif}
219   # check for LEd
220   StrCpy $0 ""
221   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LEd_is1" "InstallLocation"
222   ${if} $0 != ""
223    StrCpy $0 $0 -1
224    StrCpy $EditorPath "$EditorPath;$0"
225   ${endif}
226   # check for WinTeX
227   StrCpy $0 ""
228   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinTeX XP" "DisplayIcon"
229   ${if} $0 != ""
230    StrCpy $0 $0 -11 # remove "\wintex.exe"
231    StrCpy $EditorPath "$EditorPath;$0"
232   ${endif}
233
234 FunctionEnd