]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/include/detection.nsh
installer: updates to dictionary handling
[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
34 FunctionEnd
35
36 # ---------------------------------------
37
38 Function MissingPrograms
39   # check if third-party programs are installed
40
41   # test if Ghostscript is installed
42   StrCpy $3 0
43   GSloop:
44   EnumRegKey $1 HKLM "Software\GPL Ghostscript" $3
45   ${if} $1 != ""
46    ReadRegStr $2 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPL Ghostscript $1" "DisplayName"
47    StrCpy $0 "Software\GPL Ghostscript\$1"
48    ${if} $2 == "" # if nothing was found in the uninstall section
49     ReadRegStr $2 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" # check if Ghostscript was installed together with LyX
50    ${endif}
51    ${if} $2 == "" # if nothing was found in the uninstall section
52     DeleteRegKey HKLM "$0"
53     goto GSloop
54    ${else}
55     ReadRegStr $GhostscriptPath HKLM $0 "GS_DLL"
56     ${if} $GhostscriptPath != ""
57      StrCpy $GhostscriptPath "$GhostscriptPath" -12 # remove ending "gsdll32.dll"
58     ${endif}
59     # there might be several versions installed and we want to use the newest one
60     IntOp $3 $3 + 1
61     goto GSloop
62    ${endif} # if $2
63   ${endif}
64
65   # test if Python is installed
66   # only use an existing python when it is version 2.5 or newer because some
67   # older Compaq and Dell PCs were delivered with outdated Python interpreters
68   # Python 3.x was reported not to work with LyX properly, see
69   # http://www.lyx.org/trac/ticket/7143
70   ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
71   ${if} $PythonPath == ""
72    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.6\InstallPath" ""
73   ${endif}
74   ${if} $PythonPath == ""
75    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.7\InstallPath" ""
76   ${endif}
77   ${if} $PythonPath != ""
78    StrCpy $PythonPath $PythonPath -1 # remove the "\" at the end
79    StrCpy $DelPythonFiles "True"
80   ${endif}
81   
82   # test if Acrobat or Adobe Reader is used as PDF-viewer
83   ReadRegStr $String HKCR ".pdf" ""
84   ${if} $String != "AcroExch.Document" # this name is only used by Acrobat and Adobe Reader
85    StrCpy $Acrobat "None"
86   ${else}
87    StrCpy $Acrobat "Yes"
88   ${endif}
89
90   # test if a PostScript-viewer is installed, only check for GSview32
91   StrCpy $PSVPath ""
92   ReadRegStr $PSVPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview32.exe" "Path"
93
94   # test if an editor with syntax-highlighting for LaTeX-files is installed
95   Call EditorCheck
96
97   # test if an image editor is installed
98   StrCpy $ImageEditorPath ""
99   ReadRegStr $ImageEditorPath HKLM "Software\Classes\GIMP-2.8-xcf\shell\open\command" ""
100   ${if} $ImageEditorPath != ""
101    StrCpy $ImageEditorPath "$ImageEditorPath" -19 # delete '\gimp-2.x.exe" "%1"'
102    StrCpy $ImageEditorPath $ImageEditorPath "" 1 # remove the leading quote
103   ${endif}
104   # check for Photoshop
105   ReadRegStr $0 HKLM "Software\Classes\Applications\Photoshop.exe\shell\open\command" ""
106   ${if} $0 != ""
107    StrCpy $0 "$0" -20 # delete '\photoshop.exe" "%1"'
108    StrCpy $0 $0 "" 1 # remove the leading quote
109    ${if} $ImageEditorPath != ""
110     StrCpy $ImageEditorPath "$ImageEditorPath;$0"
111    ${else}
112     StrCpy $ImageEditorPath $0
113    ${endif}
114   ${endif}
115   
116   # test if and where the BibTeX-editor JabRef is installed
117   ReadRegStr $PathBibTeXEditor HKCU "Software\JabRef" "Path"
118   ${if} $PathBibTeXEditor == ""
119    ReadRegStr $PathBibTeXEditor HKLM "Software\JabRef" "Path"
120   ${endif}
121
122   ${IfNot} ${FileExists} "$PathBibTeXEditor\${BIN_BIBTEXEDITOR}"
123     StrCpy $PathBibTeXEditor ""
124     StrCpy $JabRefInstalled == "No"
125   ${else}
126    StrCpy $JabRefInstalled == "Yes"
127   ${endif}
128   
129   # test if and where LilyPond is installed
130   ReadRegStr $LilyPondPath HKLM "Software\LilyPond" "Install_Dir"
131   ${if} $LilyPondPath != ""
132    StrCpy $LilyPondPath "$LilyPondPath\usr\bin" # add "\usr\bin"
133   ${endif}
134   
135   # test if Inkscape is installed
136   ReadRegStr $SVGPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Inkscape" "InstallLocation"
137   
138   # test if Gnumeric is installed
139   ReadRegStr $0 HKLM "Software\Classes\Applications\gnumeric.exe\shell\Open\command" ""
140   ${if} $0 != ""
141    StrCpy $0 $0 -18 # remove "gnumeric.exe" "%1""
142    StrCpy $0 $0 "" 1 # remove the leading quote
143    StrCpy $GnumericPath $0
144   ${endif}
145
146 FunctionEnd
147
148 # ---------------------------------------
149
150 Function FindDictionaries
151   # find the installed dictionaries
152
153   # start with empty strings
154   StrCpy $FoundDict ""
155   StrCpy $FoundThes ""
156   
157   # read out the possible spell-checker filenames from the file 
158   FileOpen $R5 "$INSTDIR\Resources\HunspellDictionaryNames.txt" r
159   ${for} $5 1 60
160    # the file has 120 lines, but we only need to check for one of the 2 dictionary files per language
161    # therefore check only for every second line
162    FileRead $R5 $String   # $String is now the dictionary name
163    FileRead $R5 $String   # $String is now the dictionary name
164    StrCpy $String $String -2 # remove the linebreak characters
165    StrCpy $R3 $String -4 # $R3 is now the dictionary language code
166    # we have 2 cases where we renamed the file to a 3 letter code, see thesaurus.nsh
167    ${if} $String == "db_DE.dic"
168     StrCpy $String "dsb_DE.dic"
169    ${endif}
170    ${if} $String == "hb_DE.dic"
171     StrCpy $String "hsb_DE.dic"
172    ${endif}
173    !insertmacro FileCheck $4 $String "$INSTDIR\Resources\dicts" # macro from LyXUtils.nsh
174    ${if} $4 == "True"
175     StrCpy $FoundDict "$R3 $FoundDict"
176    ${endif}
177   ${next}
178   FileClose $R5
179   
180   # read out the possible thesaurus filenames from the file     
181   FileOpen $R5 "$INSTDIR\Resources\ThesaurusDictionaryNames.txt" r
182   ${for} $5 1 22
183    # the file has 44 lines, but we only need to check for one of the 2 dictionary files per language
184    # therefore check only for every second line
185    FileRead $R5 $String   # $String is now the dictionary name
186    FileRead $R5 $String   # $String is now the dictionary name
187    StrCpy $String $String -2 # remove the linebreak characters
188    StrCpy $R3 $String 5 3 # $R3 is now the dictionary language code
189    !insertmacro FileCheck $4 $String "$INSTDIR\Resources\thes" # macro from LyXUtils.nsh
190    ${if} $4 == "True"
191     StrCpy $FoundThes "$R3 $FoundThes"
192    ${endif}
193   ${next}
194   FileClose $R5
195
196 FunctionEnd
197
198 # ---------------------------------------
199
200 Function EditorCheck
201   # test if an editor with syntax-highlighting for LaTeX-files is installed
202
203   # (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
204   StrCpy $EditorPath ""
205   StrCpy $0 ""
206   # check for jEdit
207   ReadRegStr $EditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\jEdit_is1" "InstallLocation"
208   ${if} $EditorPath != ""
209    StrCpy $EditorPath $EditorPath -1 # remove "\" from the end of the string
210   ${endif}
211   # check for PSPad
212   StrCpy $0 ""
213   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PSPad editor_is1" "InstallLocation"
214   ${if} $0 != ""
215    StrCpy $0 $0 -1
216    StrCpy $EditorPath "$EditorPath;$0"
217   ${endif}
218   # check for WinShell
219   StrCpy $0 ""
220   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinShell_is1" "InstallLocation"
221   ${if} $0 != ""
222    StrCpy $0 $0 -1
223    StrCpy $EditorPath "$EditorPath;$0"
224   ${endif}
225   # check for ConTEXT
226   StrCpy $0 ""
227   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ConTEXTEditor_is1" "InstallLocation"
228   ${if} $0 != ""
229    StrCpy $0 $0 -1
230    StrCpy $EditorPath "$EditorPath;$0"
231   ${endif}
232   # check for Crimson Editor
233   StrCpy $0 ""
234   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Crimson Editor" "UninstallString"
235   ${if} $0 != ""
236    StrCpy $0 $0 -14 # remove "\uninstall.exe"
237    StrCpy $EditorPath "$EditorPath;$0"
238   ${endif}
239   # check for Vim 6.x
240   StrCpy $0 ""
241   ReadRegStr $0 HKLM "Software\Classes\Applications\gvim.exe\shell\edit\command" ""
242   ${if} $0 != ""
243    StrCpy $0 $0 -13 # remove "gvim.exe "%1""
244    StrCpy $EditorPath "$EditorPath;$0"
245   ${endif}
246   # check for Vim 7.0
247   StrCpy $0 ""
248   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Vim 7.0" "UninstallString"
249   ${if} $0 != ""
250    StrCpy $0 $0 -18 # remove "\uninstall-gui.exe"
251    StrCpy $EditorPath "$EditorPath;$0"
252   ${endif}
253   # check for TeXnicCenter
254   StrCpy $0 ""
255   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "Inno Setup: App Path"
256   ${if} $0 != ""
257    StrCpy $EditorPath "$EditorPath;$0"
258   ${endif}
259   # check for LaTeXEditor
260   StrCpy $0 ""
261   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LaTeX Editor" "InstallLocation"
262   ${if} $0 != ""
263    StrCpy $EditorPath "$EditorPath;$0"
264   ${endif}
265   # check for WinEdt
266   StrCpy $0 ""
267   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinEdt_is1" "InstallLocation"
268   ${if} $0 != ""
269    StrCpy $0 $0 -1
270    StrCpy $EditorPath "$EditorPath;$0"
271   ${endif}
272   # check for LEd
273   StrCpy $0 ""
274   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LEd_is1" "InstallLocation"
275   ${if} $0 != ""
276    StrCpy $0 $0 -1
277    StrCpy $EditorPath "$EditorPath;$0"
278   ${endif}
279   # check for WinTeX
280   StrCpy $0 ""
281   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinTeX XP" "DisplayIcon"
282   ${if} $0 != ""
283    StrCpy $0 $0 -11 # remove "\wintex.exe"
284    StrCpy $EditorPath "$EditorPath;$0"
285   ${endif}
286
287 FunctionEnd