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.9"
58 StrCpy $MiKTeXVersion "2.9"
59 StrCpy $LaTeXName "MiKTeX 2.9"
63 # check for 64bit MiKTeX
64 ${if} $LaTeXName == ""
68 # check if MiKTeX 2.8 or newer is installed
71 EnumRegKey $1 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" $0 # check the last subkey
77 ${if} $String == "2.9"
78 StrCpy $MiKTeXVersion "2.9"
79 StrCpy $LaTeXName "MiKTeX 2.9"
83 ${if} $PathLaTeX != ""
84 StrCpy $MiKTeXUser "HKLM" # needed later to configure MiKTeX
85 ${else} # check if MiKTeX is installed only for the current user
87 SetRegView 64 # the PATH is in the 64bit registry section
89 ReadRegStr $String HKCU "Environment" "Path"
90 StrCpy $Search "miktex"
91 Call LaTeXCheck # function from LyXUtils.nsh
92 ${if} $PathLaTeX != ""
93 StrCpy $MiKTeXUser "HKCU"
96 ${if} $LaTeXName == "" # check for the MiKTeX version
99 EnumRegKey $1 HKCU "SOFTWARE\MiKTeX.org\MiKTeX" $0 # check the last subkey
105 ${if} $String == "2.9"
106 StrCpy $MiKTeXVersion "2.9"
107 StrCpy $LaTeXName "MiKTeX 2.9"
111 ${if} $PathLaTeX != ""
112 StrCpy $String $PathLaTeX
113 StrCpy $Search "x64" # search if it is 64bit MiKTeX
114 Call StrPoint # Function from LyXUtils.nsh
115 ${if} $Pointer != "-1" # if something was found
116 StrCpy $Is64bit "true"
118 StrCpy $LaTeXInstalled "MiKTeX"
119 # on some installations the path ends with a "\" on some not
120 # therefore assure that we remove it if it exists
121 StrCpy $0 $PathLaTeX "" -1
123 StrCpy $PathLaTeX "$PathLaTeX" -1 # delete "\"
127 # test if TeXLive is installed
128 # TeXLive can be installed so that it appears in the PATH variable and/or only as current user.
129 # The safest method is to first check for the PATH because this is independent of the TeXLive version.
131 SetRegView 64 # the PATH is in the 64bit registry section
133 ${if} $PathLaTeX == ""
134 ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
135 StrCpy $Search "TeXLive"
136 Call LaTeXCheck # function from LyXUtils.nsh
138 # check for the current user Path variable
139 ${if} $PathLaTeX == ""
140 ReadRegStr $String HKCU "Environment" "Path"
141 StrCpy $Search "texlive"
143 Call LaTeXCheck # function from LyXUtils.nsh
145 # check if it was installed to the system
147 SetRegView 32 # TeXLive is a 32bit application
149 ${if} $PathLaTeX == ""
150 ReadRegStr $String HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "UninstallString"
152 ReadRegStr $String HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "UninstallString"
155 StrCpy $String $String -28 # remove '\tlpkg\installer\uninst.bat"'
156 StrCpy $String $String "" 1 # remove the leading quote
158 StrCpy $PathLaTeX "$String\bin\win32"
159 # check if the latex.exe exists in the $PathLaTeX folder
160 !insertmacro FileCheck $5 "latex.exe" "$PathLaTeX" # macro from LyXUtils.nsh
165 # finally set the name
166 ${if} $PathLaTeX != ""
167 ${andif} $LaTeXName != "MiKTeX 2.9"
168 StrCpy $LaTeXInstalled "TeXLive"
169 ReadRegStr $String HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "DisplayVersion"
171 ReadRegStr $String HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "DisplayVersion"
174 StrCpy $LaTeXName "TeXLive $String"
176 StrCpy $LaTeXName "TeXLive"
182 # ------------------------------
184 Function ConfigureMiKTeX
185 # installs the LaTeX class files that are delivered with LyX,
186 # a Perl interpreter for splitindex and pdfcrop
187 # and enable MiKTeX's automatic package installation
189 # install LyX's LaTeX class and style files and a Perl interpreter
190 ${if} $PathLaTeX != ""
191 ${if} $MultiUser.Privileges == "Admin"
192 ${orif} $MultiUser.Privileges == "Power"
193 ${if} $Is64bit == "true"
194 StrCpy $PathLaTeXLocal "$PathLaTeX" -15 # delete "\miktex\bin\x64"
196 StrCpy $PathLaTeXLocal "$PathLaTeX" -11 # delete "\miktex\bin"
199 StrCpy $PathLaTeXLocal "$APPDATA\MiKTeX\$MiKTeXVersion"
202 # only install the LyX packages if they are not already installed
203 ${ifnot} ${FileExists} "$PathLaTeXLocal\tex\latex\lyx\broadway.cls"
204 # files in Resources\tex
205 SetOutPath "$PathLaTeXLocal\tex\latex\lyx"
206 CopyFiles /SILENT "$INSTDIR\Resources\tex\*.*" "$PathLaTeXLocal\tex\latex\lyx"
208 # refresh MiKTeX's file name database (do this always to assure everything is in place)
209 ${if} $MultiUser.Privileges != "Admin"
210 ${andif} $MultiUser.Privileges != "Power"
211 # call the non-admin version
212 nsExec::ExecToLog "$PathLaTeX\initexmf --update-fndb"
214 ${if} $MiKTeXUser != "HKCU" # call the admin version
215 nsExec::ExecToLog "$PathLaTeX\initexmf --admin --update-fndb"
217 nsExec::ExecToLog "$PathLaTeX\initexmf --update-fndb"
220 Pop $UpdateFNDBReturn # Return value
223 # install a Perl interpreter for splitindex and pdfcrop
224 SetOutPath "$INSTDIR"
225 # recursively copy all files under Perl
226 File /r "${FILES_PERL}"
228 ${endif} # end if $PathLaTeX != ""
231 # ------------------------------
233 Function ConfigureTeXLive
234 # installs the LaTeX class files that are delivered with LyX
235 # (TeXLive comes already with a Perl interpreter.)
237 ${if} $PathLaTeX != ""
238 StrCpy $PathLaTeXLocal "$PathLaTeX" -10 # delete "\bin\win32"
240 # only install the LyX packages if they are not already installed
241 ${ifnot} ${FileExists} "$PathLaTeXLocal\texmf-dist\tex\latex\lyx\broadway.cls"
242 # files in Resources\tex
243 SetOutPath "$PathLaTeXLocal\texmf-dist\tex\latex\lyx"
244 CopyFiles /SILENT "$INSTDIR\Resources\tex\*.*" "$PathLaTeXLocal\texmf-dist\tex\latex\lyx"
245 # update TeXLive's package file list
246 ExecWait '$PathLaTeX\texhash'