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