2007-02-08 21:09:30 +00:00
|
|
|
/*
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
init.nsh
|
|
|
|
|
|
|
|
Initialization function
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2007-02-26 16:03:30 +00:00
|
|
|
#--------------------------------
|
2008-03-30 21:37:53 +00:00
|
|
|
# Installer initialization
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-04-05 19:12:37 +00:00
|
|
|
!macro PRINTER_INIT
|
|
|
|
|
|
|
|
${If} ${AtLeastWinVista}
|
|
|
|
StrCpy $PrinterConf "printui.exe"
|
|
|
|
${Else}
|
|
|
|
StrCpy $PrinterConf "rundll32.exe printui.dll,PrintUIEntry"
|
|
|
|
${EndIf}
|
|
|
|
|
|
|
|
!macroend
|
|
|
|
|
2007-02-08 21:09:30 +00:00
|
|
|
Function .onInit
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${IfNot} ${IsNT}
|
2011-03-21 10:22:32 +00:00
|
|
|
${OrIfNot} ${AtLeastWinXP}
|
|
|
|
MessageBox MB_OK|MB_ICONSTOP "${APP_NAME} ${APP_VERSION} requires Windows XP or later."
|
2008-03-30 21:37:53 +00:00
|
|
|
Quit
|
|
|
|
${EndIf}
|
2011-05-23 04:12:10 +00:00
|
|
|
|
|
|
|
# check that the installer is not currently running
|
|
|
|
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${BundleExeFile}.Instance") i .r1 ?e'
|
|
|
|
Pop $R0
|
|
|
|
${if} $R0 != "0"
|
|
|
|
MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
|
|
|
|
Abort
|
|
|
|
${endif}
|
|
|
|
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${ExeFile}.Instance") i .r1 ?e'
|
|
|
|
Pop $R0
|
|
|
|
${if} $R0 != "0"
|
|
|
|
MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
|
|
|
|
Abort
|
|
|
|
${endif}
|
|
|
|
|
|
|
|
# check if LyX is already installed
|
|
|
|
ReadRegStr $0 HKLM "${APP_UNINST_KEY}" "Publisher"
|
|
|
|
${if} $0 != ""
|
|
|
|
MessageBox MB_OK|MB_ICONSTOP "$(StillInstalled)"
|
|
|
|
Abort
|
|
|
|
${endif}
|
2008-03-30 21:37:53 +00:00
|
|
|
|
2008-04-05 19:12:37 +00:00
|
|
|
!insertmacro PRINTER_INIT
|
2008-03-30 21:37:53 +00:00
|
|
|
!insertmacro MULTIUSER_INIT
|
2011-05-23 04:12:10 +00:00
|
|
|
|
|
|
|
# this can be reset to "true" in section SecDesktop
|
|
|
|
StrCpy $CreateDesktopIcon "false"
|
|
|
|
StrCpy $CreateFileAssociations "false"
|
2008-04-11 23:01:05 +00:00
|
|
|
|
2008-04-07 17:26:02 +00:00
|
|
|
${IfNot} ${Silent}
|
2008-05-01 18:33:36 +00:00
|
|
|
|
|
|
|
!ifndef BUNDLE_IMAGEMAGICK & BUNDLE_GHOSTSCRIPT
|
2008-04-11 23:01:05 +00:00
|
|
|
# Warn the user when no Administrator or Power user privileges are available
|
|
|
|
# These privileges are required to install ImageMagick or Ghostscript
|
|
|
|
${If} $MultiUser.Privileges != "Admin"
|
2008-05-01 18:33:36 +00:00
|
|
|
${AndIf} $MultiUser.Privileges != "Power"
|
2008-04-11 23:01:05 +00:00
|
|
|
MessageBox MB_OK|MB_ICONEXCLAMATION $(TEXT_NO_PRIVILEDGES)
|
|
|
|
${EndIf}
|
2008-05-01 18:33:36 +00:00
|
|
|
!endif
|
2008-04-11 23:01:05 +00:00
|
|
|
|
|
|
|
# Show banner while installer is intializating
|
2007-02-08 21:09:30 +00:00
|
|
|
Banner::show /NOUNLOAD "Checking system"
|
2008-03-30 21:37:53 +00:00
|
|
|
${EndIf}
|
2008-04-11 23:01:05 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
Call SearchExternal
|
2011-05-23 04:12:10 +00:00
|
|
|
#Call InitExternal
|
|
|
|
|
2011-06-08 16:41:48 +00:00
|
|
|
!if ${SETUPTYPE} == BUNDLE
|
|
|
|
# don't let the installer sections appear when the programs are already installed
|
|
|
|
${if} $PathBibTeXEditor != ""
|
|
|
|
SectionSetText 3 "" # hides the corresponding uninstaller section, ${SecInstJabRef}
|
|
|
|
${endif}
|
|
|
|
!endif
|
|
|
|
|
2008-04-07 17:26:02 +00:00
|
|
|
${IfNot} ${Silent}
|
2007-02-08 21:09:30 +00:00
|
|
|
Banner::destroy
|
2008-03-30 21:37:53 +00:00
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
FunctionEnd
|
|
|
|
|
2011-05-23 04:12:10 +00:00
|
|
|
# this function is called at first after starting the uninstaller
|
2007-02-08 21:09:30 +00:00
|
|
|
Function un.onInit
|
|
|
|
|
2008-04-05 19:12:37 +00:00
|
|
|
!insertmacro PRINTER_INIT
|
2008-03-30 21:37:53 +00:00
|
|
|
!insertmacro MULTIUSER_UNINIT
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2011-05-23 04:12:10 +00:00
|
|
|
# Check that LyX is not currently running
|
|
|
|
FindProcDLL::FindProc "lyx.exe"
|
|
|
|
${if} $R0 == "1"
|
|
|
|
MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
|
|
|
|
Abort
|
|
|
|
${endif}
|
|
|
|
|
|
|
|
# set registry root key
|
|
|
|
${if} $MultiUser.Privileges == "Admin"
|
|
|
|
${orif} $MultiUser.Privileges == "Power"
|
|
|
|
SetShellVarContext all
|
|
|
|
${else}
|
|
|
|
SetShellVarContext current
|
|
|
|
${endif}
|
|
|
|
|
|
|
|
# Ascertain whether the user has sufficient privileges to uninstall.
|
|
|
|
# abort when LyX was installed with admin permissions but the user doesn't have administrator privileges
|
|
|
|
ReadRegStr $0 HKLM "${APP_UNINST_KEY}" "DisplayVersion"
|
|
|
|
${if} $0 != ""
|
|
|
|
${andif} $MultiUser.Privileges != "Admin"
|
|
|
|
${andif} $MultiUser.Privileges != "Power"
|
|
|
|
MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)"
|
|
|
|
Abort
|
|
|
|
${endif}
|
|
|
|
# abort when LyX couldn't be found in the registry
|
|
|
|
${if} $0 == "" # check in HKCU
|
|
|
|
ReadRegStr $0 HKCU "${APP_UNINST_KEY}" "DisplayVersion"
|
|
|
|
${if} $0 == ""
|
|
|
|
MessageBox MB_OK|MB_ICONEXCLAMATION "$(UnNotInRegistryLabel)"
|
|
|
|
${endif}
|
|
|
|
${endif}
|
|
|
|
|
|
|
|
# Macro to investigate name of LyX's preferences folders to be able remove them
|
|
|
|
!insertmacro UnAppPreSuff $AppPre $AppSuff # macro from LyXUtils.nsh
|
|
|
|
|
|
|
|
# test if MiKTeX was installed together with LyX
|
|
|
|
ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
|
|
|
|
${if} $0 == "Yes${APP_SERIES_KEY}"
|
|
|
|
SectionSetText 2 "MiKTeX" # names the corersponding uninstaller section
|
|
|
|
StrCpy $LaTeXInstalled "MiKTeX"
|
|
|
|
DeleteRegValue HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
|
|
|
|
${else}
|
|
|
|
SectionSetText 2 "" # hides the corresponding uninstaller section
|
|
|
|
${endif}
|
2011-06-08 16:41:48 +00:00
|
|
|
|
2011-05-23 04:12:10 +00:00
|
|
|
# test if JabRef was installed together with LyX
|
|
|
|
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
|
|
|
|
${if} $0 == "Yes${APP_SERIES_KEY}"
|
|
|
|
SectionSetText 3 "JabRef" # names the corersponding uninstaller section
|
|
|
|
StrCpy $JabRefInstalled "Yes"
|
|
|
|
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
|
|
|
|
${else}
|
|
|
|
SectionSetText 3 "" # hides the corresponding uninstaller section
|
|
|
|
${endif}
|
|
|
|
|
|
|
|
# question message if the user really wants to uninstall LyX
|
|
|
|
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2 # continue if yes
|
|
|
|
Abort
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
FunctionEnd
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
#--------------------------------
|
|
|
|
# User initialization
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
Var ComponentPath
|
|
|
|
Var LyXLangName
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2011-05-23 04:12:10 +00:00
|
|
|
# COMPONENT can be LaTeX, ImageMagick and Ghostscript
|
2008-03-30 21:37:53 +00:00
|
|
|
!macro EXTERNAL_INIT COMPONENT
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
# APP_REGKEY_SETUP = "Software\${APP_NAME}${APP_SERIES_KEY}\Setup"
|
|
|
|
# where ${APP_NAME}${APP_SERIES_KEY} is something like LyX16
|
|
|
|
ReadRegStr $ComponentPath SHELL_CONTEXT "${APP_REGKEY_SETUP}" "${COMPONENT} Path"
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
# BIN_LATEX etc are defined in settings.nsh
|
|
|
|
${If} ${FileExists} "$ComponentPath\${BIN_${COMPONENT}}"
|
|
|
|
# set variables like PathLaTeX
|
|
|
|
StrCpy $Path${COMPONENT} $ComponentPath
|
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
!macroend
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
Function InitUser
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
# Get directories of components from registry
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
!insertmacro EXTERNAL_INIT LaTeX
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
# Get LyX language
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
ReadRegStr $LyXLangName SHELL_CONTEXT "${APP_REGKEY_SETUP}" "LyX Language"
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${If} $LyXLangName != ""
|
|
|
|
StrCpy $LangName $LyXLangName
|
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
FunctionEnd
|
2011-05-23 04:12:10 +00:00
|
|
|
|
|
|
|
#--------------------------------
|
|
|
|
# visible installer sections
|
|
|
|
|
|
|
|
Section "!${APP_NAME}" SecCore
|
|
|
|
SectionIn RO
|
|
|
|
SectionEnd
|
|
|
|
Section "$(SecFileAssocTitle)" SecFileAssoc
|
|
|
|
StrCpy $CreateFileAssociations "true"
|
|
|
|
SectionEnd
|
2011-09-05 07:20:53 +00:00
|
|
|
Section "$(SecDesktopTitle)" SecDesktop
|
2011-05-23 04:12:10 +00:00
|
|
|
StrCpy $CreateDesktopIcon "true"
|
|
|
|
SectionEnd
|
|
|
|
|
|
|
|
!if ${SETUPTYPE} == BUNDLE
|
|
|
|
Section /o "$(SecInstJabRefTitle)" SecInstJabRef
|
|
|
|
AddSize 5000
|
|
|
|
StrCpy $InstallJabRef "true"
|
|
|
|
SectionEnd
|
|
|
|
!endif
|
|
|
|
|
|
|
|
# Section descriptions
|
|
|
|
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
|
|
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
|
|
|
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} "$(SecFileAssocDescription)"
|
|
|
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
|
2011-06-08 16:41:48 +00:00
|
|
|
!if ${SETUPTYPE} == BUNDLE
|
|
|
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecInstJabRef} "$(SecInstJabRefDescription)"
|
|
|
|
!endif
|
2011-05-23 04:12:10 +00:00
|
|
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
|
|
|
|