]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/install.nsh
installer:
[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 FileListDll File "${FILES_DEPS}\bin\"
32   !insertmacro FileListMSVC File "${FILES_MSVC}\"
33   !insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
34   !insertmacro FileListDTLBin File "${FILES_DTL}\"
35   !insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
36   !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
37   !insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
38   !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
39   
40   # Resources
41   SetOutPath "$INSTDIR"
42   # recursively copy all files under Resources
43   File /r "${FILES_LYX}\Resources"
44   
45   # Python
46   SetOutPath "$INSTDIR"
47   # recursively copy all files under Python
48   File /r "${FILES_PYTHON}"
49   # add MSVC runtimes
50   #SetOutPath "$INSTDIR\python"
51   #!insertmacro FileListMSVC File "${FILES_MSVC}\"
52   
53   
54   # Compile all Pyton files to byte-code
55   # The user using the scripts may not have write access
56   FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
57   FileWrite $PythonCompileFile "import compileall$\r$\n"
58   FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
59   FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
60   FileClose $PythonCompileFile
61   DetailPrint $(TEXT_CONFIGURE_PYTHON)
62   nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
63   Pop $PythonCompileReturn # Return value
64   Delete "$INSTDIR\compilepy.py"
65   
66   # Components of ImageMagick
67   SetOutPath "$INSTDIR\imagemagick"
68   File /r "${FILES_IMAGEMAGICK}\"
69   !insertmacro FileListMSVC File "${FILES_MSVC}\"
70   # register ImageMagick
71   WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" "$INSTDIR\imagemagick\convert.exe $$"
72   WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "BinPath" "$INSTDIR\imagemagick"
73   WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
74   WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "ConfigurePath" "$INSTDIR\imagemagick\config"
75   WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
76   WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "LibPath" "$INSTDIR\imagemagick"
77   WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "BinPath" "$INSTDIR\imagemagick"
78   WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
79   WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "ConfigurePath" "$INSTDIR\imagemagick\config"
80   WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
81   WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "LibPath" "$INSTDIR\imagemagick"
82   WriteRegDWORD SHCTX "SOFTWARE\ImageMagick\Current" "QuantumDepth" 0x00000010
83   WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "Version" "${ImageMagickVersion}"
84   
85   # Components of Ghostscript
86   ${if} $GhostscriptPath == ""
87    SetOutPath "$INSTDIR\ghostscript"
88    File /r "${FILES_GHOSTSCRIPT}\"
89    !insertmacro FileListMSVC File "${FILES_MSVC}\"
90    StrCpy $GhostscriptPath "$INSTDIR\ghostscript\bin"
91   ${endif}
92   
93   !if ${SETUPTYPE} == BUNDLE
94    
95    # extract the Jabref and MiKTeX installer
96    File /r "${FILES_LYX}\external"
97
98    # install MiKTeX if not already installed
99    Call InstallMiKTeX # function from LaTeX.nsh
100    
101    # install JabRef if not already installed and the user selected it
102    # if no BibTeX editor is installed
103    ${if} $PathBibTeXEditor == ""
104     ${if} $InstallJabRef == "true"
105      # launch installer
106      MessageBox MB_OK|MB_ICONINFORMATION "$(JabRefInfo)"
107      ExecWait "$INSTDIR\${JabRefInstall}"
108      # test if JabRef is now installed
109      StrCpy $PathBibTeXEditor ""
110      ReadRegStr $PathBibTeXEditor HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"    
111      ${if} $PathBibTeXEditor == ""
112       MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)"
113      ${else}
114       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
115      ${endif}
116     ${endif}
117    ${endif}
118   !endif # end if BUNDLE
119   
120    # install eLyXer as Python module
121    ExecWait '"$INSTDIR\python\python.exe" "$INSTDIR\python\setup.py" install'
122
123   # install the LaTeX class files that are delivered with LyX
124   # and enable MiKTeX's automatic package installation
125   ${if} $LaTeXInstalled == "MiKTeX"
126    Call ConfigureMiKTeX # Function from LaTeX.nsh
127   ${endif}
128   
129   # Create uninstaller
130   WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
131
132 SectionEnd
133
134 #--------------------------------
135 # Support code for file downloads
136
137 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
138
139   # Downloads a file
140   
141   # RET = Return value (OK if succesful)
142   # ID = Name of the download in settings.nsh
143   # FILENAME = Location to store file
144   # APPEND = Filename to append to server location in settings.nsh
145
146   # Try first time
147   NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
148   Pop ${RET} # Return value (OK if succesful)
149
150   ${If} ${RET} != "OK"
151     # Download failed, try again (usally we get a different mirror)
152     NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
153     Pop ${RET}
154   ${EndIf}
155
156 !macroend
157
158 #--------------------------------
159 # Extenral components
160
161 #Var PathAllUsers
162 #Var PathCurrentUser
163
164 !macro EXTERNAL COMPONENT
165
166   # Download/Install the component
167   
168   ${If} $Setup${COMPONENT} == ${TRUE}
169   
170     StrCpy $Path${COMPONENT} "" ;A new one will be installed
171   
172     !ifndef BUNDLESETUP_${COMPONENT}
173       !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
174     !else
175       !insertmacro EXTERNAL_INSTALL ${COMPONENT}
176     !endif
177     
178   ${EndIf}
179
180 !macroend
181
182 !macro EXTERNAL_RUNINSTALLER COMPONENT
183
184   # Run the installer application of the component that does the actual installation.
185
186   install_${COMPONENT}:
187       
188     ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
189     
190     # Updates the path environment variable of the installer process to the latest system value
191 #    ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
192 #    ReadRegStr $PathCurrentUser HKCU "Environment" Path
193 #    System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
194
195     Call Search${COMPONENT}
196     
197     ${If} $Path${COMPONENT} == ""  
198       MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
199     ${EndIf}
200       
201     Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
202      
203 !macroend
204
205 !macro EXTERNAL_DOWNLOAD COMPONENT
206
207   download_${COMPONENT}:
208
209     !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
210  
211     ${If} $DownloadResult != "OK"
212       # Download failed
213       MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
214       Goto noinstall_${COMPONENT}
215     ${EndIf}
216       
217     !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
218       
219   noinstall_${COMPONENT}:
220
221 !macroend
222
223 !macro EXTERNAL_INSTALL COMPONENT
224
225   # Extract
226   File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
227     
228   !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
229     
230 !macroend
231
232
233 # Sections for external components
234
235 #Section -LaTeX ExternalLaTeX
236 #  !insertmacro EXTERNAL LaTeX
237 #SectionEnd
238
239 /*Function InitExternal
240
241   # Get sizes of external component installers
242   
243   #SectionGetSize ${ExternalLaTeX} $SizeLaTeX
244   
245   # Add download size
246   
247   !ifndef BUNDLESETUP_MIKTEX
248     IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
249   !endif
250
251 FunctionEnd*/