]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/install.nsh
4c5b9203176945ca04958bcc0c2ec1f0a66b4463
[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 #Var DownloadResult
15
16 Section -ProgramFiles SecProgramFiles
17
18   # Install and register the core LyX files
19   
20   # The macros are defined in filelists.nsh
21   # the parameters are COMMAND DIRECTORY that form command '${COMMAND} "${DIRECTORY}files"  
22   
23   # Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
24   # $PLUGINSDIR is automatically deleted when the installer exits.
25   InitPluginsDir
26   
27   # Binaries
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}\"
40   
41   # Resources
42   SetOutPath "$INSTDIR"
43   # recursively copy all files under Resources
44   File /r "${FILES_LYX}\Resources"
45   
46   !if ${SETUPTYPE} == BUNDLE
47    
48    # extract the Jabref and MiKTeX installer
49    File /r "${FILES_LYX}\external"
50
51    # install MiKTeX if not already installed
52    Call InstallMiKTeX # function from LaTeX.nsh
53    
54   !endif # end if BUNDLE
55   
56   # Python
57   SetOutPath "$INSTDIR"
58   # recursively copy all files under Python
59   File /r "${FILES_PYTHON}"
60   
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"
72   
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}"
91   
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"
98   ${endif}
99   
100   !if ${SETUPTYPE} == BUNDLE
101    
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"
106      # launch installer
107      MessageBox MB_OK|MB_ICONINFORMATION "$(JabRefInfo)"
108      ExecWait "$INSTDIR\${JabRefInstall}"
109      # test if JabRef is now installed
110      StrCpy $PathBibTeXEditor ""
111      ReadRegStr $PathBibTeXEditor HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"    
112      ${if} $PathBibTeXEditor == ""
113       MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)"
114      ${else}
115       WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}" # special entry to tell the uninstaller that it was installed with LyX
116      ${endif}
117     ${endif}
118    ${endif}
119   !endif # end if BUNDLE
120   
121    # install eLyXer
122    SetOutPath "$INSTDIR\Python\Lib"
123    !insertmacro FileListeLyXer File "${FILES_ELYXER}\"
124    
125    # install unoconv
126    SetOutPath "$INSTDIR\Python\Lib"
127    !insertmacro FileListUnoConv File "${FILES_UNOCONV}\"
128
129   # install the LaTeX class files that are delivered with LyX
130   # and enable MiKTeX's automatic package installation
131   ${if} $LaTeXInstalled == "MiKTeX"
132    Call ConfigureMiKTeX # Function from LaTeX.nsh
133   ${endif}
134   
135   # download dictionaries and thesaurus
136   ${if} $DictCodes != ""
137    Call InstallHunspellDictionary # Function from Thesaurus.nsh
138   ${endif}
139   ${if} $ThesCodes != ""
140    Call InstallThesaurusDictionary # Function from Thesaurus.nsh
141   ${endif}
142   # finally delete the list of dictionaries and mirrors
143   Delete "$INSTDIR\Resources\DictionaryMirrors.txt"
144   Delete "$INSTDIR\Resources\ThesaurusDictionaryNames.txt"
145   Delete "$INSTDIR\Resources\HunspellDictionaryNames.txt"
146   
147   # Create uninstaller
148   WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
149
150 SectionEnd
151
152 #--------------------------------
153 # Support code for file downloads
154
155 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
156
157   # Downloads a file
158   
159   # RET = Return value (OK if succesful)
160   # ID = Name of the download in settings.nsh
161   # FILENAME = Location to store file
162   # APPEND = Filename to append to server location in settings.nsh
163
164   # Try first time
165   NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
166   Pop ${RET} # Return value (OK if succesful)
167
168   ${If} ${RET} != "success"
169     ${AndIf} ${RET} != "cancel"
170     # Download failed, try once again before giving up
171     # (usally we get a different mirror)
172     NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
173     Pop ${RET}
174   ${EndIf}
175
176 !macroend
177
178 #--------------------------------
179 # Extenral components
180
181 #Var PathAllUsers
182 #Var PathCurrentUser
183
184 !macro EXTERNAL COMPONENT
185
186   # Download/Install the component
187   
188   ${If} $Setup${COMPONENT} == ${TRUE}
189   
190     StrCpy $Path${COMPONENT} "" ;A new one will be installed
191   
192     !ifndef BUNDLESETUP_${COMPONENT}
193       !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
194     !else
195       !insertmacro EXTERNAL_INSTALL ${COMPONENT}
196     !endif
197     
198   ${EndIf}
199
200 !macroend
201
202 !macro EXTERNAL_RUNINSTALLER COMPONENT
203
204   # Run the installer application of the component that does the actual installation.
205
206   install_${COMPONENT}:
207       
208     ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
209     
210     # Updates the path environment variable of the installer process to the latest system value
211 #    ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
212 #    ReadRegStr $PathCurrentUser HKCU "Environment" Path
213 #    System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
214
215     Call Search${COMPONENT}
216     
217     ${If} $Path${COMPONENT} == ""  
218       MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
219     ${EndIf}
220       
221     Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
222      
223 !macroend
224
225 !macro EXTERNAL_DOWNLOAD COMPONENT
226
227   download_${COMPONENT}:
228
229     !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
230  
231     ${If} $DownloadResult != "success"
232       ${AndIf} $DownloadResult != "cancel"
233       # Download failed after trying twice - ask user
234       MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
235       Goto noinstall_${COMPONENT}
236     ${EndIf}
237       
238     !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
239       
240   noinstall_${COMPONENT}:
241
242 !macroend
243
244 !macro EXTERNAL_INSTALL COMPONENT
245
246   # Extract
247   File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
248     
249   !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
250     
251 !macroend
252
253
254 # Sections for external components
255
256 #Section -LaTeX ExternalLaTeX
257 #  !insertmacro EXTERNAL LaTeX
258 #SectionEnd
259
260 /*Function InitExternal
261
262   # Get sizes of external component installers
263   
264   #SectionGetSize ${ExternalLaTeX} $SizeLaTeX
265   
266   # Add download size
267   
268   !ifndef BUNDLESETUP_MIKTEX
269     IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
270   !endif
271
272 FunctionEnd*/