installer: sync with branch
[lyx.git] / development / Win32 / packaging / AltInstaller / MissingPrograms.nsh
blobdf202991467c1c97346e3dec1d53f5727318a27b
1 # This script contains the following functions:
3 # - MissingPrograms, (check if third-party programs are installed), uses:
4 #    EditorCheck
5 #    FileCheck
7 # - MissingProgramsPage,
8 #    (generate the page showing the missing programs that will be installed)
10 # - EditorCheck,
11 #    (test if an editor with syntax-highlighting for LaTeX-files is installed)
13 #--------------------------
15 Function MissingPrograms
16   # check if third-party programs are installed
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}
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}
59   # test if Imagemagick is installed
60   ReadRegStr $ImageMagickPath HKLM "Software\ImageMagick\Current" "BinPath"
61   ${if} $ImageMagickPath == ""
62    StrCpy $MissedProg "True"
63   ${endif}
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"
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}
87   # test if Python is installed
88   # only use an existing python when it is version 2.5 or newer because some
89   # Compaq and Dell PCs were delivered with outdated Python interpreters
90   ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
91   ${if} $PythonPath == ""
92    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.6\InstallPath" ""
93   ${endif}
94   ${if} $PythonPath == ""
95    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\3.0\InstallPath" ""
96   ${endif}
97   ${if} $PythonPath == ""
98    ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\3.1\InstallPath" ""
99   ${endif}
100   ${if} $PythonPath != ""
101    StrCpy $PythonPath $PythonPath -1 # remove the "\" at the end
102    StrCpy $DelPythonFiles "True"
103   ${endif}
105   # test if Acrobat or Adobe Reader is used as PDF-viewer
106   ReadRegStr $String HKCR ".pdf" ""
107   ${if} $String != "AcroExch.Document" # this name is only used by Acrobat and Adobe Reader
108    StrCpy $Acrobat "None"
109   ${else}
110    StrCpy $Acrobat "Yes"
111   ${endif}
113   # test if a PostScript-viewer is installed, only check for GSview32
114   StrCpy $PSVPath ""
115   ReadRegStr $PSVPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview32.exe" "Path"
117   # test if an editor with syntax-highlighting for LaTeX-files is installed
118   Call EditorCheck
120   # test if an image editor is installed (due to LyX's bug 2654 first check for GIMP)
121   StrCpy $ImageEditorPath ""
122   ReadRegStr $ImageEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinGimp-2.0_is1" "DisplayIcon"
123   ${if} $ImageEditorPath != ""
124    StrCpy $ImageEditorPath "$ImageEditorPath" -13 # delete "\gimp-2.x.exe"
125   ${endif}
126   # check for Photoshop
127   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\Photoshop.exe" "Path"
128   ${if} $0 != ""
129    StrCpy $0 "$0" -1 # delete the last "\"
130    ${if} $ImageEditorPath != ""
131     StrCpy $ImageEditorPath "$ImageEditorPath;$0"
132    ${else}
133     StrCpy $ImageEditorPath $0
134    ${endif}
135   ${endif}
137   # test if the BibTeX-editor JabRef is installed
138   StrCpy $BibTeXEditorPath ""
139   ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.2" "UninstallString"
140   ${if} $BibTeXEditorPath == ""
141    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.3" "UninstallString"
142   ${endif}
143   ${if} $BibTeXEditorPath == ""
144    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.3.1" "UninstallString"
145   ${endif}
146   ${if} $BibTeXEditorPath == ""
147    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.4" "UninstallString"
148   ${endif}
149   ${if} $BibTeXEditorPath == ""
150    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.4.1" "UninstallString"
151   ${endif}
152   ${if} $BibTeXEditorPath == ""
153    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.4.2" "UninstallString"
154   ${endif}
155   ${if} $BibTeXEditorPath == ""
156    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.5" "UninstallString"
157   ${endif}
158   
159   # test if Inkscape is installed
160   ReadRegStr $SVGPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Inkscape" "InstallLocation"
161   
162   # test if metafile2eps is installed
163   ReadRegStr $WMFPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Metafile to EPS Converter" "InstallLocation"
165 FunctionEnd
167 # ---------------------------------------
169 Function MissingProgramsPage
170   # generate the page showing the missing programs that will be installed
172   StrCpy $0 "2" # start value for the dynamical item numbering
173   !insertmacro MUI_INSTALLOPTIONS_EXTRACT "io_missing_progs.ini"
174   !insertmacro MUI_HEADER_TEXT "$(MissProgHeader)" ""
175   
176   ${if} $MissedProg == "False"
177    !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field 6" "Text" "$(MissProgMessage)"
178   ${else}
179    !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field 1" "Text" "$(MissProgCap)"
180    ${if} ${INSTALLER_VERSION} == "Complete"
181     ${if} $LatexPath == ""
182      !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgLatex)"
183      IntOp $0 $0 + 1
184     ${endif}
185    ${endif}
186    ${if} $GhostscriptPath == ""
187     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgGhostscript)"
188     IntOp $0 $0 + 1
189    ${endif}
190    ${if} $ImageMagickPath == ""
191     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgImageMagick)"
192     IntOp $0 $0 + 1
193    ${endif}
194    ${if} $AspellPath == ""
195     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgAspell)"
196    ${endif}
197   ${endif}
198   
199   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "io_missing_progs.ini"
201 FunctionEnd
203 # ---------------------------------------
205 Function MissingProgramsPage_LeaveFunction
207  # this empty function is needed for the installer page
209 FunctionEnd
211 # ---------------------------------------
213 Function EditorCheck
214   # test if an editor with syntax-highlighting for LaTeX-files is installed
216   # (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
217   StrCpy $EditorPath ""
218   StrCpy $0 ""
219   # check for jEdit
220   ReadRegStr $EditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\jEdit_is1" "InstallLocation"
221   ${if} $EditorPath != ""
222    StrCpy $EditorPath $EditorPath -1 # remove "\" from the end of the string
223   ${endif}
224   # check for PSPad
225   StrCpy $0 ""
226   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PSPad editor_is1" "InstallLocation"
227   ${if} $0 != ""
228    StrCpy $0 $0 -1
229    StrCpy $EditorPath "$EditorPath;$0"
230   ${endif}
231   # check for WinShell
232   StrCpy $0 ""
233   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinShell_is1" "InstallLocation"
234   ${if} $0 != ""
235    StrCpy $0 $0 -1
236    StrCpy $EditorPath "$EditorPath;$0"
237   ${endif}
238   # check for ConTEXT
239   StrCpy $0 ""
240   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ConTEXTEditor_is1" "InstallLocation"
241   ${if} $0 != ""
242    StrCpy $0 $0 -1
243    StrCpy $EditorPath "$EditorPath;$0"
244   ${endif}
245   # check for Crimson Editor
246   StrCpy $0 ""
247   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Crimson Editor" "UninstallString"
248   ${if} $0 != ""
249    StrCpy $0 $0 -14 # remove "\uninstall.exe"
250    StrCpy $EditorPath "$EditorPath;$0"
251   ${endif}
252   # check for Vim 6.x
253   StrCpy $0 ""
254   ReadRegStr $0 HKLM "Software\Classes\Applications\gvim.exe\shell\edit\command" ""
255   ${if} $0 != ""
256    StrCpy $0 $0 -13 # remove "gvim.exe "%1""
257    StrCpy $EditorPath "$EditorPath;$0"
258   ${endif}
259   # check for Vim 7.0
260   StrCpy $0 ""
261   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Vim 7.0" "UninstallString"
262   ${if} $0 != ""
263    StrCpy $0 $0 -18 # remove "\uninstall-gui.exe"
264    StrCpy $EditorPath "$EditorPath;$0"
265   ${endif}
266   # check for TeXnicCenter
267   StrCpy $0 ""
268   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "Inno Setup: App Path"
269   ${if} $0 != ""
270    StrCpy $EditorPath "$EditorPath;$0"
271   ${endif}
272   # check for LaTeXEditor
273   StrCpy $0 ""
274   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LaTeX Editor" "InstallLocation"
275   ${if} $0 != ""
276    StrCpy $EditorPath "$EditorPath;$0"
277   ${endif}
278   # check for WinEdt
279   StrCpy $0 ""
280   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinEdt_is1" "InstallLocation"
281   ${if} $0 != ""
282    StrCpy $0 $0 -1
283    StrCpy $EditorPath "$EditorPath;$0"
284   ${endif}
285   # check for LEd
286   StrCpy $0 ""
287   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LEd_is1" "InstallLocation"
288   ${if} $0 != ""
289    StrCpy $0 $0 -1
290    StrCpy $EditorPath "$EditorPath;$0"
291   ${endif}
292   # check for WinTeX
293   StrCpy $0 ""
294   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinTeX XP" "DisplayIcon"
295   ${if} $0 != ""
296    StrCpy $0 $0 -11 # remove "\wintex.exe"
297    StrCpy $EditorPath "$EditorPath;$0"
298   ${endif}
300 FunctionEnd