]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/installer/LyXWinInstaller/InstallActions-complete.nsh
file format change: support for Armenian
[lyx.git] / development / Win32 / packaging / installer / LyXWinInstaller / InstallActions-complete.nsh
1 ; this file contains the main installer section
2
3 ; The '-' makes the section invisible.
4 Section "-Installation actions" SecInstallation
5
6   ; dummy actions to avoid NSIS warnings
7   StrCpy $FileName ""
8   StrCpy $NewString ""
9   StrCpy $OldString ""
10   
11   ; extract all files
12   SetOutPath "$INSTDIR"
13   File /r "${PRODUCT_SOURCEDIR}\bin"
14   File /r "${PRODUCT_SOURCEDIR}\etc"
15   File /r "${PRODUCT_SOURCEDIR}\Resources"
16   File /r "${PRODUCT_SOURCEDIR}\external"
17
18   ; install MiKTeX if not already installed
19   Call MiKTeX
20
21   ; install Ghostscript if it not installed
22   Call Ghostscript
23
24   ; install ImageMagick if it not installed
25   Call ImageMagick
26
27   ; install ImageMAspellagick if it not installed
28   Call Aspell
29
30   ; install Aiksaurus if it not installed
31   Call Aiksaurus
32
33   ; install GSview if it not installed and the user selected it
34   Call PostScript
35
36   ; install JabRef if it not installed and the user selected it
37   Call BibTeX
38
39   ; install the LaTeX class files that are delivered with LyX
40   ; and enable MiKTeX's automatic package installation
41   Call ConfigureMiKTeX ; Function from LaTeX.nsh
42
43   ; install Aspell dictionaries
44   ${if} $LangCode == "nb_NO"
45    StrCpy $LangCode "no_NO" ; we only have a norwegian dictionary available
46   ${endif}
47   Call InstallAspellDictionary ; function from Aspell.nsh
48
49   ; configure LyX
50   Call ConfigureLyX ; Function from ConfigLyX.nsh
51
52   ; delete unnecessary files
53   ${if} $DelPythonFiles == "True"
54    Delete $INSTDIR\bin\python.exe
55    Delete $INSTDIR\bin\python25.dll
56    Delete $INSTDIR\bin\Python-License.txt
57    RMDir /r $INSTDIR\bin\Lib
58    RMDir /r $INSTDIR\bin\DLLs
59   ${endif}
60   RMDir /r $INSTDIR\external
61
62   ; create Uninstaller
63   WriteUninstaller "${PRODUCT_UNINSTALL_EXE}"
64
65   ; run LyX's configure script
66   ; create a bat-file to start configure in a console window so that the user see the progress
67   ; of the configuration and to have a signal when the configuration is ready to start LyX
68   ; this is important when LyX is installed together with MiKTeX or when LyX is installed for the first
69   ; time on a computer, because the installation of missing LaTeX-files required by LyX could last minutes
70   ; a batch file is needed because simply calling ExecWait '"$PythonPath\python.exe" "$INSTDIR\Resources\configure.py"'
71   ; creates the config files in $PythonPath
72   ${if} $PythonPath == ""
73    StrCpy $PythonPath "$INSTDIR\bin"
74   ${endif}
75   StrCpy $1 $INSTDIR 2 ; get drive letter
76   FileOpen $R1 "$INSTDIR\Resources\configLyX.bat" w
77   FileWrite $R1 '$1$\r$\n\
78                  cd $INSTDIR\Resources\$\r$\n\
79                  "$PythonPath\python.exe" configure.py'
80   FileClose $R1
81   MessageBox MB_OK|MB_ICONINFORMATION "$(LatexConfigInfo)"
82   ExecWait '"$INSTDIR\Resources\configLyX.bat"'
83   Delete "$INSTDIR\Resources\configLyX.bat"
84
85   ; ask to update MiKTeX
86   ${if} $MiKTeXInstalled == "yes"
87    MessageBox MB_YESNO|MB_ICONINFORMATION "$(MiKTeXInfo)" IDYES UpdateNow IDNO UpdateLater
88    UpdateNow:
89     StrCpy $0 $LaTeXPath -4 ; remove "\bin"
90     ExecWait '"$LaTeXPath\copystart.exe" "$0\config\update.dat"' ; run MiKTeX's update wizard
91    UpdateLater:
92   ${endif}
93
94   ; save MiKTeX's install path to be able to remove LyX's LaTeX-files in the uninstaller
95   FileOpen $R1 "$INSTDIR\Resources\uninstallPaths.dat" w
96   FileWrite $R1 '$LaTeXPath'
97   FileClose $R1
98
99   ; prepare variables for uninstaller
100   StrCpy $MiKTeXVersionVar ${MiKTeXDeliveredVersion}
101   StrCpy $JabRefVersionVar ${JabRefVersion}
102
103 SectionEnd
104
105 ; -------------------------------------------
106
107 Function MiKTeX
108         
109 ; install MiKTeX if not already installed
110   ${if} $LatexPath == ""
111    ; launch MiKTeX's installer
112    MessageBox MB_OK|MB_ICONINFORMATION "$(LatexInfo)"
113    ExecWait ${MiKTeXInstall}
114    ; test if MiKTeX is installed
115    ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
116    StrCpy $Search "miktex"
117    Call LaTeXCheck
118    ${if} $LatexPath == ""
119     StrCpy $MiKTeXUser "HKCU"
120     ReadRegStr $String HKCU "Environment" "Path"
121     StrCpy $Search "miktex"
122     Call LaTeXCheck
123    ${endif}
124    ${if} $LatexPath != ""
125     ; set package repository (MiKTeX's primary package repository)
126     WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}" ; special entry to tell the uninstaller that it was installed with LyX
127     StrCpy $MiKTeXInstalled "yes"
128     ${if} $MiKTeXUser != "HKCU"
129      StrCpy $MiKTeXPath "$LatexPath" -11
130      ;MessageBox MB_OK|MB_ICONINFORMATION "$(MiKTeXPathInfo)" ; info that MiKTeX's installation folder must have write permissions for all users to work properly
131     ${endif}
132    ${else}
133     MessageBox MB_OK|MB_ICONSTOP "$(LatexError1)"
134     SetOutPath $TEMP ; to be able to delete the $INSTDIR
135     RMDir /r $INSTDIR
136     Abort
137    ${endif} ; endif $LatexPath != ""
138   ${endif}
139
140 FunctionEnd
141
142 ; -------------------------------------------
143
144 Function Ghostscript
145
146   ; if GhostScript is not installed
147   ${if} $GhostscriptPath == ""
148    ; register Ghostscript
149    WriteRegStr HKLM "SOFTWARE\GPL Ghostscript\${GhostscriptVersion}" "GS_DLL" "${GhostscriptDir}\bin\gsdll32.dll"
150    WriteRegStr HKLM "SOFTWARE\GPL Ghostscript\${GhostscriptVersion}" "GS_LIB" "${GhostscriptDir}\lib;${GhostscriptDir}\fonts;${GhostscriptDir}\Resource"
151    
152    WriteRegStr HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}" ; special entry to tell the uninstaller that it was installed with LyX
153    StrCpy $GhostscriptPath "${GhostscriptDir}\bin"
154   ${else}
155    ; delete unnecessary files
156    RMDir /r ${GhostscriptDir}   
157   ${endif}
158
159 FunctionEnd
160
161 ; -------------------------------------------
162
163 Function ImageMagick
164
165   ; if ImageMagick is not installed
166   ${if} $ImageMagickPath == ""
167    ; register ImageMagick
168    WriteRegStr HKLM "SOFTWARE\Classes\Applications" "AutoRun" "${ImageMagickDir}\convert.exe $$"
169    WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "BinPath" "${ImageMagickDir}"
170    WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "CoderModulesPath" "${ImageMagickDir}\modules\coders"
171    WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "ConfigurePath" "${ImageMagickDir}\config"
172    WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "FilterModulesPath" "${ImageMagickDir}\modules\filters"
173    WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "LibPath" "${ImageMagickDir}"
174    
175    WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "BinPath" "${ImageMagickDir}"
176    WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "CoderModulesPath" "${ImageMagickDir}\modules\coders"
177    WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "ConfigurePath" "${ImageMagickDir}\config"
178    WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "${ImageMagickDir}\modules\filters"
179    WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "LibPath" "${ImageMagickDir}"
180    WriteRegDWORD HKLM "SOFTWARE\ImageMagick\Current" "QuantumDepth" 0x00000010   
181    WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "Version" "${ImageMagickVersion}"
182    
183    WriteRegStr HKLM "Software\ImageMagick" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}" ; special entry to tell the uninstaller that it was installed with LyX
184    StrCpy $ImageMagickPath ${ImageMagickDir}
185   ${else}
186    ; delete unnecessary files
187    RMDir /r ${ImageMagickDir}
188   ${endif}
189
190 FunctionEnd
191
192 ; -------------------------------------------
193
194 Function Aspell
195
196   ; if Aspell is not installed
197   ${if} $AspellPath == ""
198    ; extract Aspell's program files
199    SetOutPath "$INSTDIR\external"
200    File /r "${PRODUCT_SOURCEDIR}\${AspellInstall}"
201    ; copy the files and register Aspell
202    CopyFiles "$INSTDIR\${AspellInstall}" "$APPDATA"
203    
204    WriteRegStr HKLM "SOFTWARE\Aspell" "Base Path" "${AspellDir}"
205    WriteRegStr HKLM "SOFTWARE\Aspell" "Dictionary Path" "${AspellDictPath}"
206    WriteRegStr HKLM "SOFTWARE\Aspell" "Personal Path" "${AspellPersonalPath}"
207    
208    WriteRegStr HKLM "Software\Aspell" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}" ; special entry to tell the uninstaller that it was installed with LyX
209    
210    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Aspell" "DisplayName" "${AspellDisplay}"
211    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Aspell" "NoModify" 0x00000001
212    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Aspell" "NoRepair" 0x00000001
213    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Aspell" "UninstallString" "${AspellDir}\${AspellUninstall}"
214   ${endif}
215
216 FunctionEnd
217
218 ; -------------------------------------------
219
220 Function Aiksaurus
221
222   ; if Aiksaurus is not installed
223   ${if} $AiksaurusPath == ""
224    ; extract Aiksaurus' program files
225    SetOutPath "$INSTDIR\external"
226    File /r "${PRODUCT_SOURCEDIR}\${AiksaurusInstall}"
227    ; copy the files and register Aiksaurus
228    CopyFiles "$INSTDIR\${AiksaurusInstall}" "$APPDATA"
229 ;   WriteRegStr HKLM "Software\Aiksaurus" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}" ; special entry to tell the uninstaller that it was installed with LyX
230 ;   WriteRegStr HKLM "Software\Aiksaurus" "Data Path" "${AiksaurusDir}"
231   ${endif}
232
233 FunctionEnd
234
235 ; -------------------------------------------
236
237 Function PostScript
238
239 ; if no PostScript viewer is installed
240   ${if} $PSVPath == ""
241    ${if} $InstallGSview == "true"
242     ; launch installer
243     MessageBox MB_OK|MB_ICONINFORMATION "$(GSviewInfo)"
244     ExecWait "$INSTDIR\${GSviewInstall}"
245     ; test if GSview is installed
246     StrCpy $PSVPath ""
247     ReadRegStr $PSVPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview32.exe" "Path"    
248     ${if} $PSVPath == ""
249      MessageBox MB_OK|MB_ICONEXCLAMATION "$(GSviewError)"
250     ${endif}
251    ${endif}
252   ${endif}
253
254 FunctionEnd
255
256 ; -------------------------------------------
257
258 Function BibTeX
259
260 ; if no BibTeX editor is installed
261   ${if} $BibTeXEditorPath == ""
262    ${if} $InstallJabRef == "true"
263     ; launch installer
264     MessageBox MB_OK|MB_ICONINFORMATION "$(JabRefInfo)"
265     ExecWait "$INSTDIR\${JabRefInstall}"
266     ; test if JabRef is installed
267     StrCpy $BibTeXEditorPath ""
268     ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${JabRefVersion}" "UninstallString"    
269     ${if} $BibTeXEditorPath == ""
270      MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)"
271     ${else}
272      WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${JabRefVersion}" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}" ; special entry to tell the uninstaller that it was installed with LyX
273     ${endif}
274    ${endif}
275   ${endif}
276
277 FunctionEnd
278