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 FileListMSVC File "${FILES_MSVC}\"
33 !insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
34 !insertmacro FileListDTLBin File "${FILES_DTL}\"
35 !insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
36 !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
37 !insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
38 !insertmacro FileListNSISPluginsStandard File "${NSISDIR}\Plugins\"
39 !insertmacro FileListNSISPlugins File "${FILES_NSISPLUGINS}\"
40 !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
44 # recursively copy all files under Resources
45 File /r "${FILES_LYX}\Resources"
47 # Components of Python
48 SetOutPath "$INSTDIR\python"
49 !insertmacro FileListPythonBin File "${FILES_PYTHON}\"
50 !insertmacro FileListMSVC File "${FILES_MSVC}\"
51 SetOutPath "$INSTDIR\python\Lib"
52 !insertmacro FileListPythonLib File "${FILES_PYTHON}\Lib\"
53 SetOutPath "$INSTDIR\python\Lib\encodings"
54 !insertmacro FileListPythonLibEncodings File "${FILES_PYTHON}\Lib\encodings\"
56 # Compile all Pyton files to byte-code
57 # The user using the scripts may not have write access
58 FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
59 FileWrite $PythonCompileFile "import compileall$\r$\n"
60 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
61 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
62 FileClose $PythonCompileFile
63 DetailPrint $(TEXT_CONFIGURE_PYTHON)
64 nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
65 Pop $PythonCompileReturn # Return value
66 Delete "$INSTDIR\compilepy.py"
68 # Components of ImageMagick
69 SetOutPath "$INSTDIR\imagemagick"
70 !insertmacro FileListImageMagick File "${FILES_IMAGEMAGICK}\"
71 !insertmacro FileListMSVC File "${FILES_MSVC}\"
73 # Components of Ghostscript
74 SetOutPath "$INSTDIR\ghostscript"
75 !insertmacro FileListGhostscript File "${FILES_GHOSTSCRIPT}\"
76 !insertmacro FileListMSVC File "${FILES_MSVC}\"
81 WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
85 #--------------------------------
86 # Support code for file downloads
88 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
90 # Downloads a file using the Inetc plug-in (HTTP or FTP)
92 # RET = Return value (OK if succesful)
93 # ID = Name of the download in settings.nsh
94 # FILENAME = Location to store file
95 # APPEND = Filename to append to server location in settings.nsh
98 Inetc::get "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
99 Pop ${RET} # Return value (OK if succesful)
102 # Download failed, try again (usally we get a different mirror)
103 Inetc::get "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
109 #--------------------------------
110 # Extenral components
115 !macro EXTERNAL COMPONENT
117 # Download/Install the component
119 ${If} $Setup${COMPONENT} == ${TRUE}
121 StrCpy $Path${COMPONENT} "" ;A new one will be installed
123 !ifndef BUNDLESETUP_${COMPONENT}
124 !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
126 !insertmacro EXTERNAL_INSTALL ${COMPONENT}
133 !macro EXTERNAL_RUNINSTALLER COMPONENT
135 # Run the installer application of the component that does the actual installation.
137 install_${COMPONENT}:
139 ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
141 # Updates the path environment variable of the instaler process to the latest system value
142 ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
143 ReadRegStr $PathCurrentUser HKCU "Environment" Path
144 System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
146 Call Search${COMPONENT}
148 ${If} $Path${COMPONENT} == ""
149 MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
152 Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
156 !macro EXTERNAL_DOWNLOAD COMPONENT
158 download_${COMPONENT}:
160 !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
162 ${If} $DownloadResult != "OK"
164 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
165 Goto noinstall_${COMPONENT}
168 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
170 noinstall_${COMPONENT}:
174 !macro EXTERNAL_INSTALL COMPONENT
177 File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
179 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
184 # Sections for external components
186 Section -LaTeX ExternalLaTeX
187 !insertmacro EXTERNAL LaTeX
190 Function InitExternal
192 # Get sizes of external component installers
194 SectionGetSize ${ExternalLaTeX} $SizeLaTeX
198 !ifndef BUNDLESETUP_MIKTEX
199 IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}