Mercurial > forge
view admin/Windows/msvc/octave_package.nsi.in @ 3665:4e16cc19161b octave-forge
handle dependencies in installers (main and pkg packages)
author | goffioul |
---|---|
date | Wed, 18 Jul 2007 12:40:45 +0000 |
parents | 41f860e3d879 |
children | 7edd4e6b07b9 |
line wrap: on
line source
; Script generated by the HM NIS Edit Script Wizard. !define PACKAGE_NAME "@PACKAGE_NAME@" !define PACKAGE_LONG_NAME "@PACKAGE_LONG_NAME@" !define PACKAGE_VERSION "@PACKAGE_VERSION@" !define PACKAGE_INFO "@PACKAGE_INFO@" !define OCTAVE_VERSION "@OCTAVE_VERSION@" !define VCLIBS_ROOT "@VCLIBS_ROOT@" !define SOFTWARE_ROOT "@SOFTWARE_ROOT@" !define OCTAVE_BASE "octave-${OCTAVE_VERSION}" !define OCTAVE_ROOT "${VCLIBS_ROOT}\local\${OCTAVE_BASE}" ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "${PACKAGE_LONG_NAME}" !define PRODUCT_VERSION "${PACKAGE_VERSION}" !define PRODUCT_PUBLISHER "" !define PRODUCT_WEB_SITE "http://octave.sourceforge.net" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\octave-${OCTAVE_VERSION}.exe" !define PRODUCT_ROOT_KEY "HKLM" ; MUI 1.67 compatible ------ !include "MUI.nsh" !include "Sections.nsh" !include "WordFunc.nsh" !insertmacro WordReplace !insertmacro WordFind ; MUI Settings !define MUI_ABORTWARNING !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" ; Welcome page !insertmacro MUI_PAGE_WELCOME ; License page !define MUI_LICENSEPAGE_TEXT_BOTTOM "Click Next to continue." !define MUI_LICENSEPAGE_BUTTON "Next >" !insertmacro MUI_PAGE_LICENSE "${VCLIBS_ROOT}\license\COPYING.GPL" !insertmacro MUI_PAGE_COMPONENTS ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; Finish page !define MUI_FINISHPAGE_TEXT "$(MUI_TEXT_FINISH_INFO_TEXT)\r\n\r\nThis package does not provide an uninstaller. To uninstall ${PRODUCT_NAME}-${PRODUCT_VERSION}, use the regular Octave package manager with the 'uninstall' command (see 'help pkg' for more information). It will also be removed if you uninstall Octave." !insertmacro MUI_PAGE_FINISH ; Language files !insertmacro MUI_LANGUAGE "English" ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "octave-${PACKAGE_NAME}-${PACKAGE_VERSION}-setup.exe" InstallDir "$PROGRAMFILES\Octave" #InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" ShowInstDetails show ShowUnInstDetails show XPStyle on Var IS_WIN2K Var OCTAVE_EXEC Section "${PACKAGE_LONG_NAME}" SEC_@PACKAGE_NAME@ SetOverwrite try @PACKAGE_FILES@ SetOutPath "$INSTDIR\${PACKAGE_NAME}-${PACKAGE_VERSION}" File /r "${OCTAVE_ROOT}\share\octave\packages\${PACKAGE_NAME}-${PACKAGE_VERSION}\*" ExecWait '"$OCTAVE_EXEC" -qf --eval "pkg rebuild ${PACKAGE_NAME}"' SectionEnd ; Section descriptions !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SEC_@PACKAGE_NAME@} "${PACKAGE_INFO}" !insertmacro MUI_FUNCTION_DESCRIPTION_END !macro MissingComponent compname MessageBox MB_ICONSTOP|MB_OK "${PRODUCT_NAME}-${PRODUCT_VERSION} cannot be installed on this computer, because some required components$\r$\nare not present. Install the missing components and run this installer again.$\r$\n$\r$\nMissing components: ${compname}" !macroend !macro CheckDependency packname packver op Push "${packname}" Push "${packver}" Push "${op}" Call CheckDependency Exch $0 StrCmp $0 "0" 0 +6 StrCmp ${packver} "" 0 +3 !insertmacro MissingComponent "${packname}" Goto +2 !insertmacro MissingComponent "${packname} (${op} ${packver})" Abort Pop $0 !macroend Function .onInit ReadRegStr $INSTDIR ${PRODUCT_ROOT_KEY} "${PRODUCT_DIR_REGKEY}" Packages StrCmp $INSTDIR "" 0 octave_present !insertmacro MissingComponent "Octave ${OCTAVE_VERSION}" Abort octave_present: ReadRegStr $OCTAVE_EXEC ${PRODUCT_ROOT_KEY} "${PRODUCT_DIR_REGKEY}" "" Call DetectWinVer Call DetectAdmin Pop $0 StrCmp $0 1 0 endadmin SetShellVarContext all endadmin: @PACKAGE_DEPENDENCY@ IfFileExists "$INSTDIR\${PACKAGE_NAME}-*" 0 endinit MessageBox MB_YESNOCANCEL|MB_ICONQUESTION "${PRODUCT_NAME} is already installed on this computer. The existing version must be uninstalled$\r$\nbefore running this installer. Do you want to remove the existing version?" IDYES +2 IDNO endinit Abort ExecWait '"$OCTAVE_EXEC" -qf --eval "pkg uninstall ${PACKAGE_NAME}"' endinit: FunctionEnd Function DetectAdmin Push $0 Push $1 ClearErrors UserInfo::GetName IfErrors win9x Pop $0 UserInfo::GetAccountType Pop $1 StrCmp $1 "Admin" win9x 0 StrCpy $0 0 Goto done win9x: StrCpy $0 1 done: Pop $1 Exch $0 FunctionEnd Function ReplaceOctDir Push $0 Push $1 Push $2 Push $3 ClearErrors FileOpen $2 $0 r IfErrors done FileOpen $3 $1 w IfErrors close doit: FileRead $2 $0 StrCmp $0 "" close1 0 ${WordReplace} $0 "@OCTAVE_DIR@" "$INSTDIR" "+" $1 FileWrite $3 $1 Goto doit close1: FileClose $3 close: FileClose $2 done: Pop $3 Pop $2 Pop $1 Pop $0 FunctionEnd Function DetectJVM Push $0 ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" CurrentVersion Exch $0 FunctionEnd Function DetectWinVer Push $0 Push $1 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion IfErrors is_error is_winnt is_winnt: StrCpy $1 $0 1 StrCmp $1 6 is_winxp StrCmp $1 5 0 is_error StrCmp $0 "5.0" is_win2k StrCmp $0 "5.1" is_winxp StrCmp $0 "5.2" is_winxp64 Goto is_error is_win2k: StrCpy $IS_WIN2K 1 Goto done is_winxp64: is_winxp: StrCpy $IS_WIN2K 0 Goto done is_error: StrCpy $1 $0 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" ProductName IfErrors 0 +4 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" Version IfErrors 0 +2 StrCpy $0 "Unknown" MessageBox MB_ICONSTOP|MB_OK "This version of Octave cannot be installed on this system.$\r$\nSupported systems are Windows 2000 and Windows XP.$\r$\n$\r$\nCurrent system: $0 (version: $1)" Abort done: Pop $1 Pop $0 FunctionEnd Function CompareVersion Exch $1 Exch Exch $0 Push $2 Push $3 ${WordFind} "$0" "." "+1" $2 ${WordFind} "$1" "." "+1" $3 IntCmp $2 $3 0 result_1 result1 ${WordFind} "$0" "." "+2" $2 ${WordFind} "$1" "." "+2" $3 IntCmp $2 $3 0 result_1 result1 ${WordFind} "$0" "." "+3" $2 ${WordFind} "$1" "." "+3" $3 IntCmp $2 $3 result0 result_1 result1 result_1: StrCpy $1 -1 Goto compare_end result0: StrCpy $1 0 Goto compare_end result1: StrCpy $1 1 compare_end: Pop $3 Pop $2 Pop $0 Exch $1 FunctionEnd Function CheckDependency Exch $R0 Exch Exch $1 Exch Exch 2 Exch $0 Push $2 Push $3 FindFirst $2 $3 "$INSTDIR\$0-*" StrCmp $3 "" dep_not_ok StrCmp $1 "" dep_ok ${WordFind} "$3" "-" "-1" $3 Push $3 Push $1 Call CompareVersion Pop $3 StrCmp $R0 "<" cmp_lt StrCmp $R0 "<=" cmp_le StrCmp $R0 ">" cmp_gt StrCmp $R0 ">=" cmp_ge StrCmp $R0 "==" cmp_eq Goto dep_not_ok cmp_lt: IntCmp $3 0 dep_not_ok dep_ok dep_not_ok cmp_le: IntCmp $3 0 dep_ok dep_ok dep_not_ok cmp_gt: IntCmp $3 0 dep_not_ok dep_not_ok dep_ok cmp_ge: IntCmp $3 0 dep_ok dep_not_ok dep_ok cmp_eq: IntCmp $3 0 dep_ok dep_not_ok dep_not_ok dep_not_ok: StrCpy $1 0 Goto done dep_ok: StrCpy $1 1 done: FindClose $2 Pop $3 Pop $2 Pop $0 Exch $1 Exch Pop $R0 FunctionEnd