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"
47 # recursively copy all files under Python
48 File /r "${FILES_PYTHON}"
50 SetOutPath "$INSTDIR\python"
51 !insertmacro FileListMSVC File "${FILES_MSVC}\"
54 # Compile all Pyton files to byte-code
55 # The user using the scripts may not have write access
56 FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
57 FileWrite $PythonCompileFile "import compileall$\r$\n"
58 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
59 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
60 FileClose $PythonCompileFile
61 DetailPrint $(TEXT_CONFIGURE_PYTHON)
62 nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
63 Pop $PythonCompileReturn # Return value
64 Delete "$INSTDIR\compilepy.py"
66 # Components of ImageMagick
67 SetOutPath "$INSTDIR\imagemagick"
68 !insertmacro FileListImageMagick File "${FILES_IMAGEMAGICK}\"
69 !insertmacro FileListMSVC File "${FILES_MSVC}\"
71 # Components of Ghostscript
72 SetOutPath "$INSTDIR\ghostscript"
73 !insertmacro FileListGhostscript File "${FILES_GHOSTSCRIPT}\"
74 !insertmacro FileListMSVC File "${FILES_MSVC}\"
77 WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
81 #--------------------------------
82 # Support code for file downloads
84 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
88 # RET = Return value (OK if succesful)
89 # ID = Name of the download in settings.nsh
90 # FILENAME = Location to store file
91 # APPEND = Filename to append to server location in settings.nsh
94 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
95 Pop ${RET} # Return value (OK if succesful)
98 # Download failed, try again (usally we get a different mirror)
99 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
105 #--------------------------------
106 # Extenral components
111 !macro EXTERNAL COMPONENT
113 # Download/Install the component
115 ${If} $Setup${COMPONENT} == ${TRUE}
117 StrCpy $Path${COMPONENT} "" ;A new one will be installed
119 !ifndef BUNDLESETUP_${COMPONENT}
120 !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
122 !insertmacro EXTERNAL_INSTALL ${COMPONENT}
129 !macro EXTERNAL_RUNINSTALLER COMPONENT
131 # Run the installer application of the component that does the actual installation.
133 install_${COMPONENT}:
135 ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
137 # Updates the path environment variable of the instaler process to the latest system value
138 ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
139 ReadRegStr $PathCurrentUser HKCU "Environment" Path
140 System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
142 Call Search${COMPONENT}
144 ${If} $Path${COMPONENT} == ""
145 MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
148 Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
152 !macro EXTERNAL_DOWNLOAD COMPONENT
154 download_${COMPONENT}:
156 !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
158 ${If} $DownloadResult != "OK"
160 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
161 Goto noinstall_${COMPONENT}
164 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
166 noinstall_${COMPONENT}:
170 !macro EXTERNAL_INSTALL COMPONENT
173 File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
175 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
180 # Sections for external components
182 Section -LaTeX ExternalLaTeX
183 !insertmacro EXTERNAL LaTeX
186 Function InitExternal
188 # Get sizes of external component installers
190 SectionGetSize ${ExternalLaTeX} $SizeLaTeX
194 !ifndef BUNDLESETUP_MIKTEX
195 IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}