]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/installer/setup/install.nsh
* remove old installer code for external ImageMagick and Ghostscript
[lyx.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 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 FileListNSISPluginsStandard File "${NSISDIR}\Plugins\"
39   !insertmacro FileListNSISPlugins File "${FILES_NSISPLUGINS}\"
40   !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
41   
42   # Resources
43   SetOutPath "$INSTDIR"
44   # recursively copy all files under Resources
45   File /r "${FILES_LYX}\Resources"
46   
47   # Components of Python
48   SetOutPath "$INSTDIR\python"
49   !insertmacro FileListPythonBin File "${FILES_PYTHON}\"
50   !insertmacro FileListMSVC File "${FILES_MSVC}\"
51   SetOutPath "$INSTDIR\python\Lib"
52   !insertmacro FileListPythonLib File "${FILES_PYTHON}\Lib\"
53   SetOutPath "$INSTDIR\python\Lib\encodings"
54   !insertmacro FileListPythonLibEncodings File "${FILES_PYTHON}\Lib\encodings\"
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   !endif  
79   
80   # Create uninstaller
81   WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
82
83 SectionEnd
84
85 #--------------------------------
86 # Support code for file downloads
87
88 !macro DOWNLOAD_FILE RET ID FILENAME APPEND
89
90   # Downloads a file using the Inetc plug-in (HTTP or FTP)
91   
92   # RET = Return value (OK if succesful)
93   # ID = Name of the download in settings.nsh
94   # FILENAME = Location to store file
95   # APPEND = Filename to append to server location in settings.nsh
96
97   # Try first time
98   Inetc::get "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
99   Pop ${RET} # Return value (OK if succesful)
100
101   ${If} ${RET} != "OK"
102     # Download failed, try again (usally we get a different mirror)
103     Inetc::get "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
104     Pop ${RET}
105   ${EndIf}
106
107 !macroend
108
109 #--------------------------------
110 # Extenral components
111
112 Var PathAllUsers
113 Var PathCurrentUser
114
115 !macro EXTERNAL COMPONENT
116
117   # Download/Install the component
118   
119   ${If} $Setup${COMPONENT} == ${TRUE}
120   
121     StrCpy $Path${COMPONENT} "" ;A new one will be installed
122   
123     !ifndef BUNDLESETUP_${COMPONENT}
124       !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
125     !else
126       !insertmacro EXTERNAL_INSTALL ${COMPONENT}
127     !endif
128     
129   ${EndIf}
130
131 !macroend
132
133 !macro EXTERNAL_RUNINSTALLER COMPONENT
134
135   # Run the installer application of the component that does the actual installation.
136
137   install_${COMPONENT}:
138       
139     ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
140     
141     # Updates the path environment variable of the instaler process to the latest system value
142     ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
143     ReadRegStr $PathCurrentUser HKCU "Environment" Path
144     System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
145
146     Call Search${COMPONENT}
147     
148     ${If} $Path${COMPONENT} == ""  
149       MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
150     ${EndIf}
151       
152     Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
153      
154 !macroend
155
156 !macro EXTERNAL_DOWNLOAD COMPONENT
157
158   download_${COMPONENT}:
159
160     !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
161  
162     ${If} $DownloadResult != "OK"
163       # Download failed
164       MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
165       Goto noinstall_${COMPONENT}
166     ${EndIf}
167       
168     !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
169       
170   noinstall_${COMPONENT}:
171
172 !macroend
173
174 !macro EXTERNAL_INSTALL COMPONENT
175
176   # Extract
177   File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
178     
179   !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
180     
181 !macroend
182
183
184 # Sections for external components
185
186 Section -LaTeX ExternalLaTeX
187   !insertmacro EXTERNAL LaTeX
188 SectionEnd
189
190 Function InitExternal
191
192   # Get sizes of external component installers
193   
194   SectionGetSize ${ExternalLaTeX} $SizeLaTeX
195   
196   # Add download size
197   
198   !ifndef BUNDLESETUP_MIKTEX
199     IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
200   !endif
201
202 FunctionEnd