]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/install.nsh
locate local MiKTeX root and install dvipost
[features.git] / development / Win32 / packaging / installer / setup / install.nsh
1 /*
2
3 install.nsh
4
5 Installation of program files, dictionaries and external components
6
7 */
8
9 #--------------------------------
10 # Program files
11
12 Section -ProgramFiles SecProgramFiles
13
14   # Install and register the core LyX files
15   # Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
16   # $PLUGINSDIR is automatically deleted when the installer exits.
17   InitPluginsDir
18   
19   # Binaries
20   
21   SetOutPath "$INSTDIR\bin"
22
23   # launcher becomes lyx.exe while the real lyx.exe is renamed to lyxc.exe
24   File "${FILES_LAUNCHER}\lyx.exe"
25   File /oname=lyxc.exe "${FILES_LYX}\bin\lyx.exe"
26   
27   # The macros are defined in filelists.nsh
28   # the parameters are COMMAND DIRECTORY that form command '${COMMAND} "${DIRECTORY}files"
29   !insertmacro FileListLyXBin File "${FILES_LYX}\bin\"
30   !insertmacro FileListQtBin File "${FILES_QT}\bin\"
31   
32   !insertmacro FileListDllMSVCBin File "${FILES_DEPS}\bin\"
33   !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
34   !insertmacro FileListMSVCManifest File "..\"    
35
36   !insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
37   !insertmacro FileListDTLBin File "${FILES_DTL}\"
38   !insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
39   !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
40   !insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
41
42   # Icons
43   
44   SetOutPath "$INSTDIR\bin"
45   !insertmacro FileListLyXIcons File "${FILES_ICONS}\"
46
47   # Resources
48   
49   SetOutPath "$INSTDIR"
50   # recursively copy all files under Resources
51   File /r "${FILES_LYX}\Resources"
52   
53   # Components of Python
54   
55   SetOutPath "$INSTDIR\python"
56   !insertmacro FileListPythonBin File "${FILES_PYTHON}\"
57   !insertmacro FileListPythonDll File "$%SystemRoot%\System32\"
58   !insertmacro FileListUnicodeDll File "${FILES_PYTHON}\DLLs\"
59   SetOutPath "$INSTDIR\python\Lib"
60   !insertmacro FileListPythonLib File "${FILES_PYTHON}\Lib\"
61   SetOutPath "$INSTDIR\python\Lib\encodings"
62   !insertmacro FileListPythonLibEncodings File "${FILES_PYTHON}\Lib\encodings\"
63   
64   # Aspell
65
66   # Copy installer to pluginsdir (a temp dir)
67   File /oname=$PLUGINSDIR\AspellData.exe "${FILES_ASPELLDATA}\AspellData.exe"
68
69   # Silently install AspellData.exe (/S option)
70   ${If} $MultiUser.InstallMode == "CurrentUser"
71     ExecWait '"$PLUGINSDIR\AspellData.exe" /S /CurrentUser'
72   ${Else}
73     ExecWait '"$PLUGINSDIR\AspellData.exe" /S /AllUsers'
74   ${EndIf}
75
76   # Remove the installer
77   Delete "$PLUGINSDIR\AspellData.exe"
78
79   # Aiksarus data
80   
81   SetOutPath "$INSTDIR\aiksaurus"
82   !insertmacro FileListAiksaurusData File "${FILES_AIKSAURUS}\"
83   
84   # Helper DLLs for NSIS-based tools
85   
86   SetOutPath "$INSTDIR\bin"
87   !insertmacro FileListNSISPluginsStandard File "${NSISDIR}\Plugins\"
88   !insertmacro FileListNSISPlugins File "${FILES_NSISPLUGINS}\"
89   
90   # Create uninstaller
91   WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
92
93 SectionEnd
94
95 #--------------------------------
96 # Support code for file downloads
97
98 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
99
100   # Downloads a file using the InetLoad plug-in (HTTP or FTP)
101   
102   # RET = Return value (OK if succesful)
103   # ID = Name of the download in settings.nsh
104   # FILENAME = Location to store file
105   # APPEND = Filename to append to server location in settings.nsh
106
107   # Try first mirror server
108   InetLoad::load "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
109   Pop ${RET} # Return value (OK if succesful)
110
111   ${If} ${RET} != "OK"
112     # Download failed, try second mirror server
113     InetLoad::load "${DOWNLOADALT_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
114     Pop ${RET}
115   ${EndIf}
116
117 !macroend
118
119 #--------------------------------
120 # Aspell dictionaries
121
122 Var DictionaryFile
123 Var DictionaryLangName
124 Var DictionaryLangCode
125 Var DictionaryPath
126
127 Var AspellHive
128 Var AspellPath
129
130 Var DownloadResult
131
132 Section -AspellDicts
133
134   # Check whether the system or local version of Aspell should be used
135   # The patched Aspell uses the same logic
136
137   ReadRegStr $AspellPath HKCU "Software\Aspell" "Base Path"
138
139   ${If} $AspellPath == ""
140     StrCpy $AspellHive HKLM
141   ${Else}
142     StrCpy $AspellHive HKCU
143   ${EndIf}
144
145 SectionEnd
146
147 !macro SECTION_DICT FILE LANGNAME LANGCODE SIZE
148
149   # One section for each dictionary
150
151   Section /o "${LANGNAME}"
152
153     AddSize ${SIZE}
154
155     StrCpy $DictionaryFile "${FILE}"
156     StrCpy $DictionaryLangName "${LANGNAME}"
157     StrCpy $DictionaryLangCode ${LANGCODE}
158
159     Call DownloadDictionary
160
161   SectionEnd
162
163 !macroend
164
165 # Include all sections
166 !insertmacro Dictionaries '!insertmacro SECTION_DICT'
167
168 Function DownloadDictionary
169
170   # Download and install a dictionary
171
172   dict_download:
173   
174     !insertmacro DOWNLOAD_FILE $DownloadResult ASPELLDICTS aspell6-$DictionaryFile.exe /aspell6-$DictionaryFile.exe
175
176     ${If} $DownloadResult != "OK"
177       # Download failed
178       MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_DICT) ($DownloadResult)" IDYES dict_download
179       Goto dict_noinstall
180     ${EndIf}
181
182     install_dict:
183
184       ExecWait '"$PLUGINSDIR\aspell6-$DictionaryFile.exe" /NoDirChange /AutoClose'
185
186       ${If} $AspellHive == HKLM
187         ReadRegStr $DictionaryPath HKLM "Software\Aspell\Dictionaries" $DictionaryLangCode
188       ${Else}
189         ReadRegStr $DictionaryPath HKCU "Software\Aspell\Dictionaries" $DictionaryLangCode
190       ${EndIf}
191
192       ${If} $DictionaryPath == ""
193         MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_NOTINSTALLED_DICT)" IDYES install_dict
194       ${EndIf}
195
196       Delete "$PLUGINSDIR\aspell6-$DictionaryFile.exe"
197
198     dict_noinstall:
199
200 FunctionEnd
201
202 #--------------------------------
203 # Extenral components
204
205 Var PathAllUsers
206 Var PathCurrentUser
207
208 !macro EXTERNAL COMPONENT
209
210   # Download/Install the component
211   
212   ${If} $Setup${component} == ${TRUE}
213   
214     StrCpy $Path${component} "" ;A new one will be installed
215   
216     !ifndef SETUPTYPE_BUNDLE
217       !insertmacro EXTERNAL_DOWNLOAD ${component}
218     !else
219       !insertmacro EXTERNAL_INSTALL ${component}
220     !endif
221     
222   ${EndIf}
223
224 !macroend
225
226 !macro EXTERNAL_RUNINSTALLER COMPONENT
227
228   # Run the installer application of the component that does the actual installation.
229
230   install_${COMPONENT}:
231       
232     ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
233     
234     # Updates the path environment variable of the instaler process to the latest system value
235     ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
236     ReadRegStr $PathCurrentUser HKCU "Environment" Path
237     System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
238
239     Call Search${COMPONENT}
240     
241     ${If} $Path${COMPONENT} == ""  
242       MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
243     ${EndIf}
244       
245     Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
246      
247 !macroend
248
249 !ifndef SETUPTYPE_BUNDLE
250
251   !macro EXTERNAL_DOWNLOAD COMPONENT
252
253     download_${COMPONENT}:
254
255       !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
256  
257       ${If} $DownloadResult != "OK"
258         # Download failed
259         MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
260         Goto noinstall_${COMPONENT}
261       ${EndIf}
262       
263       !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
264       
265     noinstall_${COMPONENT}:
266
267   !macroend
268
269 !else
270
271   !macro EXTERNAL_INSTALL COMPONENT
272
273     # Extract
274     File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
275     
276     !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
277     
278   !macroend
279
280 !endif
281
282 # Sections for external components
283
284 Section -LaTeX ExternalLaTeX
285   !insertmacro EXTERNAL LaTeX
286 SectionEnd
287
288 Section -ImageMagick ExternalImageMagick
289   !insertmacro EXTERNAL ImageMagick
290 SectionEnd
291
292 Section -Ghostscript ExternalGhostscript
293   !insertmacro EXTERNAL Ghostscript
294 SectionEnd
295
296 Function InitExternal
297
298   # Get sizes of external component installers
299   
300   SectionGetSize ${ExternalLaTeX} $SizeLaTeX
301   SectionGetSize ${ExternalImageMagick} $SizeImageMagick
302   SectionGetSize ${ExternalGhostscript} $SizeGhostscript
303   
304   !ifndef SETUPTYPE_BUNDLE
305     # Add download size
306     IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
307     IntOp $SizeImagemagick $SizeImagemagick + ${SIZE_DOWNLOAD_IMAGEMAGICK}
308     IntOp $SizeGhostscript $SizeGhostscript + ${SIZE_DOWNLOAD_GHOSTSCRIPT}
309   !endif
310   
311 FunctionEnd