2008-03-30 21:37:53 +00:00
/*
install.nsh
Installation of program files, dictionaries and external components
*/
#--------------------------------
# Program files
2008-05-01 18:33:36 +00:00
Var PythonCompileFile
Var PythonCompileReturn
2008-03-30 21:37:53 +00:00
Section -ProgramFiles SecProgramFiles
2014-03-09 06:57:47 +00:00
# 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}
2013-02-26 01:25:04 +00:00
!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
2008-03-30 21:37:53 +00:00
# Install and register the core LyX files
2008-05-01 18:33:36 +00:00
# The macros are defined in filelists.nsh
# the parameters are COMMAND DIRECTORY that form command '${COMMAND} "${DIRECTORY}files"
2008-03-30 21:37:53 +00:00
# Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
# $PLUGINSDIR is automatically deleted when the installer exits.
InitPluginsDir
2008-05-01 18:33:36 +00:00
# Binaries
2008-03-30 21:37:53 +00:00
SetOutPath "$INSTDIR\bin"
!insertmacro FileListLyXBin File "${FILES_LYX}\bin\"
!insertmacro FileListQtBin File "${FILES_QT}\bin\"
2012-05-27 00:16:57 +00:00
!insertmacro FileListQtImageformats File "${FILES_QT}\plugins\imageformats\"
2008-05-01 18:33:36 +00:00
!insertmacro FileListDll File "${FILES_DEPS}\bin\"
2011-02-17 17:02:10 +00:00
!insertmacro FileListMSVC File "${FILES_MSVC}\"
2008-03-30 21:37:53 +00:00
!insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
!insertmacro FileListDTLBin File "${FILES_DTL}\"
2015-06-01 22:25:59 +00:00
!insertmacro FileListRsvg File "${FILES_RSVG}\"
2008-03-31 15:31:09 +00:00
!insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
2008-03-30 21:37:53 +00:00
!insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
!insertmacro FileListPDFToolsBin File "${FILES_PDFTOOLS}\"
2008-05-01 18:33:36 +00:00
!insertmacro FileListMetaFile2EPS File "${FILES_METAFILE2EPS}\"
2008-03-30 21:37:53 +00:00
# Resources
SetOutPath "$INSTDIR"
# recursively copy all files under Resources
File /r "${FILES_LYX}\Resources"
2011-12-21 01:12:43 +00:00
!if ${SETUPTYPE} == BUNDLE
# extract the Jabref and MiKTeX installer
File /r "${FILES_LYX}\external"
# install MiKTeX if not already installed
Call InstallMiKTeX # function from LaTeX.nsh
!endif # end if BUNDLE
2011-04-26 21:29:32 +00:00
# Python
SetOutPath "$INSTDIR"
# recursively copy all files under Python
File /r "${FILES_PYTHON}"
2015-08-05 00:29:43 +00:00
# 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}
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
# Compile all Pyton files to byte-code
# The user using the scripts may not have write access
FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
FileWrite $PythonCompileFile "import compileall$\r$\n"
FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
FileClose $PythonCompileFile
DetailPrint $(TEXT_CONFIGURE_PYTHON)
nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
Pop $PythonCompileReturn # Return value
Delete "$INSTDIR\compilepy.py"
# Components of ImageMagick
SetOutPath "$INSTDIR\imagemagick"
2011-05-23 04:12:10 +00:00
File /r "${FILES_IMAGEMAGICK}\"
2011-02-17 17:02:10 +00:00
!insertmacro FileListMSVC File "${FILES_MSVC}\"
2011-07-25 03:09:02 +00:00
# register ImageMagick
WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" "$INSTDIR\imagemagick\convert.exe $$"
WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "BinPath" "$INSTDIR\imagemagick"
WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
2011-12-21 01:12:43 +00:00
WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "ConfigurePath" "$INSTDIR\imagemagick"
2011-07-25 03:09:02 +00:00
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"
2011-12-21 01:12:43 +00:00
WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "ConfigurePath" "$INSTDIR\imagemagick"
2011-07-25 03:09:02 +00:00
WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "LibPath" "$INSTDIR\imagemagick"
2011-09-05 06:09:13 +00:00
WriteRegDWORD SHCTX "SOFTWARE\ImageMagick\Current" "QuantumDepth" 0x00000010
2011-07-25 03:09:02 +00:00
WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "Version" "${ImageMagickVersion}"
2012-11-16 00:21:47 +00:00
WriteRegStr SHCTX "SOFTWARE\ImageMagick" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
2008-05-01 18:33:36 +00:00
# Components of Ghostscript
2011-09-05 06:09:13 +00:00
${if} $GhostscriptPath == ""
SetOutPath "$INSTDIR\ghostscript"
File /r "${FILES_GHOSTSCRIPT}\"
!insertmacro FileListMSVC File "${FILES_MSVC}\"
StrCpy $GhostscriptPath "$INSTDIR\ghostscript\bin"
${endif}
2008-05-01 18:33:36 +00:00
2011-05-23 04:12:10 +00:00
!if ${SETUPTYPE} == BUNDLE
# install JabRef if not already installed and the user selected it
# if no BibTeX editor is installed
${if} $PathBibTeXEditor == ""
2012-11-22 19:17:45 +00:00
${andif} $InstallJabRef == "true"
# launch installer
2014-02-18 01:15:53 +00:00
MessageBox MB_OK|MB_ICONINFORMATION "$(JabRefInfo)" /SD IDOK
IfSilent 0 +2
ExecWait "$INSTDIR\${JabRefInstall} /S"
2012-11-22 19:17:45 +00:00
ExecWait "$INSTDIR\${JabRefInstall}"
# test if JabRef is now installed
StrCpy $PathBibTeXEditor ""
${if} $MultiUser.Privileges == "Admin"
${orif} $MultiUser.Privileges == "Power"
ReadRegStr $PathBibTeXEditor HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"
StrCpy $PathBibTeXEditor $PathBibTeXEditor -14 # remove "\uninstall.exe"
${else}
# for non-admin users we can only check if it is in the start menu
ReadRegStr $PathBibTeXEditor HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "StartMenu"
${endif}
${if} $PathBibTeXEditor == ""
2014-02-18 01:15:53 +00:00
MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)" /SD IDOK
2012-11-22 19:17:45 +00:00
${else}
# special entry that it was installed together with LyX
# so that we can later uninstall it together with LyX
2012-11-12 00:31:00 +00:00
${if} $MultiUser.Privileges == "Admin"
2012-11-22 19:17:45 +00:00
${orif} $MultiUser.Privileges == "Power"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
2012-11-12 00:31:00 +00:00
${else}
2012-11-22 19:17:45 +00:00
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
2012-11-12 00:31:00 +00:00
${endif}
2012-11-22 19:17:45 +00:00
${endif}
${endif} # end if PathBibTeXEditor
2011-08-19 22:19:09 +00:00
!endif # end if BUNDLE
2011-05-23 04:12:10 +00:00
2012-03-07 00:56:12 +00:00
# install eLyXer
2012-03-10 10:46:14 +00:00
SetOutPath "$INSTDIR\Python\Lib"
2012-03-07 00:56:12 +00:00
!insertmacro FileListeLyXer File "${FILES_ELYXER}\"
# install unoconv
2012-03-10 10:46:14 +00:00
SetOutPath "$INSTDIR\Python\Lib"
2012-03-07 00:56:12 +00:00
!insertmacro FileListUnoConv File "${FILES_UNOCONV}\"
2011-05-23 04:12:10 +00:00
2012-11-22 22:35:59 +00:00
# install the LaTeX class files that are delivered with LyX to MiKTeX
2011-05-23 04:12:10 +00:00
# and enable MiKTeX's automatic package installation
${if} $LaTeXInstalled == "MiKTeX"
Call ConfigureMiKTeX # Function from LaTeX.nsh
${endif}
2012-11-22 22:35:59 +00:00
# install the LaTeX class files that are delivered with LyX to TeXLive
${if} $LaTeXInstalled == "TeXLive"
Call ConfigureTeXLive # Function from LaTeX.nsh
${endif}
2011-05-23 04:12:10 +00:00
2012-06-03 15:17:01 +00:00
# download dictionaries and thesaurus
${if} $DictCodes != ""
2012-11-11 17:07:55 +00:00
Call InstallHunspellDictionaries # Function from dictionaries.nsh
2012-06-03 15:17:01 +00:00
${endif}
${if} $ThesCodes != ""
2012-11-11 17:07:55 +00:00
Call InstallThesaurusDictionaries # Function from dictionaries.nsh
2012-06-03 15:17:01 +00:00
${endif}
2012-11-10 06:05:19 +00:00
# finally delete the list of mirrors
2012-06-03 15:17:01 +00:00
Delete "$INSTDIR\Resources\DictionaryMirrors.txt"
2008-03-30 21:37:53 +00:00
# Create uninstaller
WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
SectionEnd
#--------------------------------
# Support code for file downloads
!macro DOWNLOAD_FILE RET ID FILENAME APPEND
2011-02-17 19:14:18 +00:00
# Downloads a file
2008-03-30 21:37:53 +00:00
# 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
2009-08-21 22:20:41 +00:00
# Try first time
2011-02-17 19:14:18 +00:00
NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
2008-03-30 21:37:53 +00:00
Pop ${RET} # Return value (OK if succesful)
2011-11-27 13:53:29 +00:00
${If} ${RET} != "success"
${AndIf} ${RET} != "cancel"
# Download failed, try once again before giving up
# (usally we get a different mirror)
2011-02-17 19:14:18 +00:00
NSISdl::download "${DOWNLOAD_${ID}}${APPEND}" "$PLUGINSDIR\${FILENAME}"
2008-03-30 21:37:53 +00:00
Pop ${RET}
${EndIf}
!macroend
#--------------------------------
2012-07-02 23:42:30 +00:00
# External components
2008-03-30 21:37:53 +00:00
2011-08-19 22:19:09 +00:00
#Var PathAllUsers
#Var PathCurrentUser
2008-03-30 21:37:53 +00:00
!macro EXTERNAL COMPONENT
# Download/Install the component
2008-05-01 18:33:36 +00:00
${If} $Setup${COMPONENT} == ${TRUE}
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
StrCpy $Path${COMPONENT} "" ;A new one will be installed
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
!ifndef BUNDLESETUP_${COMPONENT}
!insertmacro EXTERNAL_DOWNLOAD ${COMPONENT}
2008-03-30 21:37:53 +00:00
!else
2008-05-01 18:33:36 +00:00
!insertmacro EXTERNAL_INSTALL ${COMPONENT}
2008-03-30 21:37:53 +00:00
!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"'
2011-08-19 22:19:09 +00:00
# Updates the path environment variable of the installer 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").'
2008-03-30 21:37:53 +00:00
Call Search${COMPONENT}
${If} $Path${COMPONENT} == ""
MessageBox MB_YESNO|MB_ICONEXCLAMATION $(TEXT_NOTINSTALLED_${COMPONENT}) IDYES install_${COMPONENT}
${EndIf}
Delete "$PLUGINSDIR\${COMPONENT}Setup.exe"
!macroend
2008-05-01 18:33:36 +00:00
!macro EXTERNAL_DOWNLOAD COMPONENT
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
download_${COMPONENT}:
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
!insertmacro DOWNLOAD_FILE $DownloadResult "${COMPONENT}" "${COMPONENT}Setup.exe" ""
2008-03-30 21:37:53 +00:00
2011-11-27 13:53:29 +00:00
${If} $DownloadResult != "success"
${AndIf} $DownloadResult != "cancel"
# Download failed after trying twice - ask user
2008-05-01 18:33:36 +00:00
MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(TEXT_DOWNLOAD_FAILED_${COMPONENT}) ($DownloadResult)" IDYES download_${COMPONENT}
Goto noinstall_${COMPONENT}
${EndIf}
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
!insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
noinstall_${COMPONENT}:
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
!macroend
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
!macro EXTERNAL_INSTALL COMPONENT
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
# Extract
File /oname=$PLUGINSDIR\${COMPONENT}Setup.exe ${FILES_BUNDLE}\${INSTALL_${COMPONENT}}
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
!insertmacro EXTERNAL_RUNINSTALLER ${COMPONENT}
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
!macroend
2008-03-30 21:37:53 +00:00
# Sections for external components
2011-05-23 04:12:10 +00:00
#Section -LaTeX ExternalLaTeX
# !insertmacro EXTERNAL LaTeX
#SectionEnd
2008-03-30 21:37:53 +00:00
2011-05-23 04:12:10 +00:00
/*Function InitExternal
2008-03-30 21:37:53 +00:00
# Get sizes of external component installers
2011-05-23 04:12:10 +00:00
#SectionGetSize ${ExternalLaTeX} $SizeLaTeX
2008-03-30 21:37:53 +00:00
2008-05-01 18:33:36 +00:00
# Add download size
!ifndef BUNDLESETUP_MIKTEX
2008-03-30 21:37:53 +00:00
IntOp $SizeLaTeX $SizeLaTeX + ${SIZE_DOWNLOAD_LATEX}
2008-05-01 18:33:36 +00:00
!endif
2011-05-23 04:12:10 +00:00
FunctionEnd*/