5 Installation of program files, dictionaries and external components
9 #--------------------------------
13 Var PythonCompileReturn
15 Section -ProgramFiles SecProgramFiles
17 # Install and register the core LyX files
19 # The macros are defined in filelists.nsh
20 # the parameters are COMMAND DIRECTORY that form command '${COMMAND} "${DIRECTORY}files"
22 # Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
23 # $PLUGINSDIR is automatically deleted when the installer exits.
26 # Delete stuff from previous version
27 Delete "$INSTDIR\bin\lyxc.exe"
30 SetOutPath "$INSTDIR\bin"
31 !insertmacro FileListLyXBin File "${FILES_LYX}\bin\"
32 !insertmacro FileListLyXLauncher File "${FILES_LAUNCHER}\"
33 !insertmacro FileListQtBin File "${FILES_QT}\bin\"
34 !insertmacro FileListDll File "${FILES_DEPS}\bin\"
35 !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
36 !insertmacro FileListMSVCManifest File "..\"
37 !insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
38 !insertmacro FileListDTLBin File "${FILES_DTL}\"
39 !insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
40 !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
41 !insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
42 !insertmacro FileListNSISPluginsStandard File "${NSISDIR}\Plugins\"
43 !insertmacro FileListNSISPlugins File "${FILES_NSISPLUGINS}\"
44 !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
48 # recursively copy all files under Resources
49 File /r "${FILES_LYX}\Resources"
51 # Components of Python
52 SetOutPath "$INSTDIR\python"
53 !insertmacro FileListPythonBin File "${FILES_PYTHON}\"
54 !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
55 !insertmacro FileListMSVCManifest File "..\"
56 SetOutPath "$INSTDIR\python\Lib"
57 !insertmacro FileListPythonLib File "${FILES_PYTHON}\Lib\"
58 SetOutPath "$INSTDIR\python\Lib\encodings"
59 !insertmacro FileListPythonLibEncodings File "${FILES_PYTHON}\Lib\encodings\"
61 # Compile all Pyton files to byte-code
62 # The user using the scripts may not have write access
63 FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
64 FileWrite $PythonCompileFile "import compileall$\r$\n"
65 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
66 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
67 FileClose $PythonCompileFile
68 DetailPrint $(TEXT_CONFIGURE_PYTHON)
69 nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
70 Pop $PythonCompileReturn # Return value
71 Delete "$INSTDIR\compilepy.py"
73 !ifdef BUNDLE_IMAGEMAGICK
74 # Components of ImageMagick
75 SetOutPath "$INSTDIR\imagemagick"
76 !insertmacro FileListImageMagick File "${FILES_IMAGEMAGICK}\"
77 !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
78 !insertmacro FileListMSVCManifest File "..\"
81 !ifdef BUNDLE_GHOSTSCRIPT
82 # Components of Ghostscript
83 SetOutPath "$INSTDIR\ghostscript"
84 SetOutPath "$INSTDIR\ghostscript\bin"
85 !insertmacro FileListGhostscriptBin File "${FILES_GHOSTSCRIPT}\bin\"
86 !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
87 !insertmacro FileListMSVCManifest File "..\"
88 SetOutPath "$INSTDIR\ghostscript\lib"
89 !insertmacro FileListGhostscriptLib File "${FILES_GHOSTSCRIPT}\lib\"
90 SetOutPath "$INSTDIR\ghostscript\fonts"
91 !insertmacro FileListGhostscriptFonts File "${FILES_GHOSTSCRIPT}\fonts\"
92 SetOutPath "$INSTDIR\ghostscript\Resource"
93 SetOutPath "$INSTDIR\ghostscript\Resource\CMap"
94 !insertmacro FileListGhostscriptResourceCMap File "${FILES_GHOSTSCRIPT}\Resource\CMap\"
95 SetOutPath "$INSTDIR\ghostscript\Resource\ColorSpace"
96 !insertmacro FileListGhostscriptResourceColorSpace File "${FILES_GHOSTSCRIPT}\Resource\ColorSpace\"
97 SetOutPath "$INSTDIR\ghostscript\Resource\Decoding"
98 !insertmacro FileListGhostscriptResourceDecoding File "${FILES_GHOSTSCRIPT}\Resource\Decoding\"
99 SetOutPath "$INSTDIR\ghostscript\Resource\Encoding"
100 !insertmacro FileListGhostscriptResourceEncoding File "${FILES_GHOSTSCRIPT}\Resource\Encoding\"
106 # Copy installer to pluginsdir (a temp dir)
107 File /oname=$PLUGINSDIR\AspellData.exe "${FILES_ASPELLDATA}\AspellData.exe"
109 # Silently install AspellData.exe (/S option)
110 ${If} $MultiUser.InstallMode == "CurrentUser"
111 ExecWait '"$PLUGINSDIR\AspellData.exe" /S /CurrentUser'
113 ExecWait '"$PLUGINSDIR\AspellData.exe" /S /AllUsers'
116 # Remove the installer
117 Delete "$PLUGINSDIR\AspellData.exe"
120 SetOutPath "$INSTDIR\aiksaurus"
121 !insertmacro FileListAiksaurusData File "${FILES_AIKSAURUS}\"
124 WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
128 #--------------------------------
129 # Support code for file downloads
131 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
133 # Downloads a file using the Inetc plug-in (HTTP or FTP)
135 # RET = Return value (OK if succesful)
136 # ID = Name of the download in settings.nsh
137 # FILENAME = Location to store file
138 # APPEND = Filename to append to server location in settings.nsh
140 # Try first mirror server
141 Inetc::get "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
142 Pop ${RET} # Return value (OK if succesful)
145 # Download failed, try second mirror server
146 Inetc::get "${DOWNLOADALT_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
152 #--------------------------------
153 # Aspell dictionaries
156 Var DictionaryLangName
157 Var DictionaryLangCode
167 # Check whether the system or local version of Aspell should be used
168 # The patched Aspell uses the same logic
170 ReadRegStr $AspellPath HKCU "Software\Aspell" "Base Path"
172 ${If} $AspellPath == ""
173 StrCpy $AspellHive HKLM
175 StrCpy $AspellHive HKCU
180 !macro SECTION_DICT FILE LANGNAME LANGCODE SIZE
182 # One section for each dictionary
184 Section /o "${LANGNAME}"
188 StrCpy $DictionaryFile "${FILE}"
189 StrCpy $DictionaryLangName "${LANGNAME}"
190 StrCpy $DictionaryLangCode ${LANGCODE}
192 Call DownloadDictionary
198 # Include all sections
199 !insertmacro Dictionaries '!insertmacro SECTION_DICT'
201 Function DownloadDictionary
203 # Download and install a dictionary
207 !insertmacro DOWNLOAD_FILE $DownloadResult ASPELLDICTS aspell6-$DictionaryFile.exe /aspell6-$DictionaryFile.exe
209 ${If} $DownloadResult != "OK"
211 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_DICT) ($DownloadResult)" IDYES dict_download
217 ExecWait '"$PLUGINSDIR\aspell6-$DictionaryFile.exe" /NoDirChange /AutoClose'
219 ${If} $AspellHive == HKLM
220 ReadRegStr $DictionaryPath HKLM "Software\Aspell\Dictionaries" $DictionaryLangCode
222 ReadRegStr $DictionaryPath HKCU "Software\Aspell\Dictionaries" $DictionaryLangCode
225 ${If} $DictionaryPath == ""
226 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_NOTINSTALLED_DICT)" IDYES install_dict
229 Delete "$PLUGINSDIR\aspell6-$DictionaryFile.exe"
235 #--------------------------------
236 # Extenral components
241 !macro EXTERNAL COMPONENT
243 # Download/Install the component
245 ${If} $Setup${COMPONENT} == ${TRUE}
247 StrCpy $Path${COMPONENT} "" ;A new one will be installed
249 !ifndef BUNDLESETUP_${COMPONENT}
250 !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
252 !insertmacro EXTERNAL_INSTALL ${COMPONENT}
259 !macro EXTERNAL_RUNINSTALLER COMPONENT
261 # Run the installer application of the component that does the actual installation.
263 install_${COMPONENT}:
265 ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
267 # Updates the path environment variable of the instaler process to the latest system value
268 ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
269 ReadRegStr $PathCurrentUser HKCU "Environment" Path
270 System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
272 Call Search${COMPONENT}
274 ${If} $Path${COMPONENT} == ""
275 MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
278 Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
282 !macro EXTERNAL_DOWNLOAD COMPONENT
284 download_${COMPONENT}:
286 !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
288 ${If} $DownloadResult != "OK"
290 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
291 Goto noinstall_${COMPONENT}
294 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
296 noinstall_${COMPONENT}:
300 !macro EXTERNAL_INSTALL COMPONENT
303 File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
305 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
310 # Sections for external components
312 Section -LaTeX ExternalLaTeX
313 !insertmacro EXTERNAL LaTeX
316 !ifndef BUNDLE_IMAGEMAGICK
318 Section -ImageMagick ExternalImageMagick
319 !insertmacro EXTERNAL ImageMagick
324 !ifndef BUNDLE_GHOSTSCRIPT
326 Section -Ghostscript ExternalGhostscript
327 !insertmacro EXTERNAL Ghostscript
332 Function InitExternal
334 # Get sizes of external component installers
336 SectionGetSize ${ExternalLaTeX} $SizeLaTeX
337 !ifndef BUNDLE_IMAGEMAGICK
338 SectionGetSize ${ExternalImageMagick} $SizeImageMagick
340 !ifndef BUNDLE_GHOSTSCRIPT
341 SectionGetSize ${ExternalGhostscript} $SizeGhostscript
346 !ifndef BUNDLESETUP_MIKTEX
347 IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
349 !ifndef BUNDLE_IMAGEMAGICK & BUNDLESETUP_IMAGEMAGICK
350 IntOp $SizeImagemagick $SizeImagemagick + ${SIZE_DOWNLOAD_IMAGEMAGICK}
352 !ifndef BUNDLE_GHOSTSCRIPT & BUNDLESETUP_GHOSTSCRIPT
353 IntOp $SizeGhostscript $SizeGhostscript + ${SIZE_DOWNLOAD_GHOSTSCRIPT}