5 Installation of program files, dictionaries and external components
9 #--------------------------------
13 Var PythonCompileReturn
16 Section -ProgramFiles SecProgramFiles
18 # Install and register the core LyX files
20 # The macros are defined in filelists.nsh
21 # the parameters are COMMAND DIRECTORY that form command '${COMMAND} "${DIRECTORY}files"
23 # Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
24 # $PLUGINSDIR is automatically deleted when the installer exits.
28 SetOutPath "$INSTDIR\bin"
29 !insertmacro FileListLyXBin File "${FILES_LYX}\bin\"
30 !insertmacro FileListQtBin File "${FILES_QT}\bin\"
31 !insertmacro FileListQtImageformats File "${FILES_QT}\plugins\imageformats\"
32 !insertmacro FileListDll File "${FILES_DEPS}\bin\"
33 !insertmacro FileListMSVC File "${FILES_MSVC}\"
34 !insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
35 !insertmacro FileListDTLBin File "${FILES_DTL}\"
36 !insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
37 !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
38 !insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
39 !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
43 # recursively copy all files under Resources
44 File /r "${FILES_LYX}\Resources"
46 !if ${SETUPTYPE} == BUNDLE
48 # extract the Jabref and MiKTeX installer
49 File /r "${FILES_LYX}\external"
51 # install MiKTeX if not already installed
52 Call InstallMiKTeX # function from LaTeX.nsh
54 !endif # end if BUNDLE
58 # recursively copy all files under Python
59 File /r "${FILES_PYTHON}"
61 # Compile all Pyton files to byte-code
62 # The user using the scripts may not have write access
63 FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
64 FileWrite $PythonCompileFile "import compileall$\r$\n"
65 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
66 FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
67 FileClose $PythonCompileFile
68 DetailPrint $(TEXT_CONFIGURE_PYTHON)
69 nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
70 Pop $PythonCompileReturn # Return value
71 Delete "$INSTDIR\compilepy.py"
73 # Components of ImageMagick
74 SetOutPath "$INSTDIR\imagemagick"
75 File /r "${FILES_IMAGEMAGICK}\"
76 !insertmacro FileListMSVC File "${FILES_MSVC}\"
77 # register ImageMagick
78 WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" "$INSTDIR\imagemagick\convert.exe $$"
79 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "BinPath" "$INSTDIR\imagemagick"
80 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
81 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "ConfigurePath" "$INSTDIR\imagemagick"
82 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
83 WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "LibPath" "$INSTDIR\imagemagick"
84 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "BinPath" "$INSTDIR\imagemagick"
85 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
86 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "ConfigurePath" "$INSTDIR\imagemagick"
87 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
88 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "LibPath" "$INSTDIR\imagemagick"
89 WriteRegDWORD SHCTX "SOFTWARE\ImageMagick\Current" "QuantumDepth" 0x00000010
90 WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "Version" "${ImageMagickVersion}"
92 # Components of Ghostscript
93 ${if} $GhostscriptPath == ""
94 SetOutPath "$INSTDIR\ghostscript"
95 File /r "${FILES_GHOSTSCRIPT}\"
96 !insertmacro FileListMSVC File "${FILES_MSVC}\"
97 StrCpy $GhostscriptPath "$INSTDIR\ghostscript\bin"
100 !if ${SETUPTYPE} == BUNDLE
102 # install JabRef if not already installed and the user selected it
103 # if no BibTeX editor is installed
104 ${if} $PathBibTeXEditor == ""
105 ${if} $InstallJabRef == "true"
107 MessageBox MB_OK|MB_ICONINFORMATION "$(JabRefInfo)"
108 ExecWait "$INSTDIR\${JabRefInstall}"
109 # test if JabRef is now installed
110 StrCpy $PathBibTeXEditor ""
111 ReadRegStr $PathBibTeXEditor SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"
112 ${if} $PathBibTeXEditor == ""
113 MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)"
115 # special entry that it was installed together with LyX
116 # so that we can later uninstall it together with LyX
117 ${if} $MultiUser.Privileges == "Admin"
118 ${orif} $MultiUser.Privileges == "Power"
119 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
121 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
123 ${endif} # end if PathBibTeXEditor
126 !endif # end if BUNDLE
129 SetOutPath "$INSTDIR\Python\Lib"
130 !insertmacro FileListeLyXer File "${FILES_ELYXER}\"
133 SetOutPath "$INSTDIR\Python\Lib"
134 !insertmacro FileListUnoConv File "${FILES_UNOCONV}\"
136 # install the LaTeX class files that are delivered with LyX
137 # and enable MiKTeX's automatic package installation
138 ${if} $LaTeXInstalled == "MiKTeX"
139 Call ConfigureMiKTeX # Function from LaTeX.nsh
142 # download dictionaries and thesaurus
143 ${if} $DictCodes != ""
144 Call InstallHunspellDictionaries # Function from dictionaries.nsh
146 ${if} $ThesCodes != ""
147 Call InstallThesaurusDictionaries # Function from dictionaries.nsh
149 # finally delete the list of mirrors
150 Delete "$INSTDIR\Resources\DictionaryMirrors.txt"
153 WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
157 #--------------------------------
158 # Support code for file downloads
160 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
164 # RET = Return value (OK if succesful)
165 # ID = Name of the download in settings.nsh
166 # FILENAME = Location to store file
167 # APPEND = Filename to append to server location in settings.nsh
170 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
171 Pop ${RET} # Return value (OK if succesful)
173 ${If} ${RET} != "success"
174 ${AndIf} ${RET} != "cancel"
175 # Download failed, try once again before giving up
176 # (usally we get a different mirror)
177 NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
183 #--------------------------------
184 # External components
189 !macro EXTERNAL COMPONENT
191 # Download/Install the component
193 ${If} $Setup${COMPONENT} == ${TRUE}
195 StrCpy $Path${COMPONENT} "" ;A new one will be installed
197 !ifndef BUNDLESETUP_${COMPONENT}
198 !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
200 !insertmacro EXTERNAL_INSTALL ${COMPONENT}
207 !macro EXTERNAL_RUNINSTALLER COMPONENT
209 # Run the installer application of the component that does the actual installation.
211 install_${COMPONENT}:
213 ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
215 # Updates the path environment variable of the installer process to the latest system value
216 # ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
217 # ReadRegStr $PathCurrentUser HKCU "Environment" Path
218 # System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
220 Call Search${COMPONENT}
222 ${If} $Path${COMPONENT} == ""
223 MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
226 Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
230 !macro EXTERNAL_DOWNLOAD COMPONENT
232 download_${COMPONENT}:
234 !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
236 ${If} $DownloadResult != "success"
237 ${AndIf} $DownloadResult != "cancel"
238 # Download failed after trying twice - ask user
239 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
240 Goto noinstall_${COMPONENT}
243 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
245 noinstall_${COMPONENT}:
249 !macro EXTERNAL_INSTALL COMPONENT
252 File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
254 !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
259 # Sections for external components
261 #Section -LaTeX ExternalLaTeX
262 # !insertmacro EXTERNAL LaTeX
265 /*Function InitExternal
267 # Get sizes of external component installers
269 #SectionGetSize ${ExternalLaTeX} $SizeLaTeX
273 !ifndef BUNDLESETUP_MIKTEX
274 IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}