]> git.lyx.org Git - features.git/blobdiff - development/Win32/packaging/installer/setup/install.nsh
Windows packaging updates.
[features.git] / development / Win32 / packaging / installer / setup / install.nsh
index d0e40b64f6792548f771cc6e0f047a0b4b5b7d3b..36013295280b34c967d1cee0f2fa21fcebde528f 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
 
 install.nsh
 
@@ -14,6 +14,26 @@ Var PythonCompileReturn
 
 Section -ProgramFiles SecProgramFiles
 
+  # if the $INSTDIR does not contain "LyX" we must add a subfolder to avoid that LyX will e.g.
+  # be installed directly to C:\programs - the uninstaller will then delete the whole
+  # C:\programs directory
+  StrCpy $String $INSTDIR
+  StrCpy $Search "LyX"
+  Call StrPoint # function from LyXUtils.nsh
+  ${if} $Pointer == "-1"
+   StrCpy $INSTDIR "$INSTDIR\${APP_DIR}"
+  ${endif}
+
+ !if ${SETUPTYPE} != BUNDLE
+  # abort the installation if no LaTeX was found but should be used
+  ${if} $PathLaTeX == ""
+  ${andif} $State == "0"
+   SetOutPath $TEMP # to be able to delete the $INSTDIR
+   RMDir /r $INSTDIR
+   Abort
+  ${endif}
+ !endif # end if != BUNDLE
+
   # Install and register the core LyX files
   
   # The macros are defined in filelists.nsh
@@ -23,40 +43,56 @@ Section -ProgramFiles SecProgramFiles
   # $PLUGINSDIR is automatically deleted when the installer exits.
   InitPluginsDir
   
-  # Delete stuff from previous version
-  Delete "$INSTDIR\bin\lyxc.exe"
-  
   # Binaries
   SetOutPath "$INSTDIR\bin"
   !insertmacro FileListLyXBin File "${FILES_LYX}\bin\"
-  !insertmacro FileListLyXLauncher File "${FILES_LAUNCHER}\"  
+  # The 2.3.0 and early 2.3.1 installers used a version suffix
+  # We need to remove the old binaries if we're installing into the same directory
+  Delete "$INSTDIR\bin\LyX2.3.exe"
+  Delete "$INSTDIR\bin\tex2lyx2.3.exe"
   !insertmacro FileListQtBin File "${FILES_QT}\bin\"
-  !insertmacro FileListDll File "${FILES_DEPS}\bin\"
-  !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
-  !insertmacro FileListMSVCManifest File "..\"
+  !insertmacro FileListMSVC File "${FILES_MSVC}\"
   !insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
   !insertmacro FileListDTLBin File "${FILES_DTL}\"
+  !insertmacro FileListRsvg File "${FILES_RSVG}\"
   !insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
   !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
-  !insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
-  !insertmacro FileListNSISPluginsStandard File "${NSISDIR}\Plugins\"
-  !insertmacro FileListNSISPlugins File "${FILES_NSISPLUGINS}\"
-  !insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
+  
+  # Qt plugin DLLs
+  SetOutPath "$INSTDIR\bin\imageformats"
+  !insertmacro FileListQtImageformats File "${FILES_QT}\plugins\imageformats\"
+  SetOutPath "$INSTDIR\bin\iconengines"
+  !insertmacro FileListQtIconengines File "${FILES_QT}\plugins\iconengines\"
+  SetOutPath "$INSTDIR\bin\platforms"
+  !insertmacro FileListQtPlatforms File "${FILES_QT}\plugins\platforms\"
   
   # Resources
   SetOutPath "$INSTDIR"
   # recursively copy all files under Resources
   File /r "${FILES_LYX}\Resources"
   
-  # Components of Python
-  SetOutPath "$INSTDIR\python"
-  !insertmacro FileListPythonBin File "${FILES_PYTHON}\"
-  !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
-  !insertmacro FileListMSVCManifest File "..\"  
-  SetOutPath "$INSTDIR\python\Lib"
-  !insertmacro FileListPythonLib File "${FILES_PYTHON}\Lib\"
-  SetOutPath "$INSTDIR\python\Lib\encodings"
-  !insertmacro FileListPythonLibEncodings File "${FILES_PYTHON}\Lib\encodings\"
+  !if ${SETUPTYPE} == BUNDLE
+   
+   # extract the MiKTeX installer
+   File /r "${FILES_LYX}\external"
+
+   # install MiKTeX if not already installed
+   Call InstallMiKTeX # function from LaTeX.nsh
+   
+  !endif # end if BUNDLE
+  
+  # Python
+  SetOutPath "$INSTDIR"
+  # recursively copy all files under Python
+  File /r "${FILES_PYTHON}"
+  # register .py files if necessary
+  ReadRegStr $0 SHCTX "Software\Classes\Python.File\shell\open\command" ""
+  ${if} $0 == "" # if nothing was found
+   WriteRegStr SHCTX "Software\Classes\Python.File\shell\open\command" "" '"$INSTDIR\Python\python.exe" "%1" %*'
+   WriteRegStr SHCTX "Software\Classes\Python.File\DefaultIcon" "" "$INSTDIR\Python\DLLs\py.ico"
+   WriteRegStr SHCTX "Software\Classes\.py" "" "Python.File"
+   WriteRegStr SHCTX "Software\Classes\Python.File" "OnlyWithLyX" "Yes${APP_SERIES_KEY}" # special entry to test if they were registered by this LyX version
+  ${endif}
   
   # Compile all Pyton files to byte-code
   # The user using the scripts may not have write access
@@ -70,287 +106,61 @@ Section -ProgramFiles SecProgramFiles
   Pop $PythonCompileReturn # Return value
   Delete "$INSTDIR\compilepy.py"
   
-  !ifdef BUNDLE_IMAGEMAGICK
   # Components of ImageMagick
   SetOutPath "$INSTDIR\imagemagick"
-  !insertmacro FileListImageMagick File "${FILES_IMAGEMAGICK}\"
-  !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
-  !insertmacro FileListMSVCManifest File "..\"
-  !endif  
+  File /r "${FILES_IMAGEMAGICK}\"
+  !insertmacro FileListMSVC File "${FILES_MSVC}\"
+  # register ImageMagick
+  WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "BinPath" "$INSTDIR\imagemagick"
+  WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
+  WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "ConfigurePath" "$INSTDIR\imagemagick"
+  WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
+  WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "LibPath" "$INSTDIR\imagemagick"
+  WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "BinPath" "$INSTDIR\imagemagick"
+  WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
+  WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "ConfigurePath" "$INSTDIR\imagemagick"
+  WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
+  WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "LibPath" "$INSTDIR\imagemagick"
+  WriteRegDWORD SHCTX "SOFTWARE\ImageMagick\Current" "QuantumDepth" 0x00000010
+  WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "Version" "${ImageMagickVersion}"
+  WriteRegStr SHCTX "SOFTWARE\ImageMagick" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
   
-  !ifdef BUNDLE_GHOSTSCRIPT
   # Components of Ghostscript
-  SetOutPath "$INSTDIR\ghostscript"
-  SetOutPath "$INSTDIR\ghostscript\bin"
-  !insertmacro FileListGhostscriptBin File "${FILES_GHOSTSCRIPT}\bin\"
-  !insertmacro FileListMSVCBin File "${FILES_MSVC}\"
-  !insertmacro FileListMSVCManifest File "..\"  
-  SetOutPath "$INSTDIR\ghostscript\lib"
-  !insertmacro FileListGhostscriptLib File "${FILES_GHOSTSCRIPT}\lib\"
-  SetOutPath "$INSTDIR\ghostscript\fonts"
-  !insertmacro FileListGhostscriptFonts File "${FILES_GHOSTSCRIPT}\fonts\"
-  SetOutPath "$INSTDIR\ghostscript\Resource"
-  SetOutPath "$INSTDIR\ghostscript\Resource\CMap"
-  !insertmacro FileListGhostscriptResourceCMap File "${FILES_GHOSTSCRIPT}\Resource\CMap\"
-  SetOutPath "$INSTDIR\ghostscript\Resource\ColorSpace"
-  !insertmacro FileListGhostscriptResourceColorSpace File "${FILES_GHOSTSCRIPT}\Resource\ColorSpace\"
-  SetOutPath "$INSTDIR\ghostscript\Resource\Decoding"
-  !insertmacro FileListGhostscriptResourceDecoding File "${FILES_GHOSTSCRIPT}\Resource\Decoding\"
-  SetOutPath "$INSTDIR\ghostscript\Resource\Encoding"
-  !insertmacro FileListGhostscriptResourceEncoding File "${FILES_GHOSTSCRIPT}\Resource\Encoding\"
-  
-  !endif  
-  
-  # Aspell
-
-  # Copy installer to pluginsdir (a temp dir)
-  File /oname=$PLUGINSDIR\AspellData.exe "${FILES_ASPELLDATA}\AspellData.exe"
-
-  # Silently install AspellData.exe (/S option)
-  ${If} $MultiUser.InstallMode == "CurrentUser"
-    ExecWait '"$PLUGINSDIR\AspellData.exe" /S /CurrentUser'
-  ${Else}
-    ExecWait '"$PLUGINSDIR\AspellData.exe" /S /AllUsers'
-  ${EndIf}
-
-  # Remove the installer
-  Delete "$PLUGINSDIR\AspellData.exe"
-
-  # Aiksarus data
-  SetOutPath "$INSTDIR\aiksaurus"
-  !insertmacro FileListAiksaurusData File "${FILES_AIKSAURUS}\"
+  ${if} $GhostscriptPath == ""
+   SetOutPath "$INSTDIR\ghostscript"
+   File /r "${FILES_GHOSTSCRIPT}\"
+   !insertmacro FileListMSVC File "${FILES_MSVC}\"
+   StrCpy $GhostscriptPath "$INSTDIR\ghostscript\bin"
+  ${endif}
+  
+  # install eLyXer
+  SetOutPath "$INSTDIR\Python\Lib"
+  !insertmacro FileListeLyXer File "${FILES_ELYXER}\"
+   
+  # install unoconv
+  SetOutPath "$INSTDIR\Python\Lib"
+  !insertmacro FileListUnoConv File "${FILES_UNOCONV}\"
+
+  # install the LaTeX class files that are delivered with LyX to MiKTeX
+  ${if} $LaTeXInstalled == "MiKTeX"
+   Call ConfigureMiKTeX # Function from LaTeX.nsh
+  ${endif}
+  # install the LaTeX class files that are delivered with LyX to TeXLive
+  ${if} $LaTeXInstalled == "TeXLive"
+   Call ConfigureTeXLive # Function from LaTeX.nsh
+  ${endif}
+  
+  # download dictionaries and thesaurus
+  ${if} $DictCodes != ""
+   Call InstallHunspellDictionaries # Function from dictionaries.nsh
+  ${endif}
+  ${if} $ThesCodes != ""
+   Call InstallThesaurusDictionaries # Function from dictionaries.nsh
+  ${endif}
+  # finally delete the list of mirrors
+  Delete "$INSTDIR\Resources\DictionaryMirrors.txt"
   
   # Create uninstaller
   WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
 
 SectionEnd
-
-#--------------------------------
-# Support code for file downloads
-
-!macro DOWNLOAD_FILE RET ID FILENAME APPEND
-
-  # Downloads a file using the Inetc plug-in (HTTP or FTP)
-  
-  # RET = Return value (OK if succesful)
-  # ID = Name of the download in settings.nsh
-  # FILENAME = Location to store file
-  # APPEND = Filename to append to server location in settings.nsh
-
-  # Try first mirror server
-  Inetc::get "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
-  Pop ${RET} # Return value (OK if succesful)
-
-  ${If} ${RET} != "OK"
-    # Download failed, try second mirror server
-    Inetc::get "${DOWNLOADALT_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}" /END
-    Pop ${RET}
-  ${EndIf}
-
-!macroend
-
-#--------------------------------
-# Aspell dictionaries
-
-Var DictionaryFile
-Var DictionaryLangName
-Var DictionaryLangCode
-Var DictionaryPath
-
-Var AspellHive
-Var AspellPath
-
-Var DownloadResult
-
-Section -AspellDicts
-
-  # Check whether the system or local version of Aspell should be used
-  # The patched Aspell uses the same logic
-
-  ReadRegStr $AspellPath HKCU "Software\Aspell" "Base Path"
-
-  ${If} $AspellPath == ""
-    StrCpy $AspellHive HKLM
-  ${Else}
-    StrCpy $AspellHive HKCU
-  ${EndIf}
-
-SectionEnd
-
-!macro SECTION_DICT FILE LANGNAME LANGCODE SIZE
-
-  # One section for each dictionary
-
-  Section /o "${LANGNAME}"
-
-    AddSize ${SIZE}
-
-    StrCpy $DictionaryFile "${FILE}"
-    StrCpy $DictionaryLangName "${LANGNAME}"
-    StrCpy $DictionaryLangCode ${LANGCODE}
-
-    Call DownloadDictionary
-
-  SectionEnd
-
-!macroend
-
-# Include all sections
-!insertmacro Dictionaries '!insertmacro SECTION_DICT'
-
-Function DownloadDictionary
-
-  # Download and install a dictionary
-
-  dict_download:
-  
-    !insertmacro DOWNLOAD_FILE $DownloadResult ASPELLDICTS aspell6-$DictionaryFile.exe /aspell6-$DictionaryFile.exe
-
-    ${If} $DownloadResult != "OK"
-      # Download failed
-      MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_DICT) ($DownloadResult)" IDYES dict_download
-      Goto dict_noinstall
-    ${EndIf}
-
-    install_dict:
-
-      ExecWait '"$PLUGINSDIR\aspell6-$DictionaryFile.exe" /NoDirChange /AutoClose'
-
-      ${If} $AspellHive == HKLM
-        ReadRegStr $DictionaryPath HKLM "Software\Aspell\Dictionaries" $DictionaryLangCode
-      ${Else}
-        ReadRegStr $DictionaryPath HKCU "Software\Aspell\Dictionaries" $DictionaryLangCode
-      ${EndIf}
-
-      ${If} $DictionaryPath == ""
-        MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_NOTINSTALLED_DICT)" IDYES install_dict
-      ${EndIf}
-
-      Delete "$PLUGINSDIR\aspell6-$DictionaryFile.exe"
-
-    dict_noinstall:
-
-FunctionEnd
-
-#--------------------------------
-# Extenral components
-
-Var PathAllUsers
-Var PathCurrentUser
-
-!macro EXTERNAL COMPONENT
-
-  # Download/Install the component
-  
-  ${If} $Setup${COMPONENT} == ${TRUE}
-  
-    StrCpy $Path${COMPONENT} "" ;A new one will be installed
-  
-    !ifndef BUNDLESETUP_${COMPONENT}
-      !insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
-    !else
-      !insertmacro EXTERNAL_INSTALL ${COMPONENT}
-    !endif
-    
-  ${EndIf}
-
-!macroend
-
-!macro EXTERNAL_RUNINSTALLER COMPONENT
-
-  # Run the installer application of the component that does the actual installation.
-
-  install_${COMPONENT}:
-      
-    ExecWait '"$PLUGINSDIR\${COMPONENT}Setup.exe"'
-    
-    # Updates the path environment variable of the instaler process to the latest system value
-    ReadRegStr $PathAllUsers HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
-    ReadRegStr $PathCurrentUser HKCU "Environment" Path
-    System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$PathAllUsers;$PathCurrentUser").'
-
-    Call Search${COMPONENT}
-    
-    ${If} $Path${COMPONENT} == ""  
-      MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
-    ${EndIf}
-      
-    Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
-     
-!macroend
-
-!macro EXTERNAL_DOWNLOAD COMPONENT
-
-  download_${COMPONENT}:
-
-    !insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
-    ${If} $DownloadResult != "OK"
-      # Download failed
-      MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
-      Goto noinstall_${COMPONENT}
-    ${EndIf}
-      
-    !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
-      
-  noinstall_${COMPONENT}:
-
-!macroend
-
-!macro EXTERNAL_INSTALL COMPONENT
-
-  # Extract
-  File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
-    
-  !insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
-    
-!macroend
-
-
-# Sections for external components
-
-Section -LaTeX ExternalLaTeX
-  !insertmacro EXTERNAL LaTeX
-SectionEnd
-
-!ifndef BUNDLE_IMAGEMAGICK
-
-Section -ImageMagick ExternalImageMagick
-  !insertmacro EXTERNAL ImageMagick
-SectionEnd
-
-!endif
-
-!ifndef BUNDLE_GHOSTSCRIPT
-
-Section -Ghostscript ExternalGhostscript
-  !insertmacro EXTERNAL Ghostscript
-SectionEnd
-
-!endif
-
-Function InitExternal
-
-  # Get sizes of external component installers
-  
-  SectionGetSize ${ExternalLaTeX} $SizeLaTeX
-  !ifndef BUNDLE_IMAGEMAGICK
-    SectionGetSize ${ExternalImageMagick} $SizeImageMagick
-  !endif
-  !ifndef BUNDLE_GHOSTSCRIPT
-    SectionGetSize ${ExternalGhostscript} $SizeGhostscript
-  !endif
-  
-  # Add download size
-  
-  !ifndef BUNDLESETUP_MIKTEX
-    IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
-  !endif
-  !ifndef BUNDLE_IMAGEMAGICK & BUNDLESETUP_IMAGEMAGICK
-    IntOp $SizeImagemagick $SizeImagemagick + ${SIZE_DOWNLOAD_IMAGEMAGICK}
-  !endif
-  !ifndef BUNDLE_GHOSTSCRIPT & BUNDLESETUP_GHOSTSCRIPT
-    IntOp $SizeGhostscript $SizeGhostscript + ${SIZE_DOWNLOAD_GHOSTSCRIPT}
-  !endif
-
-FunctionEnd