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