4 Handling of LaTeX distributions
7 # This script contains the following functions:
9 # - LaTeXActions (checks if MiKTeX or TeXLive is installed)
12 # (installs the LaTeX class files that are delivered with LyX,
13 # a Perl interpreter for splitindex and pdfcrop
14 # and enable MiKTeX's automatic package installation)
17 # (installs the LaTeX class files that are delivered with LyX)
19 # ---------------------------------------
22 # checks if MiKTeX or TeXLive is installed
24 StrCpy $Is64bit "false"
27 SetRegView 64 # the PATH is in the 64bit registry section
29 # test if MiKTeX is installed
30 # reads the PATH variable via the registry because NSIS' "$%Path%" variable is not updated when the PATH changes
31 ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
32 StrCpy $Search "miktex"
33 Call LaTeXCheck # sets the path to the latex.exe to $PathLaTeX # Function from LyXUtils.nsh
35 StrCpy $String $PathLaTeX
36 StrCpy $Search "x64" # search if it is 64bit MiKTeX
37 Call StrPoint # Function from LyXUtils.nsh
38 ${if} $Pointer != "-1" # if something was found
39 StrCpy $Is64bit "true"
42 # check for 32bit MiKTeX
43 ${if} $PathLaTeX != ""
44 ${andif} $Is64bit != "true"
48 # check if MiKTeX 2.8 or newer is installed
51 EnumRegKey $1 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" $0 # check the last subkey
57 ${if} $String == "2.8"
58 StrCpy $MiKTeXVersion "2.8"
59 StrCpy $LaTeXName "MiKTeX 2.8"
61 ${if} $String == "2.9"
62 StrCpy $MiKTeXVersion "2.9"
63 StrCpy $LaTeXName "MiKTeX 2.9"
67 # check for 64bit MiKTeX
68 ${if} $LaTeXName == ""
72 # check if MiKTeX 2.8 or newer is installed
75 EnumRegKey $1 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" $0 # check the last subkey
81 ${if} $String == "2.8"
82 StrCpy $MiKTeXVersion "2.8"
83 StrCpy $LaTeXName "MiKTeX 2.8"
85 ${if} $String == "2.9"
86 StrCpy $MiKTeXVersion "2.9"
87 StrCpy $LaTeXName "MiKTeX 2.9"
91 ${if} $PathLaTeX != ""
92 StrCpy $MiKTeXUser "HKLM" # needed later to configure MiKTeX
93 ${else} # check if MiKTeX is installed only for the current user
95 SetRegView 64 # the PATH is in the 64bit registry section
97 ReadRegStr $String HKCU "Environment" "Path"
98 StrCpy $Search "miktex"
99 Call LaTeXCheck # function from LyXUtils.nsh
100 ${if} $PathLaTeX != ""
101 StrCpy $MiKTeXUser "HKCU"
104 ${if} $LaTeXName == "" # check for the MiKTeX version
107 EnumRegKey $1 HKCU "SOFTWARE\MiKTeX.org\MiKTeX" $0 # check the last subkey
113 ${if} $String == "2.8"
114 StrCpy $MiKTeXVersion "2.8"
115 StrCpy $LaTeXName "MiKTeX 2.8"
117 ${if} $String == "2.9"
118 StrCpy $MiKTeXVersion "2.9"
119 StrCpy $LaTeXName "MiKTeX 2.9"
123 ${if} $PathLaTeX != ""
124 StrCpy $String $PathLaTeX
125 StrCpy $Search "x64" # search if it is 64bit MiKTeX
126 Call StrPoint # Function from LyXUtils.nsh
127 ${if} $Pointer != "-1" # if something was found
128 StrCpy $Is64bit "true"
130 StrCpy $LaTeXInstalled "MiKTeX"
131 # on some installations the path ends with a "\" on some not
132 # therefore assure that we remove it if it exists
133 StrCpy $0 $PathLaTeX "" -1
135 StrCpy $PathLaTeX "$PathLaTeX" -1 # delete "\"
139 # test if TeXLive is installed
140 # TeXLive can be installed so that it appears in the PATH variable and/or only as current user.
141 # The safest method is to first check for the PATH because this is independent of the TeXLive version.
143 SetRegView 64 # the PATH is in the 64bit registry section
145 ${if} $PathLaTeX == ""
146 ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
147 StrCpy $Search "TeXLive"
148 Call LaTeXCheck # function from LyXUtils.nsh
150 # check for the current user Path variable
151 ${if} $PathLaTeX == ""
152 ReadRegStr $String HKCU "Environment" "Path"
153 StrCpy $Search "texlive"
155 Call LaTeXCheck # function from LyXUtils.nsh
157 # check if it was installed to the system
159 SetRegView 32 # TeXLive is a 32bit application
161 ${if} $PathLaTeX == ""
162 ReadRegStr $String HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "UninstallString"
164 ReadRegStr $String HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "UninstallString"
167 StrCpy $String $String -28 # remove '\tlpkg\installer\uninst.bat"'
168 StrCpy $String $String "" 1 # remove the leading quote
170 StrCpy $PathLaTeX "$String\bin\win32"
171 # check if the latex.exe exists in the $PathLaTeX folder
172 !insertmacro FileCheck $5 "latex.exe" "$PathLaTeX" # macro from LyXUtils.nsh
177 # finally set the name
178 ${if} $PathLaTeX != ""
179 ${andif} $LaTeXName != "MiKTeX 2.8"
180 ${andif} $LaTeXName != "MiKTeX 2.9"
181 StrCpy $LaTeXInstalled "TeXLive"
182 ReadRegStr $String HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "DisplayVersion"
184 ReadRegStr $String HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "DisplayVersion"
187 ReadRegStr $String HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2014" "DisplayVersion"
190 ReadRegStr $String HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2014" "DisplayVersion"
193 StrCpy $LaTeXName "TeXLive $String"
195 StrCpy $LaTeXName "TeXLive"
201 # ------------------------------
203 Function ConfigureMiKTeX
204 # installs the LaTeX class files that are delivered with LyX,
205 # a Perl interpreter for splitindex and pdfcrop
206 # and enable MiKTeX's automatic package installation
208 # install LyX's LaTeX class and style files and a Perl interpreter
209 ${if} $PathLaTeX != ""
210 ${if} $MultiUser.Privileges == "Admin"
211 ${orif} $MultiUser.Privileges == "Power"
212 ${if} $Is64bit == "true"
213 StrCpy $PathLaTeXLocal "$PathLaTeX" -15 # delete "\miktex\bin\x64"
215 StrCpy $PathLaTeXLocal "$PathLaTeX" -11 # delete "\miktex\bin"
218 StrCpy $PathLaTeXLocal "$APPDATA\MiKTeX\$MiKTeXVersion"
221 # only install the LyX packages if they are not already installed
222 ${ifnot} ${FileExists} "$PathLaTeXLocal\tex\latex\lyx\broadway.cls"
224 SetOutPath "$PathLaTeXLocal\tex\latex\dvipost"
225 File "${FILES_DVIPOST_PKG}\dvipost.sty"
226 # files in Resources\tex
227 SetOutPath "$PathLaTeXLocal\tex\latex\lyx"
228 CopyFiles /SILENT "$INSTDIR\Resources\tex\*.*" "$PathLaTeXLocal\tex\latex\lyx"
230 # refresh MiKTeX's file name database (do this always to assure everything is in place)
231 ${if} $MultiUser.Privileges != "Admin"
232 ${andif} $MultiUser.Privileges != "Power"
233 # call the non-admin version
234 nsExec::ExecToLog "$PathLaTeX\initexmf --update-fndb"
236 ${if} $MiKTeXUser != "HKCU" # call the admin version
237 nsExec::ExecToLog "$PathLaTeX\initexmf --admin --update-fndb"
239 nsExec::ExecToLog "$PathLaTeX\initexmf --update-fndb"
242 Pop $UpdateFNDBReturn # Return value
245 # install a Perl interpreter for splitindex and pdfcrop
246 SetOutPath "$INSTDIR"
247 # recursively copy all files under Perl
248 File /r "${FILES_PERL}"
250 ${endif} # end if $PathLaTeX != ""
253 # ------------------------------
255 Function ConfigureTeXLive
256 # installs the LaTeX class files that are delivered with LyX
257 # (TeXLive comes already with a Perl interpreter.)
259 ${if} $PathLaTeX != ""
260 StrCpy $PathLaTeXLocal "$PathLaTeX" -10 # delete "\bin\win32"
262 # only install the LyX packages if they are not already installed
263 ${ifnot} ${FileExists} "$PathLaTeXLocal\texmf-dist\tex\latex\lyx\broadway.cls"
265 SetOutPath "$PathLaTeXLocal\texmf-dist\tex\latex\dvipost"
266 File "${FILES_DVIPOST_PKG}\dvipost.sty"
267 # files in Resources\tex
268 SetOutPath "$PathLaTeXLocal\texmf-dist\tex\latex\lyx"
269 CopyFiles /SILENT "$INSTDIR\Resources\tex\*.*" "$PathLaTeXLocal\texmf-dist\tex\latex\lyx"
270 # update TeXLive's package file list
271 ExecWait '$PathLaTeX\texhash'