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