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 FileListDll File "${FILES_DEPS}\bin\"
52 !insertmacro FileListMSVC File "${FILES_MSVC}\"
53 !insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
54 !insertmacro FileListDTLBin File "${FILES_DTL}\"
55 !insertmacro FileListRsvg File "${FILES_RSVG}\"
56 !insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
57 !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
58 !insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
59 !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
63 # recursively copy all files under Resources
64 File /r "${FILES_LYX}\Resources"
66 !if ${SETUPTYPE} == BUNDLE
68 # extract the Jabref and MiKTeX installer
69 File /r "${FILES_LYX}\external"
71 # install MiKTeX if not already installed
72 Call InstallMiKTeX # function from LaTeX.nsh
74 !endif # end if BUNDLE
78 # recursively copy all files under Python
79 File /r "${FILES_PYTHON}"
80 # register .py files if necessary
81 ReadRegStr $0 SHCTX "Software\Classes\Python.File\shell\open\command" ""
82 ${if} $0 == "" # if nothing was found
83 WriteRegStr SHCTX "Software\Classes\Python.File\shell\open\command" "" '"$INSTDIR\Python\python.exe" "%1" %*'
84 WriteRegStr SHCTX "Software\Classes\Python.File\DefaultIcon" "" "$INSTDIR\Python\DLLs\py.ico"
85 WriteRegStr SHCTX "Software\Classes\.py" "" "Python.File"
86 WriteRegStr SHCTX "Software\Classes\Python.File" "OnlyWithLyX" "Yes${APP_SERIES_KEY}" # special entry to test if they were registered by this LyX version
89 # Compile all Pyton files to byte-code
90 # The user using the scripts may not have write access
91 FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
92 FileWrite $PythonCompileFile "import compileall$\r$\n"
93 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
94 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
95 FileClose $PythonCompileFile
96 DetailPrint $(TEXT_CONFIGURE_PYTHON)
97 nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
98 Pop $PythonCompileReturn # Return value
99 Delete "$INSTDIR\compilepy.py"
101 # Components of ImageMagick
102 SetOutPath "$INSTDIR\imagemagick"
103 File /r "${FILES_IMAGEMAGICK}\"
104 !insertmacro FileListMSVC File "${FILES_MSVC}\"
105 # register ImageMagick
106 WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" "$INSTDIR\imagemagick\convert.exe $$"
107 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "BinPath" "$INSTDIR\imagemagick"
108 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
109 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "ConfigurePath" "$INSTDIR\imagemagick"
110 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
111 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "LibPath" "$INSTDIR\imagemagick"
112 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "BinPath" "$INSTDIR\imagemagick"
113 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
114 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "ConfigurePath" "$INSTDIR\imagemagick"
115 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
116 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "LibPath" "$INSTDIR\imagemagick"
117 WriteRegDWORD SHCTX "SOFTWARE\ImageMagick\Current" "QuantumDepth" 0x00000010
118 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "Version" "${ImageMagickVersion}"
119 WriteRegStr SHCTX "SOFTWARE\ImageMagick" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
121 # Components of Ghostscript
122 ${if} $GhostscriptPath == ""
123 SetOutPath "$INSTDIR\ghostscript"
124 File /r "${FILES_GHOSTSCRIPT}\"
125 !insertmacro FileListMSVC File "${FILES_MSVC}\"
126 StrCpy $GhostscriptPath "$INSTDIR\ghostscript\bin"
129 !if ${SETUPTYPE} == BUNDLE
131 # install JabRef if not already installed and the user selected it
132 # if no BibTeX editor is installed
133 ${if} $PathBibTeXEditor == ""
134 ${andif} $InstallJabRef == "true"
136 MessageBox MB_OK|MB_ICONINFORMATION "$(JabRefInfo)" /SD IDOK
138 ExecWait "$INSTDIR\${JabRefInstall} /S"
139 ExecWait "$INSTDIR\${JabRefInstall}"
140 # test if JabRef is now installed
141 StrCpy $PathBibTeXEditor ""
142 ${if} $MultiUser.Privileges == "Admin"
143 ${orif} $MultiUser.Privileges == "Power"
144 ReadRegStr $PathBibTeXEditor HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"
145 StrCpy $PathBibTeXEditor $PathBibTeXEditor -14 # remove "\uninstall.exe"
147 # for non-admin users we can only check if it is in the start menu
148 ReadRegStr $PathBibTeXEditor HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "StartMenu"
150 ${if} $PathBibTeXEditor == ""
151 MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)" /SD IDOK
153 # special entry that it was installed together with LyX
154 # so that we can later uninstall it together with LyX
155 ${if} $MultiUser.Privileges == "Admin"
156 ${orif} $MultiUser.Privileges == "Power"
157 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
159 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
162 ${endif} # end if PathBibTeXEditor
163 !endif # end if BUNDLE
166 SetOutPath "$INSTDIR\Python\Lib"
167 !insertmacro FileListeLyXer File "${FILES_ELYXER}\"
170 SetOutPath "$INSTDIR\Python\Lib"
171 !insertmacro FileListUnoConv File "${FILES_UNOCONV}\"
173 # install the LaTeX class files that are delivered with LyX to MiKTeX
174 # and enable MiKTeX's automatic package installation
175 ${if} $LaTeXInstalled == "MiKTeX"
176 Call ConfigureMiKTeX # Function from LaTeX.nsh
178 # install the LaTeX class files that are delivered with LyX to TeXLive
179 ${if} $LaTeXInstalled == "TeXLive"
180 Call ConfigureTeXLive # Function from LaTeX.nsh
183 # download dictionaries and thesaurus
184 ${if} $DictCodes != ""
185 Call InstallHunspellDictionaries # Function from dictionaries.nsh
187 ${if} $ThesCodes != ""
188 Call InstallThesaurusDictionaries # Function from dictionaries.nsh
190 # finally delete the list of mirrors
191 Delete "$INSTDIR\Resources\DictionaryMirrors.txt"
194 WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
198 #--------------------------------
199 # Support code for file downloads
201 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
205 # RET = Return value (OK if succesful)
206 # ID = Name of the download in settings.nsh
207 # FILENAME = Location to store file
208 # APPEND = Filename to append to server location in settings.nsh
211 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
212 Pop ${RET} # Return value (OK if succesful)
214 ${If} ${RET} != "success"
215 ${AndIf} ${RET} != "cancel"
216 # Download failed, try once again before giving up
217 # (usally we get a different mirror)
218 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
224 #--------------------------------
225 # External components
230 !macro EXTERNAL COMPONENT
232 # Download/Install the component
234 ${If} $Setup${COMPONENT} == ${TRUE}
236 StrCpy $Path${COMPONENT} "" ;A new one will be installed
238 !ifndef BUNDLESETUP_${COMPONENT}
239 !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
241 !insertmacro EXTERNAL_INSTALL ${COMPONENT}
248 !macro EXTERNAL_RUNINSTALLER COMPONENT
250 # Run the installer application of the component that does the actual installation.
252 install_${COMPONENT}:
254 ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
256 # Updates the path environment variable of the installer process to the latest system value
257 # ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
258 # ReadRegStr $PathCurrentUser HKCU "Environment" Path
259 # System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
261 Call Search${COMPONENT}
263 ${If} $Path${COMPONENT} == ""
264 MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
267 Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
271 !macro EXTERNAL_DOWNLOAD COMPONENT
273 download_${COMPONENT}:
275 !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
277 ${If} $DownloadResult != "success"
278 ${AndIf} $DownloadResult != "cancel"
279 # Download failed after trying twice - ask user
280 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
281 Goto noinstall_${COMPONENT}
284 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
286 noinstall_${COMPONENT}:
290 !macro EXTERNAL_INSTALL COMPONENT
293 File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
295 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
300 # Sections for external components
302 #Section -LaTeX ExternalLaTeX
303 # !insertmacro EXTERNAL LaTeX
306 /*Function InitExternal
308 # Get sizes of external component installers
310 #SectionGetSize ${ExternalLaTeX} $SizeLaTeX
314 !ifndef BUNDLESETUP_MIKTEX
315 IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}