5 Installation of program files, dictionaries and external components
9 #--------------------------------
13 Var PythonCompileReturn
16 Section -ProgramFiles SecProgramFiles
18 # Install and register the core LyX files
20 # The macros are defined in filelists.nsh
21 # the parameters are COMMAND DIRECTORY that form command '${COMMAND} "${DIRECTORY}files"
23 # Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
24 # $PLUGINSDIR is automatically deleted when the installer exits.
28 SetOutPath "$INSTDIR\bin"
29 !insertmacro FileListLyXBin File "${FILES_LYX}\bin\"
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 FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
42 # recursively copy all files under Resources
43 File /r "${FILES_LYX}\Resources"
45 # Components of Python
46 SetOutPath "$INSTDIR\python"
47 !insertmacro FileListPythonBin File "${FILES_PYTHON}\"
48 !insertmacro FileListMSVC File "${FILES_MSVC}\"
49 SetOutPath "$INSTDIR\python\Lib"
50 !insertmacro FileListPythonLib File "${FILES_PYTHON}\Lib\"
51 SetOutPath "$INSTDIR\python\Lib\encodings"
52 !insertmacro FileListPythonLibEncodings File "${FILES_PYTHON}\Lib\encodings\"
53 SetOutPath "$INSTDIR\python\Lib\logging"
54 !insertmacro FileListPythonLibLogging File "${FILES_PYTHON}\Lib\logging\"
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}\"
79 WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
83 #--------------------------------
84 # Support code for file downloads
86 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
90 # RET = Return value (OK if succesful)
91 # ID = Name of the download in settings.nsh
92 # FILENAME = Location to store file
93 # APPEND = Filename to append to server location in settings.nsh
96 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
97 Pop ${RET} # Return value (OK if succesful)
100 # Download failed, try again (usally we get a different mirror)
101 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
107 #--------------------------------
108 # Extenral components
113 !macro EXTERNAL COMPONENT
115 # Download/Install the component
117 ${If} $Setup${COMPONENT} == ${TRUE}
119 StrCpy $Path${COMPONENT} "" ;A new one will be installed
121 !ifndef BUNDLESETUP_${COMPONENT}
122 !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
124 !insertmacro EXTERNAL_INSTALL ${COMPONENT}
131 !macro EXTERNAL_RUNINSTALLER COMPONENT
133 # Run the installer application of the component that does the actual installation.
135 install_${COMPONENT}:
137 ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
139 # Updates the path environment variable of the instaler process to the latest system value
140 ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
141 ReadRegStr $PathCurrentUser HKCU "Environment" Path
142 System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
144 Call Search${COMPONENT}
146 ${If} $Path${COMPONENT} == ""
147 MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
150 Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
154 !macro EXTERNAL_DOWNLOAD COMPONENT
156 download_${COMPONENT}:
158 !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
160 ${If} $DownloadResult != "OK"
162 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
163 Goto noinstall_${COMPONENT}
166 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
168 noinstall_${COMPONENT}:
172 !macro EXTERNAL_INSTALL COMPONENT
175 File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
177 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
182 # Sections for external components
184 Section -LaTeX ExternalLaTeX
185 !insertmacro EXTERNAL LaTeX
188 Function InitExternal
190 # Get sizes of external component installers
192 SectionGetSize ${ExternalLaTeX} $SizeLaTeX
196 !ifndef BUNDLESETUP_MIKTEX
197 IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}