]> git.lyx.org Git - features.git/blobdiff - development/Win32/packaging/installer/include/LaTeX.nsh
Consider inset strings in simple find/replaceAll (#12049)
[features.git] / development / Win32 / packaging / installer / include / LaTeX.nsh
index 5a5a1bc066cf95e21cee45ff5743c262556771da..fa6f34daf378be9baf0da252cae706f0082986bb 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
 LaTeX.nsh
 
 Handling of LaTeX distributions
@@ -8,19 +8,13 @@ Handling of LaTeX distributions
 #
 # - LaTeXActions (checks if MiKTeX or TeXLive is installed)
 #
-# - InstallMiKTeX (installs MiKTeX if not already installed),
-#   only for bunlde installer, uses:
-#    LaTeXCheck # function from LyXUtils.nsh
-#
 # - 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
 #   (installs the LaTeX class files that are delivered with LyX)
-#
-# - UpdateMiKTeX (asks to update MiKTeX)
 
 # ---------------------------------------
 
@@ -60,10 +54,6 @@ Function LaTeXActions
     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"
@@ -84,10 +74,6 @@ Function LaTeXActions
     IntOp $0 $0 + 1
     Goto loop64
    done64:
-   ${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"
@@ -116,10 +102,6 @@ Function LaTeXActions
     IntOp $0 $0 + 1
     Goto loopB
    doneB:
-   ${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"
@@ -165,9 +147,9 @@ Function LaTeXActions
    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 -28 # remove '\tlpkg\installer\uninst.bat"'
@@ -182,12 +164,11 @@ Function LaTeXActions
   ${endif}
   # finally set the name
   ${if} $PathLaTeX != ""
-  ${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\TeXLive2012" "DisplayVersion"
+    ReadRegStr $String HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXLive2015" "DisplayVersion"
    ${endif}
    ${if} $String != ""
     StrCpy $LaTeXName "TeXLive $String"
@@ -198,49 +179,11 @@ Function LaTeXActions
 
 FunctionEnd
 
-# -------------------------------------------
-
-!if ${SETUPTYPE} == BUNDLE
-
- Function InstallMiKTeX
-  # installs MiKTeX if not already installed
-  
-  ${if} $PathLaTeX == ""
-   # launch MiKTeX's installer
-   MessageBox MB_OK|MB_ICONINFORMATION "$(LatexInfo)"
-   ExecWait ${MiKTeXInstall}
-   # test if MiKTeX is installed
-   Call LaTeXActions
-   ${if} ${RunningX64}
-    SetRegView 32 # we install the 32bit version of MiKTeX
-   ${endif}
-   ${if} $PathLaTeX != ""
-    # special entry that it was installed together with LyX
-    # so that we can later uninstall it together with LyX
-    ${if} $MiKTeXUser == "HKCU"
-     WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
-    ${else}
-     WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
-    ${endif}
-    StrCpy $LaTeXInstalled "MiKTeX"
-    StrCpy $MiKTeXVersion ${MiKTeXDeliveredVersion}
-   ${else}
-    MessageBox MB_OK|MB_ICONSTOP "$(LatexError1)"
-    SetOutPath $TEMP # to be able to delete the $INSTDIR
-    RMDir /r $INSTDIR
-    Abort
-   ${endif} # endif $PathLaTeX != ""
-  ${endif}
-
-  FunctionEnd
-
-!endif # endif ${SETUPTYPE} == BUNDLE
-
 # ------------------------------
 
 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
@@ -258,115 +201,31 @@ Function ConfigureMiKTeX
 
   # only install the LyX packages if they are not already installed
   ${ifnot} ${FileExists} "$PathLaTeXLocal\tex\latex\lyx\broadway.cls"
-   # dvipost
-   SetOutPath "$PathLaTeXLocal\tex\latex\dvipost"
-   File "${FILES_DVIPOST_PKG}\dvipost.sty"
-   # Belarusian support
-   SetOutPath "$PathLaTeXLocal\tex\generic\babel"
-   File "${FILES_DVIPOST_PKG}\belarusian.ldf"
-   File "${FILES_DVIPOST_PKG}\belarusian.sty"
-   # Hungarian support
-   SetOutPath "$PathLaTeXLocal\tex\generic\babel"
-   File "${FILES_DVIPOST_PKG}\magyar.ldf"
    # files in Resources\tex
    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
-  ${if} ${RunningX64}
-   SetRegView 32 # FIXME: recheck this if the 64bit version of MiKTeX is out of beta state 
-  ${endif}
-  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}
+
+   # refresh MiKTeX's file name database (do this always to assure everything is in place)
+   ${if} $MultiUser.Privileges != "Admin"
+   ${andif} $MultiUser.Privileges != "Power"
+    # call the non-admin version
+    nsExec::ExecToLog "$PathLaTeX\initexmf --update-fndb"
    ${else}
-    ${ifnot} ${FileExists} "$PathLaTeX\perl.exe"
-     ${if} $Is64bit == "true"
-      StrCpy $3 "$PathLaTeX" -15 # delete "\miktex\bin\x64"
-     ${else}
-      StrCpy $3 "$PathLaTeX" -11 # delete "\miktex\bin"
-     ${endif}
-     SetOutPath "$3"
-     File /r ${FILES_MIKTEX}
-     # move the files to the correct location for 64bit
-     ${if} $Is64bit == "true"
-      CopyFiles /SILENT /FILESONLY "$3\miktex\bin\*.*" "$PathLaTeX"
-      Delete "$3\miktex\bin\*.*"
-      CreateDirectory "$3\miktex\bin\lib"
-      CopyFiles /SILENT "$3\miktex\lib\*.*" "$3\miktex\bin\lib"
-      RMDir /r "$3\miktex\lib"
-     ${endif}
-    ${endif}
-   ${endif}
-  ${else}
-   ${ifnot} ${FileExists} "$PathLaTeX\perl.exe"
-    SetOutPath "$PathLaTeXLocal"
-    File /r ${FILES_MIKTEX}
-    # move the files to the correct location for 64bit
-    ${if} $Is64bit == "true"
-     CopyFiles /SILENT /FILESONLY "$PathLaTeXLocal\miktex\bin\*.*" "$PathLaTeX"
-     Delete "$PathLaTeXLocal\miktex\bin\*.*"
-     CreateDirectory "$PathLaTeXLocal\miktex\bin\lib"
-     CopyFiles /SILENT "$PathLaTeXLocal\miktex\lib\*.*" "$PathLaTeXLocal\miktex\bin\lib"
-     RMDir /r "$PathLaTeXLocal\miktex\lib"
+    ${if} $MiKTeXUser != "HKCU" # call the admin version
+     nsExec::ExecToLog "$PathLaTeX\initexmf --admin --update-fndb"
+    ${else}
+     nsExec::ExecToLog "$PathLaTeX\initexmf --update-fndb"
     ${endif}
    ${endif}
+   Pop $UpdateFNDBReturn # Return value
   ${endif}
   
-  # refresh MiKTeX's file name database (do this always to assure everything is in place)
-  ${if} $MultiUser.Privileges != "Admin"
-  ${andif} $MultiUser.Privileges != "Power"
-   # call the non-admin version
-   nsExec::ExecToLog "$PathLaTeX\initexmf --update-fndb"
-  ${else}
-   ${if} $MiKTeXUser != "HKCU" # call the admin version
-    nsExec::ExecToLog "$PathLaTeX\initexmf --admin --update-fndb"
-   ${else}
-    nsExec::ExecToLog "$PathLaTeX\initexmf --update-fndb"
-   ${endif}
-  ${endif}
-  Pop $UpdateFNDBReturn # Return value
-  
- ${endif} # end if $PathLaTeX != ""
-  
-  # 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}
-  ${if} $MiKTeXUser == "HKCU" # if only for current user
-   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}
-   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}
-  
-  # update MiKTeX's package file list
-  ExecWait '$PathLaTeX\mpm.exe --update-fndb'
-  
-  # we must return to 32bit because LyX is a 32bit application
-  SetRegView 32
-  
+  # install a Perl interpreter for splitindex and pdfcrop
+  SetOutPath "$INSTDIR\Perl"
+  # recursively copy all files under Perl
+  File /r "${FILES_PERL}\"
+
+  ${endif} # end if $PathLaTeX != ""  
 FunctionEnd
 
 # ------------------------------
@@ -380,43 +239,12 @@ Function ConfigureTeXLive
   
   # only install the LyX packages if they are not already installed
   ${ifnot} ${FileExists} "$PathLaTeXLocal\texmf-dist\tex\latex\lyx\broadway.cls"
-   # dvipost
-   SetOutPath "$PathLaTeXLocal\texmf-dist\tex\latex\dvipost"
-   File "${FILES_DVIPOST_PKG}\dvipost.sty"
    # files in Resources\tex
    SetOutPath "$PathLaTeXLocal\texmf-dist\tex\latex\lyx"
    CopyFiles /SILENT "$INSTDIR\Resources\tex\*.*" "$PathLaTeXLocal\texmf-dist\tex\latex\lyx"
+   # update TeXLive's package file list
+   ExecWait '$PathLaTeX\texhash'
   ${endif}
  ${endif}
  
- # update TeXLive's package file list
- ExecWait '$PathLaTeX\texhash'
- # update TeXLive
- ExecWait '$PathLaTeX\tlmgr update --all'
 FunctionEnd
-
-# ------------------------------
-
-Function UpdateMiKTeX
- # asks to update MiKTeX
-
-  MessageBox MB_YESNO|MB_ICONINFORMATION "$(MiKTeXInfo)" IDYES UpdateNow IDNO UpdateLater
-  UpdateNow:
-  # the update wizard is started by the miktex-update.exe
-  ${if} $MultiUser.Privileges != "Admin"
-  ${andif} $MultiUser.Privileges != "Power"
-   # call the non-admin version
-    ExecWait '"$PathLaTeX\internal\miktex-update.exe"'
-  ${else}
-   ${if} $MiKTeXUser != "HKCU" # call the admin version
-    ExecWait '"$PathLaTeX\internal\miktex-update_admin.exe"'
-   ${else}
-     ExecWait '"$PathLaTeX\internal\miktex-update.exe"'
-   ${endif}
-  ${endif}
-  UpdateLater:
-
-FunctionEnd
-