]> git.lyx.org Git - features.git/blob - development/Win32/packaging/AltInstaller/MissingPrograms.nsh
9fb0e98c5026964c55b9656f9a6f3d1151233a06
[features.git] / development / Win32 / packaging / AltInstaller / MissingPrograms.nsh
1 Function MissingPrograms
2   # check if third-party programs are installed
3
4   # initialize variable, is later set to True when a program was not found
5   ${if} $MissedProg != "True" # is already True when LaTeX is missing
6    StrCpy $MissedProg "False"
7   ${endif}
8
9   # test if Ghostscript is installed
10   GSloop:
11   EnumRegKey $1 HKLM "Software\AFPL Ghostscript" 0
12   ${if} $1 == ""
13    EnumRegKey $1 HKLM "Software\GPL Ghostscript" 0
14    ${if} $1 != ""
15     StrCpy $2 "True"
16    ${endif}
17   ${endif}
18   ${if} $1 != ""
19    ${if} $2 == "True"
20     ReadRegStr $3 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPL Ghostscript $1" "DisplayName"
21     StrCpy $0 "Software\GPL Ghostscript\$1"
22    ${else}
23     ReadRegStr $3 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AFPL Ghostscript $1" "DisplayName"
24     StrCpy $0 "Software\AFPL Ghostscript\$1"
25    ${endif}
26    ${if} $3 == "" # if nothing was found in the uninstall section
27     ReadRegStr $3 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" # check if Ghostscript was installed together with LyX
28    ${endif}
29    ${if} $3 == "" # if nothing was found in the uninstall section
30     DeleteRegKey HKLM "$0"
31     goto GSloop
32    ${else}
33     ReadRegStr $GhostscriptPath HKLM $0 "GS_DLL"
34     ${if} $GhostscriptPath != ""
35      StrCpy $GhostscriptPath "$GhostscriptPath" -12 # remove ending "gsdll32.dll"
36     ${else}
37      StrCpy $MissedProg "True"
38     ${endif}
39    ${endif} # if $3
40   ${else} # if $1
41    StrCpy $GhostscriptPath ""
42    StrCpy $MissedProg "True"
43   ${endif}
44
45   # test if Imagemagick is installed
46   ReadRegStr $ImageMagickPath HKLM "Software\ImageMagick\Current" "BinPath"
47   ${if} $ImageMagickPath == ""
48    StrCpy $MissedProg "True"
49   ${endif}
50
51   # test if Aiksaurus is installed
52   !insertmacro FileCheck $5 "meanings.dat" "${AiksaurusDir}" # macro from LyXUtils.nsh
53   ${if} $5 == "True"
54    StrCpy $AiksaurusPath "${AiksaurusDir}"
55   ${endif}
56 #  ReadRegStr $AiksaurusPath HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "AIK_DATA_DIR"
57
58   # test if Aspell is installed
59   StrCpy $5 ""
60   ReadRegStr $5 HKCU "SOFTWARE\Aspell" "Base Path"
61   ${if} $5 == ""
62    ReadRegStr $5 HKLM "SOFTWARE\Aspell" "Base Path"
63    StrCpy $AspellBaseReg "HKLM" # used in the aspell installation section
64   ${else}
65    StrCpy $AspellBaseReg "HKCU"
66   ${endif}
67   ${if} $5 == ""
68    StrCpy $MissedProg "True"
69   ${else}
70    StrCpy $AspellPath "$5"
71   ${endif}
72
73   # test if Python is installed
74   # only use an existing python when it is version 2.5 because many Compaq and Dell PC are delivered
75   # with outdated Python interpreters
76   ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
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 (due to LyX's bug 2654 first check for GIMP)
98   StrCpy $ImageEditorPath ""
99   ReadRegStr $ImageEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinGimp-2.0_is1" "DisplayIcon"
100   ${if} $ImageEditorPath != ""
101    StrCpy $ImageEditorPath "$ImageEditorPath" -13 # delete "\gimp-2.x.exe"
102   ${endif}
103   # check for Photoshop
104   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\Photoshop.exe" "Path"
105   ${if} $0 != ""
106    StrCpy $0 "$0" -1 # delete the last "\"
107    ${if} $ImageEditorPath != ""
108     StrCpy $ImageEditorPath "$ImageEditorPath;$0"
109    ${else}
110     StrCpy $ImageEditorPath $0
111    ${endif}
112   ${endif}
113
114   # test if the BibTeX-editor JabRef is installed
115   StrCpy $BibTeXEditorPath ""
116   ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.1" "UninstallString"
117   ${if} $BibTeXEditorPath == ""
118    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.2" "UninstallString"
119   ${endif}
120
121 FunctionEnd
122
123 # ---------------------------------------
124
125 Function MissingProgramsPage
126   # generate the page showing the missing programs that will be installed
127
128   StrCpy $0 "2" # start value for the dynamical item numbering
129   !insertmacro MUI_INSTALLOPTIONS_EXTRACT "io_missing_progs.ini"
130   !insertmacro MUI_HEADER_TEXT "$(MissProgHeader)" ""
131   
132   ${if} $MissedProg == "False"
133    !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field 6" "Text" "$(MissProgMessage)"
134   ${else}
135    !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field 1" "Text" "$(MissProgCap)"
136    ${if} ${INSTALLER_VERSION} == "Complete"
137     ${if} $LatexPath == ""
138      !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgLatex)"
139      IntOp $0 $0 + 1
140     ${endif}
141    ${endif}
142    ${if} $GhostscriptPath == ""
143     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgGhostscript)"
144     IntOp $0 $0 + 1
145    ${endif}
146    ${if} $ImageMagickPath == ""
147     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgImageMagick)"
148     IntOp $0 $0 + 1
149    ${endif}
150    ${if} $AspellPath == ""
151     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgAspell)"
152    ${endif}
153   ${endif}
154   
155   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "io_missing_progs.ini"
156
157 FunctionEnd
158
159 # ---------------------------------------
160
161 Function MissingProgramsPage_LeaveFunction
162
163  # this empty function is needed for the installer page
164
165 FunctionEnd
166
167 # ---------------------------------------
168
169 Function EditorCheck
170   # test if an editor with syntax-highlighting for LaTeX-files is installed
171
172   # (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
173   StrCpy $EditorPath ""
174   StrCpy $0 ""
175   # check for jEdit
176   ReadRegStr $EditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\jEdit_is1" "InstallLocation"
177   ${if} $EditorPath != ""
178    StrCpy $EditorPath $EditorPath -1 # remove "\" from the end of the string
179   ${endif}
180   # check for PSPad
181   StrCpy $0 ""
182   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PSPad editor_is1" "InstallLocation"
183   ${if} $0 != ""
184    StrCpy $0 $0 -1
185    StrCpy $EditorPath "$EditorPath;$0"
186   ${endif}
187   # check for WinShell
188   StrCpy $0 ""
189   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinShell_is1" "InstallLocation"
190   ${if} $0 != ""
191    StrCpy $0 $0 -1
192    StrCpy $EditorPath "$EditorPath;$0"
193   ${endif}
194   # check for ConTEXT
195   StrCpy $0 ""
196   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ConTEXTEditor_is1" "InstallLocation"
197   ${if} $0 != ""
198    StrCpy $0 $0 -1
199    StrCpy $EditorPath "$EditorPath;$0"
200   ${endif}
201   # check for Crimson Editor
202   StrCpy $0 ""
203   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Crimson Editor" "UninstallString"
204   ${if} $0 != ""
205    StrCpy $0 $0 -14 # remove "\uninstall.exe"
206    StrCpy $EditorPath "$EditorPath;$0"
207   ${endif}
208   # check for Vim 6.x
209   StrCpy $0 ""
210   ReadRegStr $0 HKLM "Software\Classes\Applications\gvim.exe\shell\edit\command" ""
211   ${if} $0 != ""
212    StrCpy $0 $0 -13 # remove "gvim.exe "%1""
213    StrCpy $EditorPath "$EditorPath;$0"
214   ${endif}
215   # check for Vim 7.0
216   StrCpy $0 ""
217   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Vim 7.0" "UninstallString"
218   ${if} $0 != ""
219    StrCpy $0 $0 -18 # remove "\uninstall-gui.exe"
220    StrCpy $EditorPath "$EditorPath;$0"
221   ${endif}
222   # check for TeXnicCenter
223   StrCpy $0 ""
224   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "Inno Setup: App Path"
225   ${if} $0 != ""
226    StrCpy $EditorPath "$EditorPath;$0"
227   ${endif}
228   # check for LaTeXEditor
229   StrCpy $0 ""
230   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LaTeX Editor" "InstallLocation"
231   ${if} $0 != ""
232    StrCpy $EditorPath "$EditorPath;$0"
233   ${endif}
234   # check for WinEdt
235   StrCpy $0 ""
236   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinEdt_is1" "InstallLocation"
237   ${if} $0 != ""
238    StrCpy $0 $0 -1
239    StrCpy $EditorPath "$EditorPath;$0"
240   ${endif}
241   # check for LEd
242   StrCpy $0 ""
243   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LEd_is1" "InstallLocation"
244   ${if} $0 != ""
245    StrCpy $0 $0 -1
246    StrCpy $EditorPath "$EditorPath;$0"
247   ${endif}
248   # check for WinTeX
249   StrCpy $0 ""
250   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinTeX XP" "DisplayIcon"
251   ${if} $0 != ""
252    StrCpy $0 $0 -11 # remove "\wintex.exe"
253    StrCpy $EditorPath "$EditorPath;$0"
254   ${endif}
255
256 FunctionEnd
257