]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/install.nsh
delete old Aspell/Aiksaurus setup code
[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   # Install and register the core LyX files
18   
19   # The macros are defined in filelists.nsh
20   # the parameters are COMMAND DIRECTORY that form command '${COMMAND} "${DIRECTORY}files"  
21   
22   # Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
23   # $PLUGINSDIR is automatically deleted when the installer exits.
24   InitPluginsDir
25   
26   # Binaries
27   SetOutPath "$INSTDIR\bin"
28   !insertmacro FileListLyXBin File "${FILES_LYX}\bin\"
29   !insertmacro FileListLyXLauncher File "${FILES_LAUNCHER}\"  
30   !insertmacro FileListQtBin File "${FILES_QT}\bin\"
31   !insertmacro FileListDll File "${FILES_DEPS}\bin\"
32   !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
33   !insertmacro FileListMSVCManifest File "..\"
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 FileListNSISPluginsStandard File "${NSISDIR}\Plugins\"
40   !insertmacro FileListNSISPlugins File "${FILES_NSISPLUGINS}\"
41   !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
42   
43   # Resources
44   SetOutPath "$INSTDIR"
45   # recursively copy all files under Resources
46   File /r "${FILES_LYX}\Resources"
47   
48   # Components of Python
49   SetOutPath "$INSTDIR\python"
50   !insertmacro FileListPythonBin File "${FILES_PYTHON}\"
51   !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
52   !insertmacro FileListMSVCManifest File "..\"  
53   SetOutPath "$INSTDIR\python\Lib"
54   !insertmacro FileListPythonLib File "${FILES_PYTHON}\Lib\"
55   SetOutPath "$INSTDIR\python\Lib\encodings"
56   !insertmacro FileListPythonLibEncodings File "${FILES_PYTHON}\Lib\encodings\"
57   
58   # Compile all Pyton files to byte-code
59   # The user using the scripts may not have write access
60   FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
61   FileWrite $PythonCompileFile "import compileall$\r$\n"
62   FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
63   FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
64   FileClose $PythonCompileFile
65   DetailPrint $(TEXT_CONFIGURE_PYTHON)
66   nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
67   Pop $PythonCompileReturn # Return value
68   Delete "$INSTDIR\compilepy.py"
69   
70   !ifdef BUNDLE_IMAGEMAGICK
71   # Components of ImageMagick
72   SetOutPath "$INSTDIR\imagemagick"
73   !insertmacro FileListImageMagick File "${FILES_IMAGEMAGICK}\"
74   !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
75   !insertmacro FileListMSVCManifest File "..\"
76   !endif  
77   
78   !ifdef BUNDLE_GHOSTSCRIPT
79   # Components of Ghostscript
80   SetOutPath "$INSTDIR\ghostscript"
81   !insertmacro FileListGhostscript File "${FILES_GHOSTSCRIPT}\"
82   !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
83   !insertmacro FileListMSVCManifest File "..\"
84   
85   !endif  
86   
87   # Create uninstaller
88   WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
89
90 SectionEnd
91
92 #--------------------------------
93 # Support code for file downloads
94
95 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
96
97   # Downloads a file using the Inetc plug-in (HTTP or FTP)
98   
99   # RET = Return value (OK if succesful)
100   # ID = Name of the download in settings.nsh
101   # FILENAME = Location to store file
102   # APPEND = Filename to append to server location in settings.nsh
103
104   # Try first time
105   Inetc::get "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
106   Pop ${RET} # Return value (OK if succesful)
107
108   ${If} ${RET} != "OK"
109     # Download failed, try again (usally we get a different mirror)
110     Inetc::get "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
111     Pop ${RET}
112   ${EndIf}
113
114 !macroend
115
116 #--------------------------------
117 # Extenral components
118
119 Var PathAllUsers
120 Var PathCurrentUser
121
122 !macro EXTERNAL COMPONENT
123
124   # Download/Install the component
125   
126   ${If} $Setup${COMPONENT} == ${TRUE}
127   
128     StrCpy $Path${COMPONENT} "" ;A new one will be installed
129   
130     !ifndef BUNDLESETUP_${COMPONENT}
131       !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
132     !else
133       !insertmacro EXTERNAL_INSTALL ${COMPONENT}
134     !endif
135     
136   ${EndIf}
137
138 !macroend
139
140 !macro EXTERNAL_RUNINSTALLER COMPONENT
141
142   # Run the installer application of the component that does the actual installation.
143
144   install_${COMPONENT}:
145       
146     ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
147     
148     # Updates the path environment variable of the instaler process to the latest system value
149     ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
150     ReadRegStr $PathCurrentUser HKCU "Environment" Path
151     System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
152
153     Call Search${COMPONENT}
154     
155     ${If} $Path${COMPONENT} == ""  
156       MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
157     ${EndIf}
158       
159     Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
160      
161 !macroend
162
163 !macro EXTERNAL_DOWNLOAD COMPONENT
164
165   download_${COMPONENT}:
166
167     !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
168  
169     ${If} $DownloadResult != "OK"
170       # Download failed
171       MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
172       Goto noinstall_${COMPONENT}
173     ${EndIf}
174       
175     !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
176       
177   noinstall_${COMPONENT}:
178
179 !macroend
180
181 !macro EXTERNAL_INSTALL COMPONENT
182
183   # Extract
184   File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
185     
186   !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
187     
188 !macroend
189
190
191 # Sections for external components
192
193 Section -LaTeX ExternalLaTeX
194   !insertmacro EXTERNAL LaTeX
195 SectionEnd
196
197 !ifndef BUNDLE_IMAGEMAGICK
198
199 Section -ImageMagick ExternalImageMagick
200   !insertmacro EXTERNAL ImageMagick
201 SectionEnd
202
203 !endif
204
205 !ifndef BUNDLE_GHOSTSCRIPT
206
207 Section -Ghostscript ExternalGhostscript
208   !insertmacro EXTERNAL Ghostscript
209 SectionEnd
210
211 !endif
212
213 Function InitExternal
214
215   # Get sizes of external component installers
216   
217   SectionGetSize ${ExternalLaTeX} $SizeLaTeX
218   !ifndef BUNDLE_IMAGEMAGICK
219     SectionGetSize ${ExternalImageMagick} $SizeImageMagick
220   !endif
221   !ifndef BUNDLE_GHOSTSCRIPT
222     SectionGetSize ${ExternalGhostscript} $SizeGhostscript
223   !endif
224   
225   # Add download size
226   
227   !ifndef BUNDLESETUP_MIKTEX
228     IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
229   !endif
230   !ifndef BUNDLE_IMAGEMAGICK & BUNDLESETUP_IMAGEMAGICK
231     IntOp $SizeImagemagick $SizeImagemagick + ${SIZE_DOWNLOAD_IMAGEMAGICK}
232   !endif
233   !ifndef BUNDLE_GHOSTSCRIPT & BUNDLESETUP_GHOSTSCRIPT
234     IntOp $SizeGhostscript $SizeGhostscript + ${SIZE_DOWNLOAD_GHOSTSCRIPT}
235   !endif
236
237 FunctionEnd