]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/install.nsh
installer: fix now all compiler warnings
[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   SetOutPath "$INSTDIR\ghostscript"
87   File /r "${FILES_GHOSTSCRIPT}\"
88   !insertmacro FileListMSVC File "${FILES_MSVC}\"
89   
90   !if ${SETUPTYPE} == BUNDLE
91    
92    # extract the Jabref and MiKTeX installer
93    File /r "${FILES_LYX}\external"
94
95    # install MiKTeX if not already installed
96    Call InstallMiKTeX # function from LaTeX.nsh
97    
98    # install JabRef if not already installed and the user selected it
99    # if no BibTeX editor is installed
100    ${if} $PathBibTeXEditor == ""
101     ${if} $InstallJabRef == "true"
102      # launch installer
103      MessageBox MB_OK|MB_ICONINFORMATION "$(JabRefInfo)"
104      ExecWait "$INSTDIR\${JabRefInstall}"
105      # test if JabRef is now installed
106      StrCpy $PathBibTeXEditor ""
107      ReadRegStr $PathBibTeXEditor HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"    
108      ${if} $PathBibTeXEditor == ""
109       MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)"
110      ${else}
111       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
112      ${endif}
113     ${endif}
114    ${endif}
115   !endif # end if BUNDLE
116   
117    # install eLyXer as Python module
118    ExecWait '"$INSTDIR\python\python.exe" "$INSTDIR\python\setup.py" install'
119
120   # install the LaTeX class files that are delivered with LyX
121   # and enable MiKTeX's automatic package installation
122   ${if} $LaTeXInstalled == "MiKTeX"
123    Call ConfigureMiKTeX # Function from LaTeX.nsh
124   ${endif}
125   
126   # Create uninstaller
127   WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
128
129 SectionEnd
130
131 #--------------------------------
132 # Support code for file downloads
133
134 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
135
136   # Downloads a file
137   
138   # RET = Return value (OK if succesful)
139   # ID = Name of the download in settings.nsh
140   # FILENAME = Location to store file
141   # APPEND = Filename to append to server location in settings.nsh
142
143   # Try first time
144   NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
145   Pop ${RET} # Return value (OK if succesful)
146
147   ${If} ${RET} != "OK"
148     # Download failed, try again (usally we get a different mirror)
149     NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
150     Pop ${RET}
151   ${EndIf}
152
153 !macroend
154
155 #--------------------------------
156 # Extenral components
157
158 #Var PathAllUsers
159 #Var PathCurrentUser
160
161 !macro EXTERNAL COMPONENT
162
163   # Download/Install the component
164   
165   ${If} $Setup${COMPONENT} == ${TRUE}
166   
167     StrCpy $Path${COMPONENT} "" ;A new one will be installed
168   
169     !ifndef BUNDLESETUP_${COMPONENT}
170       !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
171     !else
172       !insertmacro EXTERNAL_INSTALL ${COMPONENT}
173     !endif
174     
175   ${EndIf}
176
177 !macroend
178
179 !macro EXTERNAL_RUNINSTALLER COMPONENT
180
181   # Run the installer application of the component that does the actual installation.
182
183   install_${COMPONENT}:
184       
185     ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
186     
187     # Updates the path environment variable of the installer process to the latest system value
188 #    ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
189 #    ReadRegStr $PathCurrentUser HKCU "Environment" Path
190 #    System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
191
192     Call Search${COMPONENT}
193     
194     ${If} $Path${COMPONENT} == ""  
195       MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
196     ${EndIf}
197       
198     Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
199      
200 !macroend
201
202 !macro EXTERNAL_DOWNLOAD COMPONENT
203
204   download_${COMPONENT}:
205
206     !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
207  
208     ${If} $DownloadResult != "OK"
209       # Download failed
210       MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
211       Goto noinstall_${COMPONENT}
212     ${EndIf}
213       
214     !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
215       
216   noinstall_${COMPONENT}:
217
218 !macroend
219
220 !macro EXTERNAL_INSTALL COMPONENT
221
222   # Extract
223   File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
224     
225   !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
226     
227 !macroend
228
229
230 # Sections for external components
231
232 #Section -LaTeX ExternalLaTeX
233 #  !insertmacro EXTERNAL LaTeX
234 #SectionEnd
235
236 /*Function InitExternal
237
238   # Get sizes of external component installers
239   
240   #SectionGetSize ${ExternalLaTeX} $SizeLaTeX
241   
242   # Add download size
243   
244   !ifndef BUNDLESETUP_MIKTEX
245     IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
246   !endif
247
248 FunctionEnd*/