5 Installation of program files, dictionaries and external components
9 #--------------------------------
13 Var PythonCompileReturn
15 Section -ProgramFiles SecProgramFiles
17 # if the $INSTDIR does not contain "LyX" we must add a subfolder to avoid that LyX will e.g.
18 # be installed directly to C:\programs - the uninstaller will then delete the whole
19 # C:\programs directory
20 StrCpy $String $INSTDIR
22 Call StrPoint # function from LyXUtils.nsh
23 ${if} $Pointer == "-1"
24 StrCpy $INSTDIR "$INSTDIR\${APP_DIR}"
27 !if ${SETUPTYPE} != BUNDLE
28 # abort the installation if no LaTeX was found but should be used
29 ${if} $PathLaTeX == ""
30 ${andif} $State == "0"
31 SetOutPath $TEMP # to be able to delete the $INSTDIR
35 !endif # end if != BUNDLE
37 # Install and register the core LyX files
39 # The macros are defined in filelists.nsh
40 # the parameters are COMMAND DIRECTORY that form command '${COMMAND} "${DIRECTORY}files"
42 # Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
43 # $PLUGINSDIR is automatically deleted when the installer exits.
47 SetOutPath "$INSTDIR\bin"
48 !insertmacro FileListLyXBin File "${FILES_LYX}\bin\"
49 !insertmacro FileListQtBin File "${FILES_QT}\bin\"
50 !insertmacro FileListQtImageformats File "${FILES_QT}\plugins\imageformats\"
51 !insertmacro FileListQtIconengines File "${FILES_QT}\plugins\iconengines\"
52 !insertmacro FileListDll File "${FILES_DEPS}\bin\"
53 !insertmacro FileListMSVC File "${FILES_MSVC}\"
54 !insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
55 !insertmacro FileListDTLBin File "${FILES_DTL}\"
56 !insertmacro FileListRsvg File "${FILES_RSVG}\"
57 !insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
58 !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
59 !insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
60 !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
64 # recursively copy all files under Resources
65 File /r "${FILES_LYX}\Resources"
67 !if ${SETUPTYPE} == BUNDLE
69 # extract the Jabref and MiKTeX installer
70 File /r "${FILES_LYX}\external"
72 # install MiKTeX if not already installed
73 Call InstallMiKTeX # function from LaTeX.nsh
75 !endif # end if BUNDLE
79 # recursively copy all files under Python
80 File /r "${FILES_PYTHON}"
81 # register .py files if necessary
82 ReadRegStr $0 SHCTX "Software\Classes\Python.File\shell\open\command" ""
83 ${if} $0 == "" # if nothing was found
84 WriteRegStr SHCTX "Software\Classes\Python.File\shell\open\command" "" '"$INSTDIR\Python\python.exe" "%1" %*'
85 WriteRegStr SHCTX "Software\Classes\Python.File\DefaultIcon" "" "$INSTDIR\Python\DLLs\py.ico"
86 WriteRegStr SHCTX "Software\Classes\.py" "" "Python.File"
87 WriteRegStr SHCTX "Software\Classes\Python.File" "OnlyWithLyX" "Yes${APP_SERIES_KEY}" # special entry to test if they were registered by this LyX version
90 # Compile all Pyton files to byte-code
91 # The user using the scripts may not have write access
92 FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
93 FileWrite $PythonCompileFile "import compileall$\r$\n"
94 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
95 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
96 FileClose $PythonCompileFile
97 DetailPrint $(TEXT_CONFIGURE_PYTHON)
98 nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
99 Pop $PythonCompileReturn # Return value
100 Delete "$INSTDIR\compilepy.py"
102 # Components of ImageMagick
103 SetOutPath "$INSTDIR\imagemagick"
104 File /r "${FILES_IMAGEMAGICK}\"
105 !insertmacro FileListMSVC File "${FILES_MSVC}\"
106 # register ImageMagick
107 WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" "$INSTDIR\imagemagick\convert.exe $$"
108 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "BinPath" "$INSTDIR\imagemagick"
109 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
110 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "ConfigurePath" "$INSTDIR\imagemagick"
111 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
112 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "LibPath" "$INSTDIR\imagemagick"
113 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "BinPath" "$INSTDIR\imagemagick"
114 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
115 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "ConfigurePath" "$INSTDIR\imagemagick"
116 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
117 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "LibPath" "$INSTDIR\imagemagick"
118 WriteRegDWORD SHCTX "SOFTWARE\ImageMagick\Current" "QuantumDepth" 0x00000010
119 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "Version" "${ImageMagickVersion}"
120 WriteRegStr SHCTX "SOFTWARE\ImageMagick" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
122 # Components of Ghostscript
123 ${if} $GhostscriptPath == ""
124 SetOutPath "$INSTDIR\ghostscript"
125 File /r "${FILES_GHOSTSCRIPT}\"
126 !insertmacro FileListMSVC File "${FILES_MSVC}\"
127 StrCpy $GhostscriptPath "$INSTDIR\ghostscript\bin"
130 !if ${SETUPTYPE} == BUNDLE
132 # install JabRef if not already installed and the user selected it
133 # if no BibTeX editor is installed
134 ${if} $PathBibTeXEditor == ""
135 ${andif} $InstallJabRef == "true"
137 MessageBox MB_OK|MB_ICONINFORMATION "$(JabRefInfo)" /SD IDOK
139 ExecWait "$INSTDIR\${JabRefInstall} /S"
140 ExecWait "$INSTDIR\${JabRefInstall}"
141 # test if JabRef is now installed
142 StrCpy $PathBibTeXEditor ""
143 ${if} $MultiUser.Privileges == "Admin"
144 ${orif} $MultiUser.Privileges == "Power"
145 ReadRegStr $PathBibTeXEditor HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"
146 StrCpy $PathBibTeXEditor $PathBibTeXEditor -14 # remove "\uninstall.exe"
148 # for non-admin users we can only check if it is in the start menu
149 ReadRegStr $PathBibTeXEditor HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "StartMenu"
151 ${if} $PathBibTeXEditor == ""
152 MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)" /SD IDOK
154 # special entry that it was installed together with LyX
155 # so that we can later uninstall it together with LyX
156 ${if} $MultiUser.Privileges == "Admin"
157 ${orif} $MultiUser.Privileges == "Power"
158 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
160 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
163 ${endif} # end if PathBibTeXEditor
164 !endif # end if BUNDLE
167 SetOutPath "$INSTDIR\Python\Lib"
168 !insertmacro FileListeLyXer File "${FILES_ELYXER}\"
171 SetOutPath "$INSTDIR\Python\Lib"
172 !insertmacro FileListUnoConv File "${FILES_UNOCONV}\"
174 # install the LaTeX class files that are delivered with LyX to MiKTeX
175 # and enable MiKTeX's automatic package installation
176 ${if} $LaTeXInstalled == "MiKTeX"
177 Call ConfigureMiKTeX # Function from LaTeX.nsh
179 # install the LaTeX class files that are delivered with LyX to TeXLive
180 ${if} $LaTeXInstalled == "TeXLive"
181 Call ConfigureTeXLive # Function from LaTeX.nsh
184 # download dictionaries and thesaurus
185 ${if} $DictCodes != ""
186 Call InstallHunspellDictionaries # Function from dictionaries.nsh
188 ${if} $ThesCodes != ""
189 Call InstallThesaurusDictionaries # Function from dictionaries.nsh
191 # finally delete the list of mirrors
192 Delete "$INSTDIR\Resources\DictionaryMirrors.txt"
195 WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
199 #--------------------------------
200 # Support code for file downloads
202 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
206 # RET = Return value (OK if succesful)
207 # ID = Name of the download in settings.nsh
208 # FILENAME = Location to store file
209 # APPEND = Filename to append to server location in settings.nsh
212 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
213 Pop ${RET} # Return value (OK if succesful)
215 ${If} ${RET} != "success"
216 ${AndIf} ${RET} != "cancel"
217 # Download failed, try once again before giving up
218 # (usally we get a different mirror)
219 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
225 #--------------------------------
226 # External components
231 !macro EXTERNAL COMPONENT
233 # Download/Install the component
235 ${If} $Setup${COMPONENT} == ${TRUE}
237 StrCpy $Path${COMPONENT} "" ;A new one will be installed
239 !ifndef BUNDLESETUP_${COMPONENT}
240 !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
242 !insertmacro EXTERNAL_INSTALL ${COMPONENT}
249 !macro EXTERNAL_RUNINSTALLER COMPONENT
251 # Run the installer application of the component that does the actual installation.
253 install_${COMPONENT}:
255 ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
257 # Updates the path environment variable of the installer process to the latest system value
258 # ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
259 # ReadRegStr $PathCurrentUser HKCU "Environment" Path
260 # System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
262 Call Search${COMPONENT}
264 ${If} $Path${COMPONENT} == ""
265 MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
268 Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
272 !macro EXTERNAL_DOWNLOAD COMPONENT
274 download_${COMPONENT}:
276 !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
278 ${If} $DownloadResult != "success"
279 ${AndIf} $DownloadResult != "cancel"
280 # Download failed after trying twice - ask user
281 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
282 Goto noinstall_${COMPONENT}
285 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
287 noinstall_${COMPONENT}:
291 !macro EXTERNAL_INSTALL COMPONENT
294 File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
296 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
301 # Sections for external components
303 #Section -LaTeX ExternalLaTeX
304 # !insertmacro EXTERNAL LaTeX
307 /*Function InitExternal
309 # Get sizes of external component installers
311 #SectionGetSize ${ExternalLaTeX} $SizeLaTeX
315 !ifndef BUNDLESETUP_MIKTEX
316 IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}