]> git.lyx.org Git - lyx.git/blobdiff - development/Win32/packaging/installer/include/LaTeX.nsh
Win installer: push the changes that are already part of the 2.2.0 installer
[lyx.git] / development / Win32 / packaging / installer / include / LaTeX.nsh
index 809442bea937d8c2d229c19e3c4e170b8b272e7f..68c6c36fbcca4807189099159a543dd0046f367d 100644 (file)
@@ -14,7 +14,7 @@ Handling of LaTeX distributions
 #
 # - ConfigureMiKTeX
 #   (installs the LaTeX class files that are delivered with LyX,
-#    a Perl interpreter for splitindex
+#    a Perl interpreter for splitindex and pdfcrop
 #    and enable MiKTeX's automatic package installation)
 #
 # - ConfigureTeXLive
@@ -27,22 +27,63 @@ Handling of LaTeX distributions
 Function LaTeXActions
  # checks if MiKTeX or TeXLive is installed
 
+  StrCpy $Is64bit "false"
+  
+  ${if} ${RunningX64}
+   SetRegView 64 # the PATH is in the 64bit registry section
+  ${endif}
   # test if MiKTeX is installed
   # reads the PATH variable via the registry because NSIS' "$%Path%" variable is not updated when the PATH changes
   ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
   StrCpy $Search "miktex"
   Call LaTeXCheck # sets the path to the latex.exe to $PathLaTeX # Function from LyXUtils.nsh
   
+  StrCpy $String $PathLaTeX
+  StrCpy $Search "x64" # search if it is 64bit MiKTeX
+  Call StrPoint # Function from LyXUtils.nsh
+  ${if} $Pointer != "-1" # if something was found
+   StrCpy $Is64bit "true"
+  ${endif}
+  
+  # check for 32bit MiKTeX
   ${if} $PathLaTeX != ""
+  ${andif} $Is64bit != "true"
+   ${if} ${RunningX64}
+    SetRegView 32
+   ${endif}
+   # check if MiKTeX 2.8 or newer is installed
+   StrCpy $0 0
+   loop32:
+    EnumRegKey $1 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" $0 # check the last subkey
+    StrCmp $1 "" done32
+    StrCpy $String $1
+    IntOp $0 $0 + 1
+    Goto loop32
+   done32:
+   ${if} $String == "2.8"
+    StrCpy $MiKTeXVersion "2.8"
+    StrCpy $LaTeXName "MiKTeX 2.8"
+   ${endif}
+   ${if} $String == "2.9"
+    StrCpy $MiKTeXVersion "2.9"
+    StrCpy $LaTeXName "MiKTeX 2.9"
+   ${endif}
+  ${endif}
+  
+  # check for 64bit MiKTeX
+  ${if} $LaTeXName == ""
+   ${if} ${RunningX64}
+    SetRegView 64
+   ${endif}
    # check if MiKTeX 2.8 or newer is installed
    StrCpy $0 0
-   loopA:
+   loop64:
     EnumRegKey $1 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" $0 # check the last subkey
-    StrCmp $1 "" doneA
+    StrCmp $1 "" done64
     StrCpy $String $1
     IntOp $0 $0 + 1
-    Goto loopA
-   doneA:
+    Goto loop64
+   done64:
    ${if} $String == "2.8"
     StrCpy $MiKTeXVersion "2.8"
     StrCpy $LaTeXName "MiKTeX 2.8"
@@ -56,6 +97,9 @@ Function LaTeXActions
   ${if} $PathLaTeX != ""
    StrCpy $MiKTeXUser "HKLM" # needed later to configure MiKTeX
   ${else} # check if MiKTeX is installed only for the current user
+   ${if} ${RunningX64}
+    SetRegView 64 # the PATH is in the 64bit registry section
+   ${endif}
    ReadRegStr $String HKCU "Environment" "Path"
    StrCpy $Search "miktex"
    Call LaTeXCheck # function from LyXUtils.nsh
@@ -81,14 +125,29 @@ Function LaTeXActions
     StrCpy $LaTeXName "MiKTeX 2.9"
    ${endif}
   ${endif}
-    
+  
   ${if} $PathLaTeX != ""
+   StrCpy $String $PathLaTeX
+   StrCpy $Search "x64" # search if it is 64bit MiKTeX
+   Call StrPoint # Function from LyXUtils.nsh
+   ${if} $Pointer != "-1" # if something was found
+    StrCpy $Is64bit "true"
+   ${endif}
    StrCpy $LaTeXInstalled "MiKTeX"
+   # on some installations the path ends with a "\" on some not
+   # therefore assure that we remove it if it exists
+   StrCpy $0 $PathLaTeX "" -1
+   ${if} $0 == "\"
+    StrCpy $PathLaTeX "$PathLaTeX" -1 # delete "\"
+   ${endif}
   ${endif}
   
   # test if TeXLive is installed
   # TeXLive can be installed so that it appears in the PATH variable and/or only as current user.
   # The safest method is to first check for the PATH because this is independent of the TeXLive version.
+  ${if} ${RunningX64}
+   SetRegView 64 # the PATH is in the 64bit registry section
+  ${endif}
   ${if} $PathLaTeX == ""
    ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
    StrCpy $Search "TeXLive"
@@ -102,13 +161,16 @@ Function LaTeXActions
    Call LaTeXCheck # function from LyXUtils.nsh
   ${endif}
   # check if it was installed to the system
+  ${if} ${RunningX64}
+   SetRegView 32 # TeXLive is a 32bit application
+  ${endif}
   ${if} $PathLaTeX == ""
-   ReadRegStr $String HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2012" "UninstallString"
+   ReadRegStr $String HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "UninstallString"
    ${if} $String == ""
-    ReadRegStr $String HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2012" "UninstallString"
+    ReadRegStr $String HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "UninstallString"
    ${endif}
    ${if} $String != ""
-    StrCpy $String $String -27 # remove 'tlpkg\installer\uninst.bat"'
+    StrCpy $String $String -28 # remove '\tlpkg\installer\uninst.bat"'
     StrCpy $String $String "" 1 # remove the leading quote
    ${endif}
    StrCpy $PathLaTeX "$String\bin\win32"
@@ -123,9 +185,15 @@ Function LaTeXActions
   ${andif} $LaTeXName != "MiKTeX 2.8"
   ${andif} $LaTeXName != "MiKTeX 2.9"
    StrCpy $LaTeXInstalled "TeXLive"
-   ReadRegStr $String HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2012" "DisplayVersion"
+   ReadRegStr $String HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "DisplayVersion"
+   ${if} $String == ""
+    ReadRegStr $String HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "DisplayVersion"
+   ${endif}
+   ${if} $String == ""
+    ReadRegStr $String HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2014" "DisplayVersion"
+   ${endif}
    ${if} $String == ""
-    ReadRegStr $String HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2012" "DisplayVersion"
+    ReadRegStr $String HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2014" "DisplayVersion"
    ${endif}
    ${if} $String != ""
     StrCpy $LaTeXName "TeXLive $String"
@@ -145,25 +213,23 @@ FunctionEnd
   
   ${if} $PathLaTeX == ""
    # launch MiKTeX's installer
-   MessageBox MB_OK|MB_ICONINFORMATION "$(LatexInfo)"
-   ExecWait ${MiKTeXInstall}
-   # test if MiKTeX is installed
-   ReadRegStr $String HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
-   StrCpy $Search "miktex"
-   Call LaTeXCheck # function from LyXUtils.nsh
-   ${if} $PathLaTeX != ""
-    StrCpy $MiKTeXUser "HKLM"
+   MessageBox MB_OK|MB_ICONINFORMATION "$(LatexInfo)" /SD IDOK
+   ${if} $MultiUser.Privileges != "Admin"
+   ${andif} $MultiUser.Privileges != "Power"
+    # call the non-admin version
+    ExecWait ${MiKTeXInstall}
    ${else}
-    StrCpy $MiKTeXUser "HKCU"
-    ReadRegStr $String HKCU "Environment" "Path"
-    StrCpy $Search "miktex"
-    Call LaTeXCheck # function from LyXUtils.nsh
+    ExecWait "${MiKTeXInstall} --shared"
+   ${endif}
+   # test if MiKTeX is installed
+   Call LaTeXActions
+   ${if} ${RunningX64}
+    SetRegView 32 # we install the 32bit version of MiKTeX
    ${endif}
    ${if} $PathLaTeX != ""
-    # set package repository (MiKTeX's primary package repository)
+    # special entry that it was installed together with LyX
+    # so that we can later uninstall it together with LyX
     ${if} $MiKTeXUser == "HKCU"
-     # special entry that it was installed together with LyX
-     # so that we can later uninstall it together with LyX
      WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
     ${else}
      WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
@@ -171,7 +237,7 @@ FunctionEnd
     StrCpy $LaTeXInstalled "MiKTeX"
     StrCpy $MiKTeXVersion ${MiKTeXDeliveredVersion}
    ${else}
-    MessageBox MB_OK|MB_ICONSTOP "$(LatexError1)"
+    MessageBox MB_OK|MB_ICONSTOP "$(LatexError1)" /SD IDOK
     SetOutPath $TEMP # to be able to delete the $INSTDIR
     RMDir /r $INSTDIR
     Abort
@@ -186,14 +252,18 @@ FunctionEnd
 
 Function ConfigureMiKTeX
  # installs the LaTeX class files that are delivered with LyX,
- # a Perl interpreter for splitindex
+ # a Perl interpreter for splitindex and pdfcrop
  # and enable MiKTeX's automatic package installation
  
  # install LyX's LaTeX class and style files and a Perl interpreter
  ${if} $PathLaTeX != ""
   ${if} $MultiUser.Privileges == "Admin"
   ${orif} $MultiUser.Privileges == "Power"
-   StrCpy $PathLaTeXLocal "$PathLaTeX" -11 # delete "\miktex\bin"
+   ${if} $Is64bit == "true"
+    StrCpy $PathLaTeXLocal "$PathLaTeX" -15 # delete "\miktex\bin\x64"
+   ${else}
+    StrCpy $PathLaTeXLocal "$PathLaTeX" -11 # delete "\miktex\bin"
+   ${endif}
   ${else}
    StrCpy $PathLaTeXLocal "$APPDATA\MiKTeX\$MiKTeXVersion"
   ${endif}
@@ -207,28 +277,21 @@ Function ConfigureMiKTeX
    SetOutPath "$PathLaTeXLocal\tex\latex\lyx"
    CopyFiles /SILENT "$INSTDIR\Resources\tex\*.*" "$PathLaTeXLocal\tex\latex\lyx"
   ${endif}
-  
-  # only install a Perl interpreter if it is not already installed
-  # this is only possible if MikTeX _and_ LyX is installed with the same privileges
-  ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\MiKTeX $MiKTeXVersion" "DisplayVersion"
-  ${if} $MultiUser.Privileges != "Admin"
-  ${andif} $MultiUser.Privileges != "Power"
-   ${if} $0 == ""
-    ${ifnot} ${FileExists} "$PathLaTeX\perl.exe"
-     MessageBox MB_OK|MB_ICONINFORMATION "$(MultipleIndexesNotAvailable)"
-    ${endif}
-   ${else}
-    ${ifnot} ${FileExists} "$PathLaTeX\perl.exe"
-     SetOutPath "$PathLaTeXLocal"
-     File /r ${FILES_MIKTEX}
-    ${endif}
-   ${endif}
-  ${else}
-   ${ifnot} ${FileExists} "$PathLaTeX\perl.exe"
-    SetOutPath "$PathLaTeXLocal"
-    File /r ${FILES_MIKTEX}
-   ${endif}
+  # Belarusian support
+  ${ifnot} ${FileExists} "$PathLaTeXLocal\tex\generic\babel\belarusian.ldf"
+   SetOutPath "$PathLaTeXLocal\tex\generic\babel"
+   File "${FILES_DVIPOST_PKG}\belarusian.ldf"
+   File "${FILES_DVIPOST_PKG}\belarusian.sty"
   ${endif}
+  # Hungarian support
+  # this is a replacement therefore do this in every case
+  SetOutPath "$PathLaTeXLocal\tex\generic\babel"
+  File "${FILES_DVIPOST_PKG}\magyar.ldf"
+  
+  # install a Perl interpreter for splitindex and pdfcrop
+  SetOutPath "$INSTDIR"
+  # recursively copy all files under Perl
+  File /r "${FILES_PERL}"
   
   # refresh MiKTeX's file name database (do this always to assure everything is in place)
   ${if} $MultiUser.Privileges != "Admin"
@@ -246,25 +309,48 @@ Function ConfigureMiKTeX
   
  ${endif} # end if $PathLaTeX != ""
   
-  # enable package installation without asking (1 = Yes, 0 = No, 2 = Ask me first)
-  WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "AutoInstall" "1" # if only for current user
-  ${if} $MiKTeXUser != "HKCU"
-   WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "AutoInstall" "1"
+  # enable package installation without asking (1 = Yes, 0 = No, 2 = Ask me first) and
+  # if there is not package repository (MiKTeX's primary package repository) then set it
+  ${if} ${RunningX64}
+  ${andif} $Is64bit == "true"
+   SetRegView 64
+  ${else}
+   SetRegView 32
   ${endif}
-  # set package repository (MiKTeX's primary package repository)
-  WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RemoteRepository" "${MiKTeXRepo}" # if only for current user
-  WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RepositoryType" "remote" # if only for current user
-  ${if} $MiKTeXUser != "HKCU"
-   WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RemoteRepository" "${MiKTeXRepo}"
-   WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RepositoryType" "remote"
+  ${if} $MiKTeXUser == "HKCU" # if only for current user
+   # if AutoInstall is set to "0" we can assume that this was set purposly since the default is "1"
+   ReadRegStr $2 HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "AutoInstall"
+   ${if} $2 == "0"
+    Goto NoAutoInstall
+   ${endif}
+   WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "AutoInstall" "1"
+   ReadRegStr $1 HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RemoteRepository"
+   ${if} $1 == ""
+    WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RemoteRepository" "${MiKTeXRepo}" 
+    WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RepositoryType" "remote"
+   ${endif}
+  ${else}
+   # if AutoInstall is set to "0" we can assume that this was set purposly since the default is "1"
+   ReadRegStr $2 HKLM "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "AutoInstall"
+   ${if} $2 == "0"
+    Goto NoAutoInstall
+   ${endif}
+   WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "AutoInstall" "1"
+   ReadRegStr $1 HKLM "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RemoteRepository"
+   ${if} $1 == ""
+    WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RemoteRepository" "${MiKTeXRepo}"
+    WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "RepositoryType" "remote"
+   ${endif}
+   # we need to state that missing packages should be installed for all users too
+   WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\$MiKTeXVersion\MPM" "AutoAdmin" "t"
   ${endif}
+  NoAutoInstall:
   
   # update MiKTeX's package file list
   ExecWait '$PathLaTeX\mpm.exe --update-fndb'
-  # the following feature is planned to be used for a possible Live version
-  # copy LaTeX-packages needed by LyX
-  # SetOutPath "$INSTDIR"
-  # File /r "${LaTeXPackagesDir}"
+  
+  # we must return to 32bit because LyX is a 32bit application
+  SetRegView 32
   
 FunctionEnd
 
@@ -301,9 +387,8 @@ FunctionEnd
 Function UpdateMiKTeX
  # asks to update MiKTeX
 
-  MessageBox MB_YESNO|MB_ICONINFORMATION "$(MiKTeXInfo)" IDYES UpdateNow IDNO UpdateLater
+  MessageBox MB_YESNO|MB_ICONINFORMATION "$(MiKTeXInfo)" /SD IDNO IDYES UpdateNow IDNO UpdateLater
   UpdateNow:
-  StrCpy $0 $PathLaTeX -4 # remove "\bin"
   # the update wizard is started by the miktex-update.exe
   ${if} $MultiUser.Privileges != "Admin"
   ${andif} $MultiUser.Privileges != "Power"