2 # tests if MiKTeX is installed
3 # reads the PATH variable via the registry because NSIS' "$%Path%" variable is not updated when the PATH changes
5 ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
6 StrCpy $Search "miktex"
7 Call LaTeXCheck # sets the path to the latex.exe to $LatexPath # Function from LyXUtils.nsh
8 # check if MiKTeX 2.4 or 2.5 is installed
10 ReadRegStr $String HKLM "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Install Root"
12 StrCpy $MiKTeXVersion "2.4" # needed later for the configuration of MiKTeX
13 StrCpy $LaTeXName "MiKTeX 2.4"
16 ${if} $LatexPath == "" # check if MiKTeX is installed only for the current user
17 # check for MiKTeX 2.5
18 ReadRegStr $String HKCU "Environment" "Path"
19 StrCpy $Search "miktex"
20 Call LaTeXCheck # function from LyXUtils.nsh
21 ${if} $LatexPath != ""
22 StrCpy $MiKTeXUser "HKCU" # needed later to for a message about MiKTeX's install folder write permissions, see InstallActions-*.nsh
24 # check for MiKTeX 2.4
26 ReadRegStr $String HKCU "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Install Root"
28 StrCpy $MiKTeXVersion "2.4"
29 StrCpy $LaTeXName "MiKTeX 2.4"
33 ${if} $LatexPath != ""
34 StrCpy $MiKTeXInstalled "yes"
35 ${if} $LaTeXName != "MiKTeX 2.4"
36 StrCpy $LaTeXName "MiKTeX 2.5"
40 # test if TeXLive is installed
41 # as described at TeXLives' homepage there should be an entry in the PATH
42 ${if} $LatexPath == ""
43 ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
44 StrCpy $Search "TeXLive"
45 Call LaTeXCheck # function from LyXUtils.nsh
47 # check for the current user Path variable (the case when it is a live CD/DVD)
48 ${if} $LatexPath == ""
49 ReadRegStr $String HKCU "Environment" "Path"
50 StrCpy $Search "texlive"
52 Call LaTeXCheck # function from LyXUtils.nsh
54 # check if the variable TLroot exists (the case when it is installed using the program "tlpmgui")
55 ${if} $LatexPath == ""
56 ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "TLroot"
58 ReadRegStr $String HKCU "Environment" "TLroot" # the case when installed without admin permissions
60 StrCpy $LatexPath "$String\bin\win32"
61 # check if the latex.exe exists in the $LatexPath folder
62 !insertmacro FileCheck $5 "latex.exe" "$LatexPath" # macro from LyXUtils.nsh
67 ${if} $LatexPath != ""
68 ${andif} $LaTeXName != "MiKTeX 2.4"
69 ${andif} $LaTeXName != "MiKTeX 2.5"
70 StrCpy $LaTeXName "TeXLive"
75 # ------------------------------
77 Function ConfigureMiKTeX
78 # installs the LaTeX class files that are delivered with LyX
79 # and enable MiKTeX's automatic package installation
81 StrCpy $String $LatexPath
82 StrCpy $Search "miktex\bin"
84 Call StrPoint # search the LaTeXPath for the phrase "miktex\bin" (function from LyXUtils.nsh)
85 ${if} $Pointer != "-1" # if something was found
86 IntOp $Pointer $Pointer - 1 # jump before the first "\" of "\miktex\bin"
87 StrCpy $String $String "$Pointer" # $String is now the part before "\miktex\bin"
88 # install LyX's special LaTeX class files
89 CreateDirectory "$String\tex\latex\lyx"
90 SetOutPath "$String\tex\latex\lyx"
91 File "${ClassFileDir}\lyxchess.sty"
92 File "${ClassFileDir}\lyxskak.sty"
93 CreateDirectory "$String\tex\latex\revtex"
94 SetOutPath "$String\tex\latex\revtex"
95 File "${ClassFileDir}\revtex.cls"
96 CreateDirectory "$String\tex\latex\hollywood"
97 SetOutPath "$String\tex\latex\hollywood"
98 File "${ClassFileDir}\hollywood.cls"
99 CreateDirectory "$String\tex\latex\broadway"
100 SetOutPath "$String\tex\latex\broadway"
101 File "${ClassFileDir}\broadway.cls"
102 # install LaTeX-package dvipost (dvipost is not available for MiKTeX)
103 SetOutPath "$String\tex\latex\" # Should there be a final \ before "?
104 File /r "${DVIPostFileDir}"
106 ${if} $MiKTeXVersion == "2.4"
107 # refresh MiKTeX's file name database
108 ExecWait "$String\miktex\bin\initexmf --update-fndb"
109 # delete MiKTeX 2.4's dvipng executable as it is an old broken version. Then install a working one.
110 Delete "$String\miktex\bin\dvipng.exe"
112 SetOutPath "$String\miktex\bin"
113 File "${PRODUCT_DIR}\LyX\external\dvipng.exe"
114 # enable package installation without asking (1=Yes, 0=No, 2=Always Ask Before Installing)
115 WriteRegStr HKCU "SOFTWARE\MiK\MiKTeX\CurrentVersion\MiKTeX" "InstallPackagesOnTheFly" "1"
116 WriteRegStr HKCU "SOFTWARE\MiK\MiKTeX\CurrentVersion\MPM\Settings" "" ""
117 # Setting package repository (MiKTeX's primary package repository)
118 WriteRegStr HKCU "SOFTWARE\MiK\MiKTeX\CurrentVersion\MPM" "RemotePackageRepository" "${MiKTeXRepo}"
120 ${else} # if MiKTeX 2.5
121 # refresh MiKTeX's file name database
122 ExecWait "$LaTeXPath\initexmf --update-fndb"
123 # enable package installation without asking (t = Yes, f = No)
124 WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\2.5\MPM" "AutoInstall" "1" # if only for curent user
125 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_AUTOINSTALL" "t"
126 # set package repository (MiKTeX's primary package repository)
127 WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\2.5\MPM" "RemoteRepository" "${MiKTeXRepo}" # if only for curent user
128 WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\2.5\MPM" "RepositoryType" "remote" # if only for curent user
129 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_REPOSITORY" "${MiKTeXRepo}"
132 # enable MiKTeX's automatic package installation
133 ExecWait '$LaTeXPath\mpm.com --update-fndb'
134 # the following feature is planned to be used for a possible CD-version
135 # copy LaTeX-packages needed by LyX
136 # SetOutPath "$INSTDIR"
137 # File /r "${LaTeXPackagesDir}"
138 ${endif} # end ${if} $Pointer