--- joko/ToolBox/Windows/w2hfax-installer/w2hfax.nsi 2005/03/17 15:10:11 1.1 +++ joko/ToolBox/Windows/w2hfax-installer/w2hfax.nsi 2005/03/23 01:56:03 1.2 @@ -13,7 +13,7 @@ Name "w2hfax" ; The file to write -OutFile "w2hfax.exe" +OutFile "w2hfax_setup.exe" ; The default installation directory InstallDir $PROGRAMFILES\w2hfax-test @@ -24,6 +24,9 @@ Var redmonInstDir + + + ; -------------------------------- ; Pages ; -------------------------------- @@ -36,12 +39,30 @@ UninstPage instfiles + ; -------------------------------- ; The stuff to install ; -------------------------------- -;Section "w2hfax (required)" -Section "w2hfax" + +Var python_path +Var python_version +Var python_url +Var python_msi + + +Section "Python" IDX_PYTHON + Call install_python + Call check_python +SectionEnd + +Section "Python for Win32 Extensions" IDX_PYTHONWIN + Call install_pythonwin + Call check_pythonwin +SectionEnd + + +Section "w2hfax" IDX_W2HFAX SetDetailsPrint both DetailPrint "Installing w2hfax..." @@ -70,11 +91,13 @@ ;nsExec::Exec "$INSTDIR\hfaxcom.py" ; TODO: Use $pythonInstDir here! nsExec::Exec "python $INSTDIR\hfaxcom.py" + + ; TODO: (pre-)configure w2hfax here! SectionEnd -Section "RedMon Port Redirection Monitor" +Section "RedMon Port Redirection Monitor" IDX_REDMON SetDetailsPrint both DetailPrint "Installing RedMon Port Redirection Monitor..." @@ -88,6 +111,7 @@ ; Put file there File "C:\tmp\w2hfax-make\redmon17de\*.*" + ; TODO: integrate into here to use current $INSTDIR File "redmon_configure.reg" ; Write the installation path into the registry @@ -104,13 +128,14 @@ nsExec::Exec "$redmonInstDir\setup.exe" DetailPrint "Configuring RedMon Port Redirection Monitor..." + ; TODO: integrate into here to use current $INSTDIR nsExec::Exec "$redmonInstDir\redmon_configure.reg" SectionEnd ; Optional section (can be disabled by the user) -Section "Start Menu Shortcuts" +Section "Start Menu Shortcuts" IDX_STARTMENU SetDetailsPrint both DetailPrint "Installing Start Menu and Desktop Shortcuts..." @@ -122,11 +147,12 @@ SectionEnd + ; -------------------------------- ; Uninstaller ; -------------------------------- -Section "Uninstall" +Section "Uninstall" IDX_UNINSTALL ; ------------------ ; uninstall redmon @@ -168,3 +194,165 @@ RMDir "$INSTDIR" SectionEnd + + +; -------------------------------- +; Functions +; -------------------------------- + +Function check_python + + SetDetailsPrint both + DetailPrint "Checking for Python installation..." + + ClearErrors + + ReadRegStr $python_path HKLM Software\Python\PythonCore\2.4\InstallPath "" + IfErrors +3 + StrCpy $python_version "2.4" + Goto found_python + + ReadRegStr $python_path HKLM Software\Python\PythonCore\2.3\InstallPath "" + IfErrors +3 + StrCpy $python_version "2.3" + Goto found_python + + ReadRegStr $python_path HKLM Software\Python\PythonCore\2.2\InstallPath "" + IfErrors +3 + StrCpy $python_version "2.2" + Goto found_python + + Goto no_python + + found_python: + ; check if python.exe is really present + ClearErrors + IfFileExists $python_path\python.exe 0 +2 + DetailPrint "Found Python $python_version at: $python_path." + Return + + no_python: + ; error: no python + ;MessageBox MB_OK "No Python installation found (checked HKLM\Software\Python\PythonCore\2.3 and HKLM\Software\Python\PythonCore\2.2)." + ;Call install_python + SetErrors + +FunctionEnd + + + +Function install_python + + IfFileExists "$EXEDIR\python-2.4.msi" 0 +2 + StrCpy $python_msi "$EXEDIR\python-2.4.msi" + IfFileExists "$INSTDIR\python-2.4.msi" 0 +2 + StrCpy $python_msi "$INSTDIR\python-2.4.msi" + + ;MessageBox MB_OK $python_msi + StrCmp $python_msi "" 0 run_setup + + SetDetailsPrint textonly + DetailPrint "Downloading Python 2.3" + SetDetailsPrint listonly + + StrCpy $python_url "http://www.python.org/ftp/python/2.4/python-2.4.msi" + MessageBox MB_YESNO "Download Python 2.3 from $python_url?" IDYES NoCancelAbort + ;Abort ; causes uninstaller to not quit. + Return + + NoCancelAbort: + NSISdl::download $python_url $INSTDIR\python-2.4.msi + + run_setup: + IfFileExists $python_msi 0 +10 + SetDetailsPrint textonly + DetailPrint "Installing Python..." + SetDetailsPrint listonly + ExecWait 'msiexec /i "$python_msi"' + +FunctionEnd + + +Function check_pythonwin + + SetDetailsPrint both + DetailPrint "Checking for installation of 'Python for Win32 Extensions'..." + IfFileExists "$python_path\Lib\site-packages\win32com\server\register.py" 0 no_pythonwin + Return + + no_pythonwin: + SetErrors + +FunctionEnd + + +Function install_pythonwin + + ; installer exe + StrCmp $python_version "2.2" 0 +2 + StrCpy $R0 "pywin32-203.win32-py2.2.exe" + StrCmp $python_version "2.3" 0 +2 + StrCpy $R0 "pywin32-203.win32-py2.3.exe" + StrCmp $python_version "2.4" 0 +2 + StrCpy $R0 "pywin32-203.win32-py2.4.exe" + + ; download base + StrCpy $R1 "http://mesh.dl.sourceforge.net/sourceforge/pywin32/$R0" + + IfFileExists "$EXEDIR\$R0" 0 +2 + StrCpy $R2 "$EXEDIR\R0" + IfFileExists "$INSTDIR\$R0" 0 +2 + StrCpy $R2 "$INSTDIR\$R0" + + ;MessageBox MB_OK $R2 + StrCmp $R2 "" 0 run_setup + + SetDetailsPrint textonly + DetailPrint "Downloading 'Python for Win32 Extensions'" + SetDetailsPrint listonly + + MessageBox MB_YESNO "Download 'Python for Win32 Extensions' from $R1?" IDYES NoCancelAbort + ;Abort ; causes uninstaller to not quit. + Return + + NoCancelAbort: + NSISdl::download $R1 $INSTDIR\$R0 + StrCpy $R2 "$INSTDIR\$R0" + + run_setup: + IfFileExists $R2 0 +10 + SetDetailsPrint textonly + DetailPrint "Installing 'Python for Win32 Extensions'..." + SetDetailsPrint listonly + ExecWait '"$R2"' + +FunctionEnd + + +; -------------------------------- +; Startup +; -------------------------------- +Function .onInit + + Call check_python + IfErrors 0 python_found + SectionSetFlags ${IDX_PYTHON} 1 + Return + + python_found: + SectionSetFlags ${IDX_PYTHON} 0 + SectionSetText ${IDX_PYTHON} "Python (found version $python_version)" + ;Return + + + Call check_pythonwin + IfErrors 0 pythonwin_found + SectionSetFlags ${IDX_PYTHONWIN} 1 + Return + + pythonwin_found: + SectionSetFlags ${IDX_PYTHONWIN} 0 + SectionSetText ${IDX_PYTHONWIN} "Python for Win32 Extensions (found)" + ;Return + +FunctionEnd