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.
27 SetOutPath "$INSTDIR\bin"
28 !insertmacro FileListLyXBin File "${FILES_LYX}\bin\"
29 !insertmacro FileListLyXLauncher File "${FILES_LAUNCHER}\"
30 !insertmacro FileListQtBin File "${FILES_QT}\bin\"
31 !insertmacro FileListDll File "${FILES_DEPS}\bin\"
32 !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
33 !insertmacro FileListMSVCManifest File "..\"
34 !insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
35 !insertmacro FileListDTLBin File "${FILES_DTL}\"
36 !insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
37 !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
38 !insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
39 !insertmacro FileListNSISPluginsStandard File "${NSISDIR}\Plugins\"
40 !insertmacro FileListNSISPlugins File "${FILES_NSISPLUGINS}\"
41 !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
45 # recursively copy all files under Resources
46 File /r "${FILES_LYX}\Resources"
48 # Components of Python
49 SetOutPath "$INSTDIR\python"
50 !insertmacro FileListPythonBin File "${FILES_PYTHON}\"
51 !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
52 !insertmacro FileListMSVCManifest File "..\"
53 SetOutPath "$INSTDIR\python\Lib"
54 !insertmacro FileListPythonLib File "${FILES_PYTHON}\Lib\"
55 SetOutPath "$INSTDIR\python\Lib\encodings"
56 !insertmacro FileListPythonLibEncodings File "${FILES_PYTHON}\Lib\encodings\"
58 # Compile all Pyton files to byte-code
59 # The user using the scripts may not have write access
60 FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
61 FileWrite $PythonCompileFile "import compileall$\r$\n"
62 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
63 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
64 FileClose $PythonCompileFile
65 DetailPrint $(TEXT_CONFIGURE_PYTHON)
66 nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
67 Pop $PythonCompileReturn # Return value
68 Delete "$INSTDIR\compilepy.py"
70 !ifdef BUNDLE_IMAGEMAGICK
71 # Components of ImageMagick
72 SetOutPath "$INSTDIR\imagemagick"
73 !insertmacro FileListImageMagick File "${FILES_IMAGEMAGICK}\"
74 !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
75 !insertmacro FileListMSVCManifest File "..\"
78 !ifdef BUNDLE_GHOSTSCRIPT
79 # Components of Ghostscript
80 SetOutPath "$INSTDIR\ghostscript"
81 !insertmacro FileListGhostscript File "${FILES_GHOSTSCRIPT}\"
82 !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
83 !insertmacro FileListMSVCManifest File "..\"
89 # Copy installer to pluginsdir (a temp dir)
90 File /oname=$PLUGINSDIR\AspellData.exe "${FILES_ASPELLDATA}\AspellData.exe"
92 # Silently install AspellData.exe (/S option)
93 ${If} $MultiUser.InstallMode == "CurrentUser"
94 ExecWait '"$PLUGINSDIR\AspellData.exe" /S /CurrentUser'
96 ExecWait '"$PLUGINSDIR\AspellData.exe" /S /AllUsers'
99 # Remove the installer
100 Delete "$PLUGINSDIR\AspellData.exe"
103 SetOutPath "$INSTDIR\aiksaurus"
104 !insertmacro FileListAiksaurusData File "${FILES_AIKSAURUS}\"
107 WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
111 #--------------------------------
112 # Support code for file downloads
114 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
116 # Downloads a file using the Inetc plug-in (HTTP or FTP)
118 # RET = Return value (OK if succesful)
119 # ID = Name of the download in settings.nsh
120 # FILENAME = Location to store file
121 # APPEND = Filename to append to server location in settings.nsh
124 Inetc::get "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
125 Pop ${RET} # Return value (OK if succesful)
128 # Download failed, try again (usally we get a different mirror)
129 Inetc::get "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
135 #--------------------------------
136 # Aspell dictionaries
139 Var DictionaryLangName
140 Var DictionaryLangCode
150 # Check whether the system or local version of Aspell should be used
151 # The patched Aspell uses the same logic
153 ReadRegStr $AspellPath HKCU "Software\Aspell" "Base Path"
155 ${If} $AspellPath == ""
156 StrCpy $AspellHive HKLM
158 StrCpy $AspellHive HKCU
163 !macro SECTION_DICT FILE LANGNAME LANGCODE SIZE
165 # One section for each dictionary
167 Section /o "${LANGNAME}"
171 StrCpy $DictionaryFile "${FILE}"
172 StrCpy $DictionaryLangName "${LANGNAME}"
173 StrCpy $DictionaryLangCode ${LANGCODE}
175 Call DownloadDictionary
181 # Include all sections
182 !insertmacro Dictionaries '!insertmacro SECTION_DICT'
184 Function DownloadDictionary
186 # Download and install a dictionary
190 !insertmacro DOWNLOAD_FILE $DownloadResult ASPELLDICTS aspell6-$DictionaryFile.exe /aspell6-$DictionaryFile.exe
192 ${If} $DownloadResult != "OK"
194 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_DICT) ($DownloadResult)" IDYES dict_download
200 ExecWait '"$PLUGINSDIR\aspell6-$DictionaryFile.exe" /NoDirChange /AutoClose'
202 ${If} $AspellHive == HKLM
203 ReadRegStr $DictionaryPath HKLM "Software\Aspell\Dictionaries" $DictionaryLangCode
205 ReadRegStr $DictionaryPath HKCU "Software\Aspell\Dictionaries" $DictionaryLangCode
208 ${If} $DictionaryPath == ""
209 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_NOTINSTALLED_DICT)" IDYES install_dict
212 Delete "$PLUGINSDIR\aspell6-$DictionaryFile.exe"
218 #--------------------------------
219 # Extenral components
224 !macro EXTERNAL COMPONENT
226 # Download/Install the component
228 ${If} $Setup${COMPONENT} == ${TRUE}
230 StrCpy $Path${COMPONENT} "" ;A new one will be installed
232 !ifndef BUNDLESETUP_${COMPONENT}
233 !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
235 !insertmacro EXTERNAL_INSTALL ${COMPONENT}
242 !macro EXTERNAL_RUNINSTALLER COMPONENT
244 # Run the installer application of the component that does the actual installation.
246 install_${COMPONENT}:
248 ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
250 # Updates the path environment variable of the instaler process to the latest system value
251 ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
252 ReadRegStr $PathCurrentUser HKCU "Environment" Path
253 System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
255 Call Search${COMPONENT}
257 ${If} $Path${COMPONENT} == ""
258 MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
261 Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
265 !macro EXTERNAL_DOWNLOAD COMPONENT
267 download_${COMPONENT}:
269 !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
271 ${If} $DownloadResult != "OK"
273 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
274 Goto noinstall_${COMPONENT}
277 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
279 noinstall_${COMPONENT}:
283 !macro EXTERNAL_INSTALL COMPONENT
286 File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
288 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
293 # Sections for external components
295 Section -LaTeX ExternalLaTeX
296 !insertmacro EXTERNAL LaTeX
299 !ifndef BUNDLE_IMAGEMAGICK
301 Section -ImageMagick ExternalImageMagick
302 !insertmacro EXTERNAL ImageMagick
307 !ifndef BUNDLE_GHOSTSCRIPT
309 Section -Ghostscript ExternalGhostscript
310 !insertmacro EXTERNAL Ghostscript
315 Function InitExternal
317 # Get sizes of external component installers
319 SectionGetSize ${ExternalLaTeX} $SizeLaTeX
320 !ifndef BUNDLE_IMAGEMAGICK
321 SectionGetSize ${ExternalImageMagick} $SizeImageMagick
323 !ifndef BUNDLE_GHOSTSCRIPT
324 SectionGetSize ${ExternalGhostscript} $SizeGhostscript
329 !ifndef BUNDLESETUP_MIKTEX
330 IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
332 !ifndef BUNDLE_IMAGEMAGICK & BUNDLESETUP_IMAGEMAGICK
333 IntOp $SizeImagemagick $SizeImagemagick + ${SIZE_DOWNLOAD_IMAGEMAGICK}
335 !ifndef BUNDLE_GHOSTSCRIPT & BUNDLESETUP_GHOSTSCRIPT
336 IntOp $SizeGhostscript $SizeGhostscript + ${SIZE_DOWNLOAD_GHOSTSCRIPT}