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 "..\"
88 WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
92 #--------------------------------
93 # Support code for file downloads
95 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
97 # Downloads a file using the Inetc plug-in (HTTP or FTP)
99 # RET = Return value (OK if succesful)
100 # ID = Name of the download in settings.nsh
101 # FILENAME = Location to store file
102 # APPEND = Filename to append to server location in settings.nsh
105 Inetc::get "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
106 Pop ${RET} # Return value (OK if succesful)
109 # Download failed, try again (usally we get a different mirror)
110 Inetc::get "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
116 #--------------------------------
117 # Extenral components
122 !macro EXTERNAL COMPONENT
124 # Download/Install the component
126 ${If} $Setup${COMPONENT} == ${TRUE}
128 StrCpy $Path${COMPONENT} "" ;A new one will be installed
130 !ifndef BUNDLESETUP_${COMPONENT}
131 !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
133 !insertmacro EXTERNAL_INSTALL ${COMPONENT}
140 !macro EXTERNAL_RUNINSTALLER COMPONENT
142 # Run the installer application of the component that does the actual installation.
144 install_${COMPONENT}:
146 ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
148 # Updates the path environment variable of the instaler process to the latest system value
149 ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
150 ReadRegStr $PathCurrentUser HKCU "Environment" Path
151 System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
153 Call Search${COMPONENT}
155 ${If} $Path${COMPONENT} == ""
156 MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
159 Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
163 !macro EXTERNAL_DOWNLOAD COMPONENT
165 download_${COMPONENT}:
167 !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
169 ${If} $DownloadResult != "OK"
171 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
172 Goto noinstall_${COMPONENT}
175 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
177 noinstall_${COMPONENT}:
181 !macro EXTERNAL_INSTALL COMPONENT
184 File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
186 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
191 # Sections for external components
193 Section -LaTeX ExternalLaTeX
194 !insertmacro EXTERNAL LaTeX
197 !ifndef BUNDLE_IMAGEMAGICK
199 Section -ImageMagick ExternalImageMagick
200 !insertmacro EXTERNAL ImageMagick
205 !ifndef BUNDLE_GHOSTSCRIPT
207 Section -Ghostscript ExternalGhostscript
208 !insertmacro EXTERNAL Ghostscript
213 Function InitExternal
215 # Get sizes of external component installers
217 SectionGetSize ${ExternalLaTeX} $SizeLaTeX
218 !ifndef BUNDLE_IMAGEMAGICK
219 SectionGetSize ${ExternalImageMagick} $SizeImageMagick
221 !ifndef BUNDLE_GHOSTSCRIPT
222 SectionGetSize ${ExternalGhostscript} $SizeGhostscript
227 !ifndef BUNDLESETUP_MIKTEX
228 IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
230 !ifndef BUNDLE_IMAGEMAGICK & BUNDLESETUP_IMAGEMAGICK
231 IntOp $SizeImagemagick $SizeImagemagick + ${SIZE_DOWNLOAD_IMAGEMAGICK}
233 !ifndef BUNDLE_GHOSTSCRIPT & BUNDLESETUP_GHOSTSCRIPT
234 IntOp $SizeGhostscript $SizeGhostscript + ${SIZE_DOWNLOAD_GHOSTSCRIPT}