]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/install.nsh
installer: support 64bit MiKTeX
[features.git] / development / Win32 / packaging / installer / setup / install.nsh
1 /*
2
3 install.nsh
4
5 Installation of program files, dictionaries and external components
6
7 */
8
9 #--------------------------------
10 # Program files
11
12 Var PythonCompileFile
13 Var PythonCompileReturn
14
15 Section -ProgramFiles SecProgramFiles
16
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
22    RMDir /r $INSTDIR
23    Abort
24   ${endif}
25  !endif # end if != BUNDLE
26
27   # Install and register the core LyX files
28   
29   # The macros are defined in filelists.nsh
30   # the parameters are COMMAND DIRECTORY that form command '${COMMAND} "${DIRECTORY}files"  
31   
32   # Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
33   # $PLUGINSDIR is automatically deleted when the installer exits.
34   InitPluginsDir
35   
36   # Binaries
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}\"
49   
50   # Resources
51   SetOutPath "$INSTDIR"
52   # recursively copy all files under Resources
53   File /r "${FILES_LYX}\Resources"
54   
55   !if ${SETUPTYPE} == BUNDLE
56    
57    # extract the Jabref and MiKTeX installer
58    File /r "${FILES_LYX}\external"
59
60    # install MiKTeX if not already installed
61    Call InstallMiKTeX # function from LaTeX.nsh
62    
63   !endif # end if BUNDLE
64   
65   # Python
66   SetOutPath "$INSTDIR"
67   # recursively copy all files under Python
68   File /r "${FILES_PYTHON}"
69   
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"
81   
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}"
101   
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"
108   ${endif}
109   
110   !if ${SETUPTYPE} == BUNDLE
111    
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"
116     # launch installer
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"
125     ${else}
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"
128     ${endif}
129     ${if} $PathBibTeXEditor == ""
130      MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)"
131     ${else}
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}"
137      ${else}
138       WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
139      ${endif}
140     ${endif} 
141    ${endif} # end if PathBibTeXEditor
142   !endif # end if BUNDLE
143   
144    # install eLyXer
145    SetOutPath "$INSTDIR\Python\Lib"
146    !insertmacro FileListeLyXer File "${FILES_ELYXER}\"
147    
148    # install unoconv
149    SetOutPath "$INSTDIR\Python\Lib"
150    !insertmacro FileListUnoConv File "${FILES_UNOCONV}\"
151
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
156   ${endif}
157   # install the LaTeX class files that are delivered with LyX to TeXLive
158   ${if} $LaTeXInstalled == "TeXLive"
159    Call ConfigureTeXLive # Function from LaTeX.nsh
160   ${endif}
161   
162   # download dictionaries and thesaurus
163   ${if} $DictCodes != ""
164    Call InstallHunspellDictionaries # Function from dictionaries.nsh
165   ${endif}
166   ${if} $ThesCodes != ""
167    Call InstallThesaurusDictionaries # Function from dictionaries.nsh
168   ${endif}
169   # finally delete the list of mirrors
170   Delete "$INSTDIR\Resources\DictionaryMirrors.txt"
171   
172   # Create uninstaller
173   WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
174
175 SectionEnd
176
177 #--------------------------------
178 # Support code for file downloads
179
180 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
181
182   # Downloads a file
183   
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
188
189   # Try first time
190   NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
191   Pop ${RET} # Return value (OK if succesful)
192
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}"
198     Pop ${RET}
199   ${EndIf}
200
201 !macroend
202
203 #--------------------------------
204 # External components
205
206 #Var PathAllUsers
207 #Var PathCurrentUser
208
209 !macro EXTERNAL COMPONENT
210
211   # Download/Install the component
212   
213   ${If} $Setup${COMPONENT} == ${TRUE}
214   
215     StrCpy $Path${COMPONENT} "" ;A new one will be installed
216   
217     !ifndef BUNDLESETUP_${COMPONENT}
218       !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
219     !else
220       !insertmacro EXTERNAL_INSTALL ${COMPONENT}
221     !endif
222     
223   ${EndIf}
224
225 !macroend
226
227 !macro EXTERNAL_RUNINSTALLER COMPONENT
228
229   # Run the installer application of the component that does the actual installation.
230
231   install_${COMPONENT}:
232       
233     ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
234     
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").'
239
240     Call Search${COMPONENT}
241     
242     ${If} $Path${COMPONENT} == ""  
243       MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
244     ${EndIf}
245       
246     Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
247      
248 !macroend
249
250 !macro EXTERNAL_DOWNLOAD COMPONENT
251
252   download_${COMPONENT}:
253
254     !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
255  
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}
261     ${EndIf}
262       
263     !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
264       
265   noinstall_${COMPONENT}:
266
267 !macroend
268
269 !macro EXTERNAL_INSTALL COMPONENT
270
271   # Extract
272   File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
273     
274   !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
275     
276 !macroend
277
278
279 # Sections for external components
280
281 #Section -LaTeX ExternalLaTeX
282 #  !insertmacro EXTERNAL LaTeX
283 #SectionEnd
284
285 /*Function InitExternal
286
287   # Get sizes of external component installers
288   
289   #SectionGetSize ${ExternalLaTeX} $SizeLaTeX
290   
291   # Add download size
292   
293   !ifndef BUNDLESETUP_MIKTEX
294     IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
295   !endif
296
297 FunctionEnd*/