]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/install.nsh
add Python logging lib
[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   # Components of Python
46   SetOutPath "$INSTDIR\python"
47   !insertmacro FileListPythonBin File "${FILES_PYTHON}\"
48   !insertmacro FileListMSVC File "${FILES_MSVC}\"
49   SetOutPath "$INSTDIR\python\Lib"
50   !insertmacro FileListPythonLib File "${FILES_PYTHON}\Lib\"
51   SetOutPath "$INSTDIR\python\Lib\encodings"
52   !insertmacro FileListPythonLibEncodings File "${FILES_PYTHON}\Lib\encodings\"
53   SetOutPath "$INSTDIR\python\Lib\logging"
54   !insertmacro FileListPythonLibLogging File "${FILES_PYTHON}\Lib\logging\"
55   
56   # Compile all Pyton files to byte-code
57   # The user using the scripts may not have write access
58   FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
59   FileWrite $PythonCompileFile "import compileall$\r$\n"
60   FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
61   FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
62   FileClose $PythonCompileFile
63   DetailPrint $(TEXT_CONFIGURE_PYTHON)
64   nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
65   Pop $PythonCompileReturn # Return value
66   Delete "$INSTDIR\compilepy.py"
67   
68   # Components of ImageMagick
69   SetOutPath "$INSTDIR\imagemagick"
70   !insertmacro FileListImageMagick File "${FILES_IMAGEMAGICK}\"
71   !insertmacro FileListMSVC File "${FILES_MSVC}\"
72   
73   # Components of Ghostscript
74   SetOutPath "$INSTDIR\ghostscript"
75   !insertmacro FileListGhostscript File "${FILES_GHOSTSCRIPT}\"
76   !insertmacro FileListMSVC File "${FILES_MSVC}\"
77   
78   # Create uninstaller
79   WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
80
81 SectionEnd
82
83 #--------------------------------
84 # Support code for file downloads
85
86 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
87
88   # Downloads a file
89   
90   # RET = Return value (OK if succesful)
91   # ID = Name of the download in settings.nsh
92   # FILENAME = Location to store file
93   # APPEND = Filename to append to server location in settings.nsh
94
95   # Try first time
96   NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
97   Pop ${RET} # Return value (OK if succesful)
98
99   ${If} ${RET} != "OK"
100     # Download failed, try again (usally we get a different mirror)
101     NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
102     Pop ${RET}
103   ${EndIf}
104
105 !macroend
106
107 #--------------------------------
108 # Extenral components
109
110 Var PathAllUsers
111 Var PathCurrentUser
112
113 !macro EXTERNAL COMPONENT
114
115   # Download/Install the component
116   
117   ${If} $Setup${COMPONENT} == ${TRUE}
118   
119     StrCpy $Path${COMPONENT} "" ;A new one will be installed
120   
121     !ifndef BUNDLESETUP_${COMPONENT}
122       !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
123     !else
124       !insertmacro EXTERNAL_INSTALL ${COMPONENT}
125     !endif
126     
127   ${EndIf}
128
129 !macroend
130
131 !macro EXTERNAL_RUNINSTALLER COMPONENT
132
133   # Run the installer application of the component that does the actual installation.
134
135   install_${COMPONENT}:
136       
137     ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
138     
139     # Updates the path environment variable of the instaler process to the latest system value
140     ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
141     ReadRegStr $PathCurrentUser HKCU "Environment" Path
142     System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
143
144     Call Search${COMPONENT}
145     
146     ${If} $Path${COMPONENT} == ""  
147       MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
148     ${EndIf}
149       
150     Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
151      
152 !macroend
153
154 !macro EXTERNAL_DOWNLOAD COMPONENT
155
156   download_${COMPONENT}:
157
158     !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
159  
160     ${If} $DownloadResult != "OK"
161       # Download failed
162       MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
163       Goto noinstall_${COMPONENT}
164     ${EndIf}
165       
166     !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
167       
168   noinstall_${COMPONENT}:
169
170 !macroend
171
172 !macro EXTERNAL_INSTALL COMPONENT
173
174   # Extract
175   File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
176     
177   !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
178     
179 !macroend
180
181
182 # Sections for external components
183
184 Section -LaTeX ExternalLaTeX
185   !insertmacro EXTERNAL LaTeX
186 SectionEnd
187
188 Function InitExternal
189
190   # Get sizes of external component installers
191   
192   SectionGetSize ${ExternalLaTeX} $SizeLaTeX
193   
194   # Add download size
195   
196   !ifndef BUNDLESETUP_MIKTEX
197     IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
198   !endif
199
200 FunctionEnd