]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/AltInstaller/MissingPrograms.nsh
Make sure that undo is recorded when magic tricks are played with InsetBibitem.
[lyx.git] / development / Win32 / packaging / AltInstaller / MissingPrograms.nsh
1 # This script contains the following functions:
2 #
3 # - MissingPrograms, (check if third-party programs are installed), uses:
4 #    EditorCheck
5 #    FileCheck
6 #
7 # - MissingProgramsPage,
8 #    (generate the page showing the missing programs that will be installed)
9 #
10 # - EditorCheck,
11 #    (test if an editor with syntax-highlighting for LaTeX-files is installed)
12 #
13 #--------------------------
14
15 Function MissingPrograms
16   # check if third-party programs are installed
17
18   # initialize variable, is later set to True when a program was not found
19   ${if} $MissedProg != "True" # is already True when LaTeX is missing
20    StrCpy $MissedProg "False"
21   ${endif}
22
23   # test if Ghostscript is installed
24   GSloop:
25   EnumRegKey $1 HKLM "Software\AFPL Ghostscript" 0
26   ${if} $1 == ""
27    EnumRegKey $1 HKLM "Software\GPL Ghostscript" 0
28    ${if} $1 != ""
29     StrCpy $2 "True"
30    ${endif}
31   ${endif}
32   ${if} $1 != ""
33    ${if} $2 == "True"
34     ReadRegStr $3 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPL Ghostscript $1" "DisplayName"
35     StrCpy $0 "Software\GPL Ghostscript\$1"
36    ${else}
37     ReadRegStr $3 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AFPL Ghostscript $1" "DisplayName"
38     StrCpy $0 "Software\AFPL Ghostscript\$1"
39    ${endif}
40    ${if} $3 == "" # if nothing was found in the uninstall section
41     ReadRegStr $3 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" # check if Ghostscript was installed together with LyX
42    ${endif}
43    ${if} $3 == "" # if nothing was found in the uninstall section
44     DeleteRegKey HKLM "$0"
45     goto GSloop
46    ${else}
47     ReadRegStr $GhostscriptPath HKLM $0 "GS_DLL"
48     ${if} $GhostscriptPath != ""
49      StrCpy $GhostscriptPath "$GhostscriptPath" -12 # remove ending "gsdll32.dll"
50     ${else}
51      StrCpy $MissedProg "True"
52     ${endif}
53    ${endif} # if $3
54   ${else} # if $1
55    StrCpy $GhostscriptPath ""
56    StrCpy $MissedProg "True"
57   ${endif}
58
59   # test if Imagemagick is installed
60   ReadRegStr $ImageMagickPath HKLM "Software\ImageMagick\Current" "BinPath"
61   ${if} $ImageMagickPath == ""
62    StrCpy $MissedProg "True"
63   ${endif}
64
65   # test if Aiksaurus is installed
66   !insertmacro FileCheck $5 "meanings.dat" "${AiksaurusDir}" # macro from LyXUtils.nsh
67   ${if} $5 == "True"
68    StrCpy $AiksaurusPath "${AiksaurusDir}"
69   ${endif}
70 #  ReadRegStr $AiksaurusPath HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "AIK_DATA_DIR"
71
72   # test if Aspell is installed
73   StrCpy $5 ""
74   ReadRegStr $5 HKCU "SOFTWARE\Aspell" "Base Path"
75   ${if} $5 == ""
76    ReadRegStr $5 HKLM "SOFTWARE\Aspell" "Base Path"
77    StrCpy $AspellBaseReg "HKLM" # used in the aspell installation section
78   ${else}
79    StrCpy $AspellBaseReg "HKCU"
80   ${endif}
81   ${if} $5 == ""
82    StrCpy $MissedProg "True"
83   ${else}
84    StrCpy $AspellPath "$5"
85   ${endif}
86
87   # test if Python is installed
88   # only use an existing python when it is version 2.5 or newer because some
89   # older Compaq and Dell PCs were delivered with outdated Python interpreters
90   # Python 3.x was reported not to work with LyX properly, see
91   # http://www.lyx.org/trac/ticket/7143
92   ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
93   ${if} $PythonPath == ""
94    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.6\InstallPath" ""
95   ${endif}
96   ${if} $PythonPath == ""
97    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.7\InstallPath" ""
98   ${endif}
99   ${if} $PythonPath != ""
100    StrCpy $PythonPath $PythonPath -1 # remove the "\" at the end
101    StrCpy $DelPythonFiles "True"
102   ${endif}
103
104   # test if Acrobat or Adobe Reader is used as PDF-viewer
105   ReadRegStr $String HKCR ".pdf" ""
106   ${if} $String != "AcroExch.Document" # this name is only used by Acrobat and Adobe Reader
107    StrCpy $Acrobat "None"
108   ${else}
109    StrCpy $Acrobat "Yes"
110   ${endif}
111
112   # test if a PostScript-viewer is installed, only check for GSview32
113   StrCpy $PSVPath ""
114   ReadRegStr $PSVPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview32.exe" "Path"
115
116   # test if an editor with syntax-highlighting for LaTeX-files is installed
117   Call EditorCheck
118
119   # test if an image editor is installed (due to LyX's bug 2654 first check for GIMP)
120   StrCpy $ImageEditorPath ""
121   ReadRegStr $ImageEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinGimp-2.0_is1" "DisplayIcon"
122   ${if} $ImageEditorPath != ""
123    StrCpy $ImageEditorPath "$ImageEditorPath" -13 # delete "\gimp-2.x.exe"
124   ${endif}
125   # check for Photoshop
126   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\Photoshop.exe" "Path"
127   ${if} $0 != ""
128    StrCpy $0 "$0" -1 # delete the last "\"
129    ${if} $ImageEditorPath != ""
130     StrCpy $ImageEditorPath "$ImageEditorPath;$0"
131    ${else}
132     StrCpy $ImageEditorPath $0
133    ${endif}
134   ${endif}
135
136   # test if the BibTeX-editor JabRef is installed
137   StrCpy $BibTeXEditorPath ""
138   ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.3" "UninstallString"
139   ${if} $BibTeXEditorPath == ""
140    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.3.1" "UninstallString"
141   ${endif}
142   ${if} $BibTeXEditorPath == ""
143    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.4" "UninstallString"
144   ${endif}
145   ${if} $BibTeXEditorPath == ""
146    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.4.1" "UninstallString"
147   ${endif}
148   ${if} $BibTeXEditorPath == ""
149    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.4.2" "UninstallString"
150   ${endif}
151   ${if} $BibTeXEditorPath == ""
152    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.5" "UninstallString"
153   ${endif}
154   ${if} $BibTeXEditorPath == ""
155    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.6" "UninstallString"
156   ${endif}
157   
158   # test if Inkscape is installed
159   ReadRegStr $SVGPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Inkscape" "InstallLocation"
160   
161   # test if metafile2eps is installed
162   ReadRegStr $WMFPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Metafile to EPS Converter" "InstallLocation"
163
164 FunctionEnd
165
166 # ---------------------------------------
167
168 Function MissingProgramsPage
169   # generate the page showing the missing programs that will be installed
170
171   StrCpy $0 "2" # start value for the dynamical item numbering
172   !insertmacro MUI_INSTALLOPTIONS_EXTRACT "io_missing_progs.ini"
173   !insertmacro MUI_HEADER_TEXT "$(MissProgHeader)" ""
174   
175   ${if} $MissedProg == "False"
176    !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field 6" "Text" "$(MissProgMessage)"
177   ${else}
178    !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field 1" "Text" "$(MissProgCap)"
179    ${if} ${INSTALLER_VERSION} == "Complete"
180     ${if} $LatexPath == ""
181      !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgLatex)"
182      IntOp $0 $0 + 1
183     ${endif}
184    ${endif}
185    ${if} $GhostscriptPath == ""
186     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgGhostscript)"
187     IntOp $0 $0 + 1
188    ${endif}
189    ${if} $ImageMagickPath == ""
190     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgImageMagick)"
191     IntOp $0 $0 + 1
192    ${endif}
193    ${if} $AspellPath == ""
194     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgAspell)"
195    ${endif}
196   ${endif}
197   
198   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "io_missing_progs.ini"
199
200 FunctionEnd
201
202 # ---------------------------------------
203
204 Function MissingProgramsPage_LeaveFunction
205
206  # this empty function is needed for the installer page
207
208 FunctionEnd
209
210 # ---------------------------------------
211
212 Function EditorCheck
213   # test if an editor with syntax-highlighting for LaTeX-files is installed
214
215   # (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
216   StrCpy $EditorPath ""
217   StrCpy $0 ""
218   # check for jEdit
219   ReadRegStr $EditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\jEdit_is1" "InstallLocation"
220   ${if} $EditorPath != ""
221    StrCpy $EditorPath $EditorPath -1 # remove "\" from the end of the string
222   ${endif}
223   # check for PSPad
224   StrCpy $0 ""
225   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PSPad editor_is1" "InstallLocation"
226   ${if} $0 != ""
227    StrCpy $0 $0 -1
228    StrCpy $EditorPath "$EditorPath;$0"
229   ${endif}
230   # check for WinShell
231   StrCpy $0 ""
232   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinShell_is1" "InstallLocation"
233   ${if} $0 != ""
234    StrCpy $0 $0 -1
235    StrCpy $EditorPath "$EditorPath;$0"
236   ${endif}
237   # check for ConTEXT
238   StrCpy $0 ""
239   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ConTEXTEditor_is1" "InstallLocation"
240   ${if} $0 != ""
241    StrCpy $0 $0 -1
242    StrCpy $EditorPath "$EditorPath;$0"
243   ${endif}
244   # check for Crimson Editor
245   StrCpy $0 ""
246   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Crimson Editor" "UninstallString"
247   ${if} $0 != ""
248    StrCpy $0 $0 -14 # remove "\uninstall.exe"
249    StrCpy $EditorPath "$EditorPath;$0"
250   ${endif}
251   # check for Vim 6.x
252   StrCpy $0 ""
253   ReadRegStr $0 HKLM "Software\Classes\Applications\gvim.exe\shell\edit\command" ""
254   ${if} $0 != ""
255    StrCpy $0 $0 -13 # remove "gvim.exe "%1""
256    StrCpy $EditorPath "$EditorPath;$0"
257   ${endif}
258   # check for Vim 7.0
259   StrCpy $0 ""
260   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Vim 7.0" "UninstallString"
261   ${if} $0 != ""
262    StrCpy $0 $0 -18 # remove "\uninstall-gui.exe"
263    StrCpy $EditorPath "$EditorPath;$0"
264   ${endif}
265   # check for TeXnicCenter
266   StrCpy $0 ""
267   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "Inno Setup: App Path"
268   ${if} $0 != ""
269    StrCpy $EditorPath "$EditorPath;$0"
270   ${endif}
271   # check for LaTeXEditor
272   StrCpy $0 ""
273   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LaTeX Editor" "InstallLocation"
274   ${if} $0 != ""
275    StrCpy $EditorPath "$EditorPath;$0"
276   ${endif}
277   # check for WinEdt
278   StrCpy $0 ""
279   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinEdt_is1" "InstallLocation"
280   ${if} $0 != ""
281    StrCpy $0 $0 -1
282    StrCpy $EditorPath "$EditorPath;$0"
283   ${endif}
284   # check for LEd
285   StrCpy $0 ""
286   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LEd_is1" "InstallLocation"
287   ${if} $0 != ""
288    StrCpy $0 $0 -1
289    StrCpy $EditorPath "$EditorPath;$0"
290   ${endif}
291   # check for WinTeX
292   StrCpy $0 ""
293   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinTeX XP" "DisplayIcon"
294   ${if} $0 != ""
295    StrCpy $0 $0 -11 # remove "\wintex.exe"
296    StrCpy $EditorPath "$EditorPath;$0"
297   ${endif}
298
299 FunctionEnd
300