2 # check if MiKTeX or TeXLive is installed
4 # test if MiKTeX is installed
5 # reads the PATH variable via the registry because NSIS' "$%Path%" variable is not updated when the PATH changes
6 ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
7 StrCpy $Search "miktex"
8 Call LaTeXCheck # sets the path to the latex.exe to $LatexPath # Function from LyXUtils.nsh
10 ${if} $LatexPath != ""
11 # check if MiKTeX 2.4, 2.5 or 2.6 is installed
12 ReadRegStr $String HKLM "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Install Root"
14 StrCpy $MiKTeXVersion "2.4" # needed later for the configuration of MiKTeX
15 StrCpy $LaTeXName "MiKTeX 2.4"
17 # check if MiKTeX 2.5 or 2.6 is installed
20 EnumRegKey $1 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" $0 # check the last subkey
26 ${if} $String == "2.5"
27 StrCpy $MiKTeXVersion "2.5"
28 StrCpy $LaTeXName "MiKTeX 2.5"
30 ${if} $String == "2.6"
31 StrCpy $MiKTeXVersion "2.6"
32 StrCpy $LaTeXName "MiKTeX 2.6"
36 ${if} $LatexPath == "" # check if MiKTeX is installed only for the current user
37 ReadRegStr $String HKCU "Environment" "Path"
38 StrCpy $Search "miktex"
39 Call LaTeXCheck # function from LyXUtils.nsh
40 ${if} $LatexPath != ""
41 StrCpy $MiKTeXUser "HKCU" # needed later to configure MiKTeX
43 # check for MiKTeX 2.4
45 ReadRegStr $String HKCU "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Install Root"
47 StrCpy $MiKTeXVersion "2.4"
48 StrCpy $LaTeXName "MiKTeX 2.4"
50 # check for MiKTeX 2.5 and 2.6
53 EnumRegKey $1 HKCU "SOFTWARE\MiKTeX.org\MiKTeX" $0 # check the last subkey
59 ${if} $String == "2.5"
60 StrCpy $MiKTeXVersion "2.5"
61 StrCpy $LaTeXName "MiKTeX 2.5"
63 ${if} $String == "2.6"
64 StrCpy $MiKTeXVersion "2.6"
65 StrCpy $LaTeXName "MiKTeX 2.6"
69 ${if} $LatexPath != ""
70 StrCpy $MiKTeXInstalled "yes"
73 # test if TeXLive is installed
74 # as described at TeXLives' homepage there should be an entry in the PATH
75 ${if} $LatexPath == ""
76 ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
77 StrCpy $Search "TeXLive"
78 Call LaTeXCheck # function from LyXUtils.nsh
80 # check for the current user Path variable (the case when it is a live CD/DVD)
81 ${if} $LatexPath == ""
82 ReadRegStr $String HKCU "Environment" "Path"
83 StrCpy $Search "texlive"
85 Call LaTeXCheck # function from LyXUtils.nsh
87 # check if the variable TLroot exists (the case when it is installed using the program "tlpmgui")
88 ${if} $LatexPath == ""
89 ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "TLroot"
91 ReadRegStr $String HKCU "Environment" "TLroot" # the case when installed without admin permissions
93 StrCpy $LatexPath "$String\bin\win32"
94 # check if the latex.exe exists in the $LatexPath folder
95 !insertmacro FileCheck $5 "latex.exe" "$LatexPath" # macro from LyXUtils.nsh
100 ${if} $LatexPath != ""
101 ${andif} $LaTeXName != "MiKTeX 2.4"
102 ${andif} $LaTeXName != "MiKTeX 2.5"
103 ${andif} $LaTeXName != "MiKTeX 2.6"
104 StrCpy $LaTeXName "TeXLive"
109 # -------------------------------------------
111 !if ${INSTALLER_VERSION} == "Complete"
113 Function InstallMiKTeX
114 # install MiKTeX if not already installed
116 ${if} $LatexPath == ""
117 # launch MiKTeX's installer
118 MessageBox MB_OK|MB_ICONINFORMATION "$(LatexInfo)"
119 ExecWait ${MiKTeXInstall}
120 # test if MiKTeX is installed
121 ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
122 StrCpy $Search "miktex"
124 ${if} $LatexPath == ""
125 StrCpy $MiKTeXUser "HKCU"
126 ReadRegStr $String HKCU "Environment" "Path"
127 StrCpy $Search "miktex"
130 ${if} $LatexPath != ""
131 # set package repository (MiKTeX's primary package repository)
132 WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}" # special entry to tell the uninstaller that it was installed with LyX
133 StrCpy $MiKTeXInstalled "yes"
134 StrCpy $MiKTeXVersion ${MiKTeXDeliveredVersion}
135 ${if} $MiKTeXUser != "HKCU"
136 StrCpy $MiKTeXPath "$LatexPath" -11 # delete "\miktex\bin"
137 #MessageBox MB_OK|MB_ICONINFORMATION "$(MiKTeXPathInfo)" # info that MiKTeX's installation folder must have write permissions for all users to work properly
140 MessageBox MB_OK|MB_ICONSTOP "$(LatexError1)"
141 SetOutPath $TEMP # to be able to delete the $INSTDIR
144 ${endif} # endif $LatexPath != ""
149 !endif # endif ${INSTALLER_VERSION} == "Complete"
151 # ------------------------------
153 Function ConfigureMiKTeX
154 # installs the LaTeX class files that are delivered with LyX
155 # and enable MiKTeX's automatic package installation
157 StrCpy $String $LatexPath
158 StrCpy $Search "miktex\bin"
160 Call StrPoint # search the LaTeXPath for the phrase "miktex\bin" (function from LyXUtils.nsh)
161 ${if} $Pointer != "-1" # if something was found
162 IntOp $Pointer $Pointer - 1 # jump before the first "\" of "\miktex\bin"
163 StrCpy $String $String "$Pointer" # $String is now the part before "\miktex\bin"
164 # install LyX's special LaTeX class files
165 CreateDirectory "$String\tex\latex\lyx"
166 SetOutPath "$String\tex\latex\lyx"
167 File "${ClassFileDir}\lyxchess.sty"
168 File "${ClassFileDir}\lyxskak.sty"
169 CreateDirectory "$String\tex\latex\revtex"
170 SetOutPath "$String\tex\latex\revtex"
171 File "${ClassFileDir}\revtex.cls"
172 CreateDirectory "$String\tex\latex\hollywood"
173 SetOutPath "$String\tex\latex\hollywood"
174 File "${ClassFileDir}\hollywood.cls"
175 CreateDirectory "$String\tex\latex\broadway"
176 SetOutPath "$String\tex\latex\broadway"
177 File "${ClassFileDir}\broadway.cls"
178 # install LaTeX-package dvipost (dvipost is not available for MiKTeX)
179 SetOutPath "$String\tex\latex\" # Should there be a final \ before "?
180 File /r "${DVIPostFileDir}"
182 # refresh MiKTeX's file name database
183 ExecWait "$LaTeXPath\initexmf --update-fndb"
185 ${if} $MiKTeXVersion == "2.4"
186 # delete MiKTeX 2.4's dvipng executable as it is an old broken version. Then install a working one.
187 Delete "$String\miktex\bin\dvipng.exe"
189 SetOutPath "$String\miktex\bin"
190 File "${PRODUCT_DIR}\LyX\external\dvipng.exe"
191 # enable package installation without asking (1=Yes, 0=No, 2=Always Ask Before Installing)
192 WriteRegStr HKCU "SOFTWARE\MiK\MiKTeX\CurrentVersion\MiKTeX" "InstallPackagesOnTheFly" "1"
193 WriteRegStr HKCU "SOFTWARE\MiK\MiKTeX\CurrentVersion\MPM\Settings" "" ""
194 # Setting package repository (MiKTeX's primary package repository)
195 WriteRegStr HKCU "SOFTWARE\MiK\MiKTeX\CurrentVersion\MPM" "RemotePackageRepository" "${MiKTeXRepo}"
198 ${if} $MiKTeXVersion == "2.5"
199 # enable package installation without asking (t = Yes, f = No)
200 WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "AutoInstall" "1" # if only for curent user
201 ${if} $MiKTeXUser != "HKCU"
202 WriteRegStr SHCTX "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_AUTOINSTALL" "t"
204 # set package repository (MiKTeX's primary package repository)
205 WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RemoteRepository" "${MiKTeXRepo}" # if only for curent user
206 WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RepositoryType" "remote" # if only for curent user
207 ${if} $MiKTeXUser != "HKCU"
208 WriteRegStr SHCTX "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_REPOSITORY" "${MiKTeXRepo}"
212 ${if} $MiKTeXVersion == "2.6"
213 # enable package installation without asking (t = Yes, f = No)
214 WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "AutoInstall" "1" # if only for curent user
215 ${if} $MiKTeXUser != "HKCU"
216 WriteRegStr SHCTX "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "AutoInstall" "1" # if only for curent user
218 # set package repository (MiKTeX's primary package repository)
219 WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RemoteRepository" "${MiKTeXRepo}" # if only for curent user
220 WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RepositoryType" "remote" # if only for curent user
221 ${if} $MiKTeXUser != "HKCU"
222 WriteRegStr SHCTX "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RemoteRepository" "${MiKTeXRepo}" # if only for curent user
223 WriteRegStr SHCTX "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RepositoryType" "remote" # if only for curent user
227 # enable MiKTeX's automatic package installation
228 ${if} $MiKTeXVersion == "2.4"
229 ${orif} $MiKTeXVersion == "2.5"
230 ExecWait '$LaTeXPath\mpm.com --update-fndb'
231 ${else} # if MiKTeX 2.6
232 ExecWait '$LaTeXPath\mpm.exe --update-fndb'
234 # the following feature is planned to be used for a possible CD-version
235 # copy LaTeX-packages needed by LyX
236 # SetOutPath "$INSTDIR"
237 # File /r "${LaTeXPackagesDir}"
238 ${endif} # end ${if} $Pointer