--- joko/ToolBox/Windows/w2hfax-installer/w2hfax.nsi 2005/03/23 01:56:03 1.2 +++ joko/ToolBox/Windows/w2hfax-installer/w2hfax.nsi 2005/03/23 11:30:19 1.3 @@ -38,18 +38,20 @@ UninstPage uninstConfirm UninstPage instfiles - - -; -------------------------------- -; The stuff to install -; -------------------------------- - - 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 "Python" IDX_PYTHON Call install_python @@ -61,6 +63,16 @@ 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 @@ -76,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" @@ -88,11 +100,9 @@ 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" - ; TODO: (pre-)configure w2hfax here! + Call w2hfax_configure SectionEnd @@ -225,17 +235,17 @@ 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 + ; 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 + ; 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 @@ -299,6 +309,7 @@ ; 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 @@ -329,6 +340,148 @@ 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 $INSTDIR\$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 $INSTDIR\$R0 + StrCpy $R2 "$INSTDIR\$R0" + + run_setup: + IfFileExists $R2 0 +10 + SetDetailsPrint textonly + DetailPrint "Installing '$R9'..." + SetDetailsPrint listonly + ExecWait '"$R2"' + +FunctionEnd + + ; -------------------------------- ; Startup ; -------------------------------- @@ -337,7 +490,8 @@ Call check_python IfErrors 0 python_found SectionSetFlags ${IDX_PYTHON} 1 - Return + ;Return + Goto pythonwin python_found: SectionSetFlags ${IDX_PYTHON} 0 @@ -345,14 +499,77 @@ ;Return + pythonwin: Call check_pythonwin IfErrors 0 pythonwin_found SectionSetFlags ${IDX_PYTHONWIN} 1 - Return + ;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