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)"
118 ExecWait "$INSTDIR\${JabRefInstall}"
119 # test if JabRef is now installed
120 StrCpy $PathBibTeXEditor ""
121 ${if} $MultiUser.Privileges == "Admin"
122 ${orif} $MultiUser.Privileges == "Power"
123 ReadRegStr $PathBibTeXEditor HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"
124 StrCpy $PathBibTeXEditor $PathBibTeXEditor -14 # remove "\uninstall.exe"
126 # for non-admin users we can only check if it is in the start menu
127 ReadRegStr $PathBibTeXEditor HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "StartMenu"
129 ${if} $PathBibTeXEditor == ""
130 MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)"
132 # special entry that it was installed together with LyX
133 # so that we can later uninstall it together with LyX
134 ${if} $MultiUser.Privileges == "Admin"
135 ${orif} $MultiUser.Privileges == "Power"
136 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
138 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
141 ${endif} # end if PathBibTeXEditor
142 !endif # end if BUNDLE
145 SetOutPath "$INSTDIR\Python\Lib"
146 !insertmacro FileListeLyXer File "${FILES_ELYXER}\"
149 SetOutPath "$INSTDIR\Python\Lib"
150 !insertmacro FileListUnoConv File "${FILES_UNOCONV}\"
152 # install the LaTeX class files that are delivered with LyX to MiKTeX
153 # and enable MiKTeX's automatic package installation
154 ${if} $LaTeXInstalled == "MiKTeX"
155 Call ConfigureMiKTeX # Function from LaTeX.nsh
157 # install the LaTeX class files that are delivered with LyX to TeXLive
158 ${if} $LaTeXInstalled == "TeXLive"
159 Call ConfigureTeXLive # Function from LaTeX.nsh
162 # download dictionaries and thesaurus
163 ${if} $DictCodes != ""
164 Call InstallHunspellDictionaries # Function from dictionaries.nsh
166 ${if} $ThesCodes != ""
167 Call InstallThesaurusDictionaries # Function from dictionaries.nsh
169 # finally delete the list of mirrors
170 Delete "$INSTDIR\Resources\DictionaryMirrors.txt"
173 WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
177 #--------------------------------
178 # Support code for file downloads
180 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
184 # RET = Return value (OK if succesful)
185 # ID = Name of the download in settings.nsh
186 # FILENAME = Location to store file
187 # APPEND = Filename to append to server location in settings.nsh
190 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
191 Pop ${RET} # Return value (OK if succesful)
193 ${If} ${RET} != "success"
194 ${AndIf} ${RET} != "cancel"
195 # Download failed, try once again before giving up
196 # (usally we get a different mirror)
197 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
203 #--------------------------------
204 # External components
209 !macro EXTERNAL COMPONENT
211 # Download/Install the component
213 ${If} $Setup${COMPONENT} == ${TRUE}
215 StrCpy $Path${COMPONENT} "" ;A new one will be installed
217 !ifndef BUNDLESETUP_${COMPONENT}
218 !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
220 !insertmacro EXTERNAL_INSTALL ${COMPONENT}
227 !macro EXTERNAL_RUNINSTALLER COMPONENT
229 # Run the installer application of the component that does the actual installation.
231 install_${COMPONENT}:
233 ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
235 # Updates the path environment variable of the installer process to the latest system value
236 # ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
237 # ReadRegStr $PathCurrentUser HKCU "Environment" Path
238 # System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
240 Call Search${COMPONENT}
242 ${If} $Path${COMPONENT} == ""
243 MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
246 Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
250 !macro EXTERNAL_DOWNLOAD COMPONENT
252 download_${COMPONENT}:
254 !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
256 ${If} $DownloadResult != "success"
257 ${AndIf} $DownloadResult != "cancel"
258 # Download failed after trying twice - ask user
259 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
260 Goto noinstall_${COMPONENT}
263 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
265 noinstall_${COMPONENT}:
269 !macro EXTERNAL_INSTALL COMPONENT
272 File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
274 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
279 # Sections for external components
281 #Section -LaTeX ExternalLaTeX
282 # !insertmacro EXTERNAL LaTeX
285 /*Function InitExternal
287 # Get sizes of external component installers
289 #SectionGetSize ${ExternalLaTeX} $SizeLaTeX
293 !ifndef BUNDLESETUP_MIKTEX
294 IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}