5 Installation of program files, dictionaries and external components
9 #--------------------------------
13 Var PythonCompileReturn
15 Section -ProgramFiles SecProgramFiles
17 !if ${SETUPTYPE} != BUNDLE
18 # abort the installation if no LaTeX was found but should be used
19 ${if} $PathLaTeX == ""
20 ${andif} $State == "0"
21 SetOutPath $TEMP # to be able to delete the $INSTDIR
25 !endif # end if != BUNDLE
27 # Install and register the core LyX files
29 # The macros are defined in filelists.nsh
30 # the parameters are COMMAND DIRECTORY that form command '${COMMAND} "${DIRECTORY}files"
32 # Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
33 # $PLUGINSDIR is automatically deleted when the installer exits.
37 SetOutPath "$INSTDIR\bin"
38 !insertmacro FileListLyXBin File "${FILES_LYX}\bin\"
39 !insertmacro FileListQtBin File "${FILES_QT}\bin\"
40 !insertmacro FileListQtImageformats File "${FILES_QT}\plugins\imageformats\"
41 !insertmacro FileListDll File "${FILES_DEPS}\bin\"
42 !insertmacro FileListMSVC File "${FILES_MSVC}\"
43 !insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
44 !insertmacro FileListDTLBin File "${FILES_DTL}\"
45 !insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
46 !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
47 !insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
48 !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
52 # recursively copy all files under Resources
53 File /r "${FILES_LYX}\Resources"
55 !if ${SETUPTYPE} == BUNDLE
57 # extract the Jabref and MiKTeX installer
58 File /r "${FILES_LYX}\external"
60 # install MiKTeX if not already installed
61 Call InstallMiKTeX # function from LaTeX.nsh
63 !endif # end if BUNDLE
67 # recursively copy all files under Python
68 File /r "${FILES_PYTHON}"
70 # Compile all Pyton files to byte-code
71 # The user using the scripts may not have write access
72 FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
73 FileWrite $PythonCompileFile "import compileall$\r$\n"
74 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
75 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
76 FileClose $PythonCompileFile
77 DetailPrint $(TEXT_CONFIGURE_PYTHON)
78 nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
79 Pop $PythonCompileReturn # Return value
80 Delete "$INSTDIR\compilepy.py"
82 # Components of ImageMagick
83 SetOutPath "$INSTDIR\imagemagick"
84 File /r "${FILES_IMAGEMAGICK}\"
85 !insertmacro FileListMSVC File "${FILES_MSVC}\"
86 # register ImageMagick
87 WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" "$INSTDIR\imagemagick\convert.exe $$"
88 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "BinPath" "$INSTDIR\imagemagick"
89 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
90 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "ConfigurePath" "$INSTDIR\imagemagick"
91 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
92 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "LibPath" "$INSTDIR\imagemagick"
93 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "BinPath" "$INSTDIR\imagemagick"
94 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
95 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "ConfigurePath" "$INSTDIR\imagemagick"
96 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
97 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "LibPath" "$INSTDIR\imagemagick"
98 WriteRegDWORD SHCTX "SOFTWARE\ImageMagick\Current" "QuantumDepth" 0x00000010
99 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "Version" "${ImageMagickVersion}"
100 WriteRegStr SHCTX "SOFTWARE\ImageMagick" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
102 # Components of Ghostscript
103 ${if} $GhostscriptPath == ""
104 SetOutPath "$INSTDIR\ghostscript"
105 File /r "${FILES_GHOSTSCRIPT}\"
106 !insertmacro FileListMSVC File "${FILES_MSVC}\"
107 StrCpy $GhostscriptPath "$INSTDIR\ghostscript\bin"
110 !if ${SETUPTYPE} == BUNDLE
112 # install JabRef if not already installed and the user selected it
113 # if no BibTeX editor is installed
114 ${if} $PathBibTeXEditor == ""
115 ${andif} $InstallJabRef == "true"
117 MessageBox MB_OK|MB_ICONINFORMATION "$(JabRefInfo)" /SD IDOK
119 ExecWait "$INSTDIR\${JabRefInstall} /S"
120 ExecWait "$INSTDIR\${JabRefInstall}"
121 # test if JabRef is now installed
122 StrCpy $PathBibTeXEditor ""
123 ${if} $MultiUser.Privileges == "Admin"
124 ${orif} $MultiUser.Privileges == "Power"
125 ReadRegStr $PathBibTeXEditor HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"
126 StrCpy $PathBibTeXEditor $PathBibTeXEditor -14 # remove "\uninstall.exe"
128 # for non-admin users we can only check if it is in the start menu
129 ReadRegStr $PathBibTeXEditor HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "StartMenu"
131 ${if} $PathBibTeXEditor == ""
132 MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)" /SD IDOK
134 # special entry that it was installed together with LyX
135 # so that we can later uninstall it together with LyX
136 ${if} $MultiUser.Privileges == "Admin"
137 ${orif} $MultiUser.Privileges == "Power"
138 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
140 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
143 ${endif} # end if PathBibTeXEditor
144 !endif # end if BUNDLE
147 SetOutPath "$INSTDIR\Python\Lib"
148 !insertmacro FileListeLyXer File "${FILES_ELYXER}\"
151 SetOutPath "$INSTDIR\Python\Lib"
152 !insertmacro FileListUnoConv File "${FILES_UNOCONV}\"
154 # install the LaTeX class files that are delivered with LyX to MiKTeX
155 # and enable MiKTeX's automatic package installation
156 ${if} $LaTeXInstalled == "MiKTeX"
157 Call ConfigureMiKTeX # Function from LaTeX.nsh
159 # install the LaTeX class files that are delivered with LyX to TeXLive
160 ${if} $LaTeXInstalled == "TeXLive"
161 Call ConfigureTeXLive # Function from LaTeX.nsh
164 # download dictionaries and thesaurus
165 ${if} $DictCodes != ""
166 Call InstallHunspellDictionaries # Function from dictionaries.nsh
168 ${if} $ThesCodes != ""
169 Call InstallThesaurusDictionaries # Function from dictionaries.nsh
171 # finally delete the list of mirrors
172 Delete "$INSTDIR\Resources\DictionaryMirrors.txt"
175 WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
179 #--------------------------------
180 # Support code for file downloads
182 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
186 # RET = Return value (OK if succesful)
187 # ID = Name of the download in settings.nsh
188 # FILENAME = Location to store file
189 # APPEND = Filename to append to server location in settings.nsh
192 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
193 Pop ${RET} # Return value (OK if succesful)
195 ${If} ${RET} != "success"
196 ${AndIf} ${RET} != "cancel"
197 # Download failed, try once again before giving up
198 # (usally we get a different mirror)
199 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
205 #--------------------------------
206 # External components
211 !macro EXTERNAL COMPONENT
213 # Download/Install the component
215 ${If} $Setup${COMPONENT} == ${TRUE}
217 StrCpy $Path${COMPONENT} "" ;A new one will be installed
219 !ifndef BUNDLESETUP_${COMPONENT}
220 !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
222 !insertmacro EXTERNAL_INSTALL ${COMPONENT}
229 !macro EXTERNAL_RUNINSTALLER COMPONENT
231 # Run the installer application of the component that does the actual installation.
233 install_${COMPONENT}:
235 ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
237 # Updates the path environment variable of the installer process to the latest system value
238 # ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
239 # ReadRegStr $PathCurrentUser HKCU "Environment" Path
240 # System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
242 Call Search${COMPONENT}
244 ${If} $Path${COMPONENT} == ""
245 MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
248 Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
252 !macro EXTERNAL_DOWNLOAD COMPONENT
254 download_${COMPONENT}:
256 !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
258 ${If} $DownloadResult != "success"
259 ${AndIf} $DownloadResult != "cancel"
260 # Download failed after trying twice - ask user
261 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
262 Goto noinstall_${COMPONENT}
265 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
267 noinstall_${COMPONENT}:
271 !macro EXTERNAL_INSTALL COMPONENT
274 File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
276 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
281 # Sections for external components
283 #Section -LaTeX ExternalLaTeX
284 # !insertmacro EXTERNAL LaTeX
287 /*Function InitExternal
289 # Get sizes of external component installers
291 #SectionGetSize ${ExternalLaTeX} $SizeLaTeX
295 !ifndef BUNDLESETUP_MIKTEX
296 IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}