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 FileListDvipostBin File "${FILES_DVIPOST}\"
56 !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
57 !insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
58 !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
62 # recursively copy all files under Resources
63 File /r "${FILES_LYX}\Resources"
65 !if ${SETUPTYPE} == BUNDLE
67 # extract the Jabref and MiKTeX installer
68 File /r "${FILES_LYX}\external"
70 # install MiKTeX if not already installed
71 Call InstallMiKTeX # function from LaTeX.nsh
73 !endif # end if BUNDLE
77 # recursively copy all files under Python
78 File /r "${FILES_PYTHON}"
80 # Compile all Pyton files to byte-code
81 # The user using the scripts may not have write access
82 FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
83 FileWrite $PythonCompileFile "import compileall$\r$\n"
84 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
85 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
86 FileClose $PythonCompileFile
87 DetailPrint $(TEXT_CONFIGURE_PYTHON)
88 nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
89 Pop $PythonCompileReturn # Return value
90 Delete "$INSTDIR\compilepy.py"
92 # Components of ImageMagick
93 SetOutPath "$INSTDIR\imagemagick"
94 File /r "${FILES_IMAGEMAGICK}\"
95 !insertmacro FileListMSVC File "${FILES_MSVC}\"
96 # register ImageMagick
97 WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" "$INSTDIR\imagemagick\convert.exe $$"
98 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "BinPath" "$INSTDIR\imagemagick"
99 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
100 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "ConfigurePath" "$INSTDIR\imagemagick"
101 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
102 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "LibPath" "$INSTDIR\imagemagick"
103 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "BinPath" "$INSTDIR\imagemagick"
104 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
105 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "ConfigurePath" "$INSTDIR\imagemagick"
106 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
107 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "LibPath" "$INSTDIR\imagemagick"
108 WriteRegDWORD SHCTX "SOFTWARE\ImageMagick\Current" "QuantumDepth" 0x00000010
109 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "Version" "${ImageMagickVersion}"
110 WriteRegStr SHCTX "SOFTWARE\ImageMagick" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
112 # Components of Ghostscript
113 ${if} $GhostscriptPath == ""
114 SetOutPath "$INSTDIR\ghostscript"
115 File /r "${FILES_GHOSTSCRIPT}\"
116 !insertmacro FileListMSVC File "${FILES_MSVC}\"
117 StrCpy $GhostscriptPath "$INSTDIR\ghostscript\bin"
120 !if ${SETUPTYPE} == BUNDLE
122 # install JabRef if not already installed and the user selected it
123 # if no BibTeX editor is installed
124 ${if} $PathBibTeXEditor == ""
125 ${andif} $InstallJabRef == "true"
127 MessageBox MB_OK|MB_ICONINFORMATION "$(JabRefInfo)" /SD IDOK
129 ExecWait "$INSTDIR\${JabRefInstall} /S"
130 ExecWait "$INSTDIR\${JabRefInstall}"
131 # test if JabRef is now installed
132 StrCpy $PathBibTeXEditor ""
133 ${if} $MultiUser.Privileges == "Admin"
134 ${orif} $MultiUser.Privileges == "Power"
135 ReadRegStr $PathBibTeXEditor HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"
136 StrCpy $PathBibTeXEditor $PathBibTeXEditor -14 # remove "\uninstall.exe"
138 # for non-admin users we can only check if it is in the start menu
139 ReadRegStr $PathBibTeXEditor HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "StartMenu"
141 ${if} $PathBibTeXEditor == ""
142 MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)" /SD IDOK
144 # special entry that it was installed together with LyX
145 # so that we can later uninstall it together with LyX
146 ${if} $MultiUser.Privileges == "Admin"
147 ${orif} $MultiUser.Privileges == "Power"
148 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
150 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
153 ${endif} # end if PathBibTeXEditor
154 !endif # end if BUNDLE
157 SetOutPath "$INSTDIR\Python\Lib"
158 !insertmacro FileListeLyXer File "${FILES_ELYXER}\"
161 SetOutPath "$INSTDIR\Python\Lib"
162 !insertmacro FileListUnoConv File "${FILES_UNOCONV}\"
164 # install the LaTeX class files that are delivered with LyX to MiKTeX
165 # and enable MiKTeX's automatic package installation
166 ${if} $LaTeXInstalled == "MiKTeX"
167 Call ConfigureMiKTeX # Function from LaTeX.nsh
169 # install the LaTeX class files that are delivered with LyX to TeXLive
170 ${if} $LaTeXInstalled == "TeXLive"
171 Call ConfigureTeXLive # Function from LaTeX.nsh
174 # download dictionaries and thesaurus
175 ${if} $DictCodes != ""
176 Call InstallHunspellDictionaries # Function from dictionaries.nsh
178 ${if} $ThesCodes != ""
179 Call InstallThesaurusDictionaries # Function from dictionaries.nsh
181 # finally delete the list of mirrors
182 Delete "$INSTDIR\Resources\DictionaryMirrors.txt"
185 WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
189 #--------------------------------
190 # Support code for file downloads
192 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
196 # RET = Return value (OK if succesful)
197 # ID = Name of the download in settings.nsh
198 # FILENAME = Location to store file
199 # APPEND = Filename to append to server location in settings.nsh
202 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
203 Pop ${RET} # Return value (OK if succesful)
205 ${If} ${RET} != "success"
206 ${AndIf} ${RET} != "cancel"
207 # Download failed, try once again before giving up
208 # (usally we get a different mirror)
209 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
215 #--------------------------------
216 # External components
221 !macro EXTERNAL COMPONENT
223 # Download/Install the component
225 ${If} $Setup${COMPONENT} == ${TRUE}
227 StrCpy $Path${COMPONENT} "" ;A new one will be installed
229 !ifndef BUNDLESETUP_${COMPONENT}
230 !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
232 !insertmacro EXTERNAL_INSTALL ${COMPONENT}
239 !macro EXTERNAL_RUNINSTALLER COMPONENT
241 # Run the installer application of the component that does the actual installation.
243 install_${COMPONENT}:
245 ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
247 # Updates the path environment variable of the installer process to the latest system value
248 # ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
249 # ReadRegStr $PathCurrentUser HKCU "Environment" Path
250 # System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
252 Call Search${COMPONENT}
254 ${If} $Path${COMPONENT} == ""
255 MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
258 Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
262 !macro EXTERNAL_DOWNLOAD COMPONENT
264 download_${COMPONENT}:
266 !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
268 ${If} $DownloadResult != "success"
269 ${AndIf} $DownloadResult != "cancel"
270 # Download failed after trying twice - ask user
271 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
272 Goto noinstall_${COMPONENT}
275 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
277 noinstall_${COMPONENT}:
281 !macro EXTERNAL_INSTALL COMPONENT
284 File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
286 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
291 # Sections for external components
293 #Section -LaTeX ExternalLaTeX
294 # !insertmacro EXTERNAL LaTeX
297 /*Function InitExternal
299 # Get sizes of external component installers
301 #SectionGetSize ${ExternalLaTeX} $SizeLaTeX
305 !ifndef BUNDLESETUP_MIKTEX
306 IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}