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