--- joko/ToolBox/Windows/w2hfax-installer/w2hfax.nsi 2005/03/17 15:10:11 1.1 +++ joko/ToolBox/Windows/w2hfax-installer/w2hfax.nsi 2005/03/24 15:47:18 1.4 @@ -13,10 +13,10 @@ Name "w2hfax" ; The file to write -OutFile "w2hfax.exe" +OutFile "w2hfax_setup.exe" ; The default installation directory -InstallDir $PROGRAMFILES\w2hfax-test +InstallDir $PROGRAMFILES\w2hfax ; Registry key to check for directory (so if you install again, it will ; overwrite the old one automatically) @@ -24,6 +24,9 @@ Var redmonInstDir + + + ; -------------------------------- ; Pages ; -------------------------------- @@ -35,13 +38,43 @@ UninstPage uninstConfirm UninstPage instfiles +Var python_path +Var python_version +Var python_url +Var python_msi + +Var ghostscript_version +Var ghostscript_version_required +Var ghostview_version +Var ghostview_exe + ; -------------------------------- ; The stuff to install ; -------------------------------- -;Section "w2hfax (required)" -Section "w2hfax" +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 "AFPL Ghostscript 8.50" IDX_GHOSTSCRIPT + Call install_ghostscript + Call check_ghostscript +SectionEnd + +Section "GSview 4.6" IDX_GHOSTVIEW + Call install_ghostview + Call check_ghostview +SectionEnd + + +Section "w2hfax" IDX_W2HFAX SetDetailsPrint both DetailPrint "Installing w2hfax..." @@ -55,7 +88,7 @@ File "C:\tmp\w2hfax-make\w2hfax\*.*" ; Write the installation path into the registry - WriteRegStr HKLM SOFTWARE\NSIS_w2hfax "Install_Dir" "$INSTDIR" + WriteRegStr HKLM Software\NSIS_w2hfax "Install_Dir" "$INSTDIR" ; Write the uninstall keys for Windows WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\w2hfax" "DisplayName" "w2hfax" @@ -67,14 +100,14 @@ DetailPrint "Registering w2hfax COM-Server..." ; register "w2hfax COM-Server" (a python class) using the PyWin library - ;nsExec::Exec "$INSTDIR\hfaxcom.py" - ; TODO: Use $pythonInstDir here! - nsExec::Exec "python $INSTDIR\hfaxcom.py" + nsExec::Exec "$python_path\python $INSTDIR\hfaxcom.py" + + Call w2hfax_configure SectionEnd -Section "RedMon Port Redirection Monitor" +Section "RedMon Port Redirection Monitor" IDX_REDMON SetDetailsPrint both DetailPrint "Installing RedMon Port Redirection Monitor..." @@ -88,6 +121,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 +138,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 +157,12 @@ SectionEnd + ; -------------------------------- ; Uninstaller ; -------------------------------- -Section "Uninstall" +Section "Uninstall" IDX_UNINSTALL ; ------------------ ; uninstall redmon @@ -168,3 +204,372 @@ 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 $EXEDIR\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" + + StrCpy $R2 "" + 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 $EXEDIR\$R0 + StrCpy $R2 "$INSTDIR\$R0" + + run_setup: + IfFileExists $R2 0 +10 + SetDetailsPrint textonly + DetailPrint "Installing 'Python for Win32 Extensions'..." + SetDetailsPrint listonly + ExecWait '"$R2"' + +FunctionEnd + + +Function check_ghostscript + + SetDetailsPrint both + DetailPrint "Checking for Ghostscript installation..." + + ClearErrors + StrCpy $ghostscript_version_required 8.50 + + StrCpy $0 0 + loop: + EnumRegKey $1 HKLM "SOFTWARE\AFPL Ghostscript" $0 + StrCmp $1 "" done + IntOp $0 $0 + 1 + ; MessageBox MB_YESNO|MB_ICONQUESTION "$1$\n$\nMore?" IDYES loop + done: + StrCpy $ghostscript_version $1 + + ReadRegStr $R0 HKLM "Software\AFPL Ghostscript\$ghostscript_version" "GS_DLL" + IfFileExists "$R0" 0 no_ghostscript + + StrCpy $R0 $ghostscript_version + StrCpy $R1 $ghostscript_version_required + Math::Script "R2 = #[R0 >= R1, 1, 0]" + StrCmp $R2 "1" 0 no_ghostscript + Return + + no_ghostscript: + SetErrors + +FunctionEnd + + +Function install_ghostscript + + ; installer exe + StrCpy $R0 "gs850w32.exe" + + ; download base + StrCpy $R1 "ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs850/$R0" + + ; package title + StrCpy $R9 "AFPL Ghostscript 8.50" + + StrCpy $R2 "" + IfFileExists "$EXEDIR\$R0" 0 +2 + StrCpy $R2 "$EXEDIR\R0" + IfFileExists "$INSTDIR\$R0" 0 +2 + StrCpy $R2 "$INSTDIR\$R0" + + StrCmp $R2 "" 0 run_setup + + SetDetailsPrint textonly + DetailPrint "Downloading '$R9'" + SetDetailsPrint listonly + + MessageBox MB_YESNO "Download '$R9' from $R1?" IDYES NoCancelAbort + ;Abort ; causes uninstaller to not quit. + Return + + NoCancelAbort: + NSISdl::download $R1 $EXEDIR\$R0 + StrCpy $R2 "$INSTDIR\$R0" + + run_setup: + IfFileExists $R2 0 +10 + SetDetailsPrint textonly + DetailPrint "Installing '$R9'..." + SetDetailsPrint listonly + ExecWait '"$R2"' + +FunctionEnd + + +Function check_ghostview + + SetDetailsPrint both + DetailPrint "Checking for GSview installation..." + + ReadRegStr $R0 HKLM Software\Ghostgum\GSview "4.3" + IfFileExists "$R0\gsview\gsview32.exe" 0 +3 + StrCpy $ghostview_version "4.3" + Goto ok_ghostview + + ReadRegStr $R0 HKLM Software\Ghostgum\GSview "4.6" + IfFileExists "$R0\gsview\gsview32.exe" 0 no_ghostview + StrCpy $ghostview_version "4.6" + Goto ok_ghostview + + ok_ghostview: + StrCpy $ghostview_exe "$R0\gsview\gsview32.exe" + ClearErrors + Return + + no_ghostview: + SetErrors + +FunctionEnd + + +Function install_ghostview + + ClearErrors + + ; installer exe + StrCpy $R0 "gsv46w32.exe" + + ; download base + StrCpy $R1 "ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/ghostgum/$R0" + + ; package title + StrCpy $R9 "GSview 4.6" + + StrCpy $R2 "" + IfFileExists "$EXEDIR\$R0" 0 +2 + StrCpy $R2 "$EXEDIR\R0" + IfFileExists "$INSTDIR\$R0" 0 +2 + StrCpy $R2 "$INSTDIR\$R0" + + StrCmp $R2 "" 0 run_setup + + SetDetailsPrint textonly + DetailPrint "Downloading '$R9'" + SetDetailsPrint listonly + + MessageBox MB_YESNO "Download '$R9' from $R1?" IDYES NoCancelAbort + ;Abort ; causes uninstaller to not quit. + Return + + NoCancelAbort: + NSISdl::download $R1 $EXEDIR\$R0 + StrCpy $R2 "$INSTDIR\$R0" + + run_setup: + IfFileExists $R2 0 +10 + SetDetailsPrint textonly + DetailPrint "Installing '$R9'..." + SetDetailsPrint listonly + ExecWait '"$R2"' + +FunctionEnd + + +; -------------------------------- +; Startup +; -------------------------------- +Function .onInit + + Call check_python + IfErrors 0 python_found + SectionSetFlags ${IDX_PYTHON} 1 + ;Return + Goto pythonwin + + python_found: + SectionSetFlags ${IDX_PYTHON} 0 + SectionSetText ${IDX_PYTHON} "Python (found version $python_version)" + ;Return + + + pythonwin: + Call check_pythonwin + IfErrors 0 pythonwin_found + SectionSetFlags ${IDX_PYTHONWIN} 1 + ;Return + Goto ghostscript + + pythonwin_found: + SectionSetFlags ${IDX_PYTHONWIN} 0 + SectionSetText ${IDX_PYTHONWIN} "Python for Win32 Extensions (found)" + ;Return + + + ghostscript: + Call check_ghostscript + IfErrors 0 ghostscript_found + SectionSetFlags ${IDX_GHOSTSCRIPT} 1 + StrCmp $ghostscript_version "" 0 +1 + SectionSetText ${IDX_GHOSTSCRIPT} "AFPL Ghostscript 8.50 (not found)" + SectionSetText ${IDX_GHOSTSCRIPT} "AFPL Ghostscript 8.50 (found $ghostscript_version < $ghostscript_version_required)" + ;Return + Goto ghostview + + ghostscript_found: + SectionSetFlags ${IDX_GHOSTSCRIPT} 0 + SectionSetText ${IDX_GHOSTSCRIPT} "AFPL Ghostscript 8.50 (found $ghostscript_version)" + + + ghostview: + Call check_ghostview + IfErrors 0 ghostview_found + SectionSetFlags ${IDX_GHOSTVIEW} 1 + Return + + ghostview_found: + SectionSetFlags ${IDX_GHOSTVIEW} 0 + SectionSetText ${IDX_GHOSTVIEW} "GSview 4.6 (found $ghostview_version)" + +FunctionEnd + + +Function w2hfax_configure + ; (pre-)configure w2hfax here! + ; e.g. set tiff-viewer dependent of operating system: use shimgvw.dll for WinXP, use Kodak Imaging for Win2000 or others + + ; set PostScript viewer + WriteRegStr HKCU Software\GNU\w2hfax "psviewer" "$ghostview_exe" + + ; set TIFF viewer + StrCpy $R1 "" + + ; if os == xp + StrCpy $R2 "" + ReadRegStr $R2 HKLM "Software\Microsoft\Windows NT\CurrentVersion" "ProductName" + StrCmp $R2 "Microsoft Windows XP" 0 noWinXP + StrCpy $R1 "rundll32.exe shimgvw.dll,ImageView_Fullscreen" + Goto ok_tiffviewer + + noWinXP: + IfFileExists "$PROGRAMFILES\Windows NT\Zubehör\ImageVue\kodakimg.exe" 0 +2 + StrCpy $R1 "$PROGRAMFILES\Windows NT\Zubehör\ImageVue\kodakimg.exe" + IfFileExists "$PROGRAMFILES\Windows NT\Accessories\ImageVue\wangimg.exe" 0 +2 + StrCpy $R1 "$PROGRAMFILES\Windows NT\Accessories\ImageVue\wangimg.exe" + + ok_tiffviewer: + StrCmp $R1 "" no_tiffviewer + ;MessageBox MB_OK $R1 + WriteRegStr HKCU Software\GNU\w2hfax "tifviewer" "$R1" + Return + + no_tiffviewer: + Return + +FunctionEnd