/[cvs]/joko/ToolBox/Windows/w2hfax-installer/w2hfax.nsi
ViewVC logotype

Annotation of /joko/ToolBox/Windows/w2hfax-installer/w2hfax.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Wed Mar 23 11:30:19 2005 UTC (19 years, 3 months ago) by joko
Branch: MAIN
Changes since 1.2: +240 -23 lines
+ Added support for downloading and setting up "Ghostscript" and "GSview"
+ Preconfiguration of w2hfax

1 joko 1.1 ; w2hfax.nsi
2     ;
3     ; This script can install w2hfax and required packages:
4     ; Python 2.4, PythonWin, Redmon, Ghostscript and Ghostview
5     ; has uninstall support and (optionally) installs start menu shortcuts.
6     ;
7    
8    
9    
10     ; --------------------------------
11     ; The name of the installer
12     ; --------------------------------
13     Name "w2hfax"
14    
15     ; The file to write
16 joko 1.2 OutFile "w2hfax_setup.exe"
17 joko 1.1
18     ; The default installation directory
19     InstallDir $PROGRAMFILES\w2hfax-test
20    
21     ; Registry key to check for directory (so if you install again, it will
22     ; overwrite the old one automatically)
23     InstallDirRegKey HKLM "Software\NSIS_w2hfax" "Install_Dir"
24    
25     Var redmonInstDir
26    
27 joko 1.2
28    
29    
30 joko 1.1 ; --------------------------------
31     ; Pages
32     ; --------------------------------
33    
34     Page components
35     Page directory
36     Page instfiles
37    
38     UninstPage uninstConfirm
39     UninstPage instfiles
40    
41 joko 1.3 Var python_path
42     Var python_version
43     Var python_url
44     Var python_msi
45    
46     Var ghostscript_version
47     Var ghostscript_version_required
48     Var ghostview_version
49     Var ghostview_exe
50 joko 1.1
51 joko 1.2
52 joko 1.1 ; --------------------------------
53     ; The stuff to install
54     ; --------------------------------
55    
56 joko 1.2 Section "Python" IDX_PYTHON
57     Call install_python
58     Call check_python
59     SectionEnd
60    
61     Section "Python for Win32 Extensions" IDX_PYTHONWIN
62     Call install_pythonwin
63     Call check_pythonwin
64     SectionEnd
65    
66 joko 1.3 Section "AFPL Ghostscript 8.50" IDX_GHOSTSCRIPT
67     Call install_ghostscript
68     Call check_ghostscript
69     SectionEnd
70    
71     Section "GSview 4.6" IDX_GHOSTVIEW
72     Call install_ghostview
73     Call check_ghostview
74     SectionEnd
75    
76 joko 1.2
77     Section "w2hfax" IDX_W2HFAX
78 joko 1.1
79     SetDetailsPrint both
80     DetailPrint "Installing w2hfax..."
81    
82     ;SectionIn RO
83    
84     ; Set output path to the installation directory.
85     SetOutPath $INSTDIR
86    
87     ; Put file there
88     File "C:\tmp\w2hfax-make\w2hfax\*.*"
89    
90     ; Write the installation path into the registry
91 joko 1.3 WriteRegStr HKLM Software\NSIS_w2hfax "Install_Dir" "$INSTDIR"
92 joko 1.1
93     ; Write the uninstall keys for Windows
94     WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\w2hfax" "DisplayName" "w2hfax"
95     WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\w2hfax" "UninstallString" '"$INSTDIR\uninstall.exe"'
96     WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\w2hfax" "NoModify" 1
97     WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\w2hfax" "NoRepair" 1
98     WriteUninstaller "uninstall.exe"
99    
100     DetailPrint "Registering w2hfax COM-Server..."
101    
102     ; register "w2hfax COM-Server" (a python class) using the PyWin library
103 joko 1.3 nsExec::Exec "$python_path\python $INSTDIR\hfaxcom.py"
104 joko 1.2
105 joko 1.3 Call w2hfax_configure
106 joko 1.1
107     SectionEnd
108    
109    
110 joko 1.2 Section "RedMon Port Redirection Monitor" IDX_REDMON
111 joko 1.1
112     SetDetailsPrint both
113     DetailPrint "Installing RedMon Port Redirection Monitor..."
114    
115     ;SectionIn RO
116    
117     StrCpy $redmonInstDir "$PROGRAMFILES\redmon17de"
118    
119     ; Set output path to the installation directory.
120     SetOutPath $redmonInstDir
121    
122     ; Put file there
123     File "C:\tmp\w2hfax-make\redmon17de\*.*"
124 joko 1.2 ; TODO: integrate into here to use current $INSTDIR
125 joko 1.1 File "redmon_configure.reg"
126    
127     ; Write the installation path into the registry
128     WriteRegStr HKLM SOFTWARE\NSIS_redmon17de "Install_Dir" "$redmonInstDir"
129    
130     ; Write the uninstall keys for Windows
131     WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\redmon17de" "DisplayName" "redmon17de"
132     WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\redmon17de" "UninstallString" '"$redmonInstDir\uninstall.exe"'
133     WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\redmon17de" "NoModify" 1
134     WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\redmon17de" "NoRepair" 1
135     WriteUninstaller "uninstall.exe"
136    
137     DetailPrint "Registering RedMon Port Redirection Monitor..."
138     nsExec::Exec "$redmonInstDir\setup.exe"
139    
140     DetailPrint "Configuring RedMon Port Redirection Monitor..."
141 joko 1.2 ; TODO: integrate into here to use current $INSTDIR
142 joko 1.1 nsExec::Exec "$redmonInstDir\redmon_configure.reg"
143    
144     SectionEnd
145    
146    
147     ; Optional section (can be disabled by the user)
148 joko 1.2 Section "Start Menu Shortcuts" IDX_STARTMENU
149 joko 1.1
150     SetDetailsPrint both
151     DetailPrint "Installing Start Menu and Desktop Shortcuts..."
152    
153     CreateDirectory "$SMPROGRAMS\w2hfax"
154     CreateShortCut "$SMPROGRAMS\w2hfax\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
155     CreateShortCut "$SMPROGRAMS\w2hfax\w2hfax.lnk" "$INSTDIR\w2hfax.exe" "" "$INSTDIR\w2hfax.exe" 0
156    
157     SectionEnd
158    
159    
160 joko 1.2
161 joko 1.1 ; --------------------------------
162     ; Uninstaller
163     ; --------------------------------
164    
165 joko 1.2 Section "Uninstall" IDX_UNINSTALL
166 joko 1.1
167     ; ------------------
168     ; uninstall redmon
169     ; ------------------
170     ReadRegStr $redmonInstDir HKLM "Software\NSIS_redmon17de" "Install_Dir"
171     IfFileExists $redmonInstDir\unredmon.exe found
172     Messagebox MB_OK "Uninstall path incorrect"
173     Abort
174     found:
175     nsExec::Exec "$redmonInstDir\unredmon.exe"
176     ;Delete $redmonInstDir\uninstall.exe
177     Delete "$redmonInstDir\*.*"
178     RMDir "$redmonInstDir"
179    
180    
181     ; ------------------
182     ; uninstall w2hfax
183     ; ------------------
184    
185     ; Remove registry keys
186     DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\w2hfax"
187     DeleteRegKey HKLM SOFTWARE\NSIS_w2hfax
188    
189     ; Remove registry keys
190     DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\redmon17de"
191     DeleteRegKey HKLM SOFTWARE\NSIS_redmon17de
192    
193    
194     ; Remove files and uninstaller
195     ;Delete $INSTDIR\makensisw.exe
196     ;Delete $INSTDIR\uninstall.exe
197     Delete "$INSTDIR\*.*"
198    
199     ; Remove shortcuts, if any
200     Delete "$SMPROGRAMS\w2hfax\*.*"
201    
202     ; Remove directories used
203     RMDir "$SMPROGRAMS\w2hfax"
204     RMDir "$INSTDIR"
205    
206     SectionEnd
207 joko 1.2
208    
209     ; --------------------------------
210     ; Functions
211     ; --------------------------------
212    
213     Function check_python
214    
215     SetDetailsPrint both
216     DetailPrint "Checking for Python installation..."
217    
218     ClearErrors
219    
220     ReadRegStr $python_path HKLM Software\Python\PythonCore\2.4\InstallPath ""
221     IfErrors +3
222     StrCpy $python_version "2.4"
223     Goto found_python
224    
225     ReadRegStr $python_path HKLM Software\Python\PythonCore\2.3\InstallPath ""
226     IfErrors +3
227     StrCpy $python_version "2.3"
228     Goto found_python
229    
230     ReadRegStr $python_path HKLM Software\Python\PythonCore\2.2\InstallPath ""
231     IfErrors +3
232     StrCpy $python_version "2.2"
233     Goto found_python
234    
235     Goto no_python
236    
237     found_python:
238 joko 1.3 ; check if python.exe is really present
239     ClearErrors
240     IfFileExists $python_path\python.exe 0 +2
241     DetailPrint "Found Python $python_version at: $python_path."
242     Return
243 joko 1.2
244     no_python:
245 joko 1.3 ; error: no python
246     ;MessageBox MB_OK "No Python installation found (checked HKLM\Software\Python\PythonCore\2.3 and HKLM\Software\Python\PythonCore\2.2)."
247     ;Call install_python
248     SetErrors
249 joko 1.2
250     FunctionEnd
251    
252    
253    
254     Function install_python
255    
256     IfFileExists "$EXEDIR\python-2.4.msi" 0 +2
257     StrCpy $python_msi "$EXEDIR\python-2.4.msi"
258     IfFileExists "$INSTDIR\python-2.4.msi" 0 +2
259     StrCpy $python_msi "$INSTDIR\python-2.4.msi"
260    
261     ;MessageBox MB_OK $python_msi
262     StrCmp $python_msi "" 0 run_setup
263    
264     SetDetailsPrint textonly
265     DetailPrint "Downloading Python 2.3"
266     SetDetailsPrint listonly
267    
268     StrCpy $python_url "http://www.python.org/ftp/python/2.4/python-2.4.msi"
269     MessageBox MB_YESNO "Download Python 2.3 from $python_url?" IDYES NoCancelAbort
270     ;Abort ; causes uninstaller to not quit.
271     Return
272    
273     NoCancelAbort:
274     NSISdl::download $python_url $INSTDIR\python-2.4.msi
275    
276     run_setup:
277     IfFileExists $python_msi 0 +10
278     SetDetailsPrint textonly
279     DetailPrint "Installing Python..."
280     SetDetailsPrint listonly
281     ExecWait 'msiexec /i "$python_msi"'
282    
283     FunctionEnd
284    
285    
286     Function check_pythonwin
287    
288     SetDetailsPrint both
289     DetailPrint "Checking for installation of 'Python for Win32 Extensions'..."
290     IfFileExists "$python_path\Lib\site-packages\win32com\server\register.py" 0 no_pythonwin
291     Return
292    
293     no_pythonwin:
294     SetErrors
295    
296     FunctionEnd
297    
298    
299     Function install_pythonwin
300    
301     ; installer exe
302     StrCmp $python_version "2.2" 0 +2
303     StrCpy $R0 "pywin32-203.win32-py2.2.exe"
304     StrCmp $python_version "2.3" 0 +2
305     StrCpy $R0 "pywin32-203.win32-py2.3.exe"
306     StrCmp $python_version "2.4" 0 +2
307     StrCpy $R0 "pywin32-203.win32-py2.4.exe"
308    
309     ; download base
310     StrCpy $R1 "http://mesh.dl.sourceforge.net/sourceforge/pywin32/$R0"
311    
312 joko 1.3 StrCpy $R2 ""
313 joko 1.2 IfFileExists "$EXEDIR\$R0" 0 +2
314     StrCpy $R2 "$EXEDIR\R0"
315     IfFileExists "$INSTDIR\$R0" 0 +2
316     StrCpy $R2 "$INSTDIR\$R0"
317    
318     ;MessageBox MB_OK $R2
319     StrCmp $R2 "" 0 run_setup
320    
321     SetDetailsPrint textonly
322     DetailPrint "Downloading 'Python for Win32 Extensions'"
323     SetDetailsPrint listonly
324    
325     MessageBox MB_YESNO "Download 'Python for Win32 Extensions' from $R1?" IDYES NoCancelAbort
326     ;Abort ; causes uninstaller to not quit.
327     Return
328    
329     NoCancelAbort:
330     NSISdl::download $R1 $INSTDIR\$R0
331     StrCpy $R2 "$INSTDIR\$R0"
332    
333     run_setup:
334     IfFileExists $R2 0 +10
335     SetDetailsPrint textonly
336     DetailPrint "Installing 'Python for Win32 Extensions'..."
337     SetDetailsPrint listonly
338     ExecWait '"$R2"'
339    
340     FunctionEnd
341    
342    
343 joko 1.3 Function check_ghostscript
344    
345     SetDetailsPrint both
346     DetailPrint "Checking for Ghostscript installation..."
347    
348     ClearErrors
349     StrCpy $ghostscript_version_required 8.50
350    
351     StrCpy $0 0
352     loop:
353     EnumRegKey $1 HKLM "SOFTWARE\AFPL Ghostscript" $0
354     StrCmp $1 "" done
355     IntOp $0 $0 + 1
356     ; MessageBox MB_YESNO|MB_ICONQUESTION "$1$\n$\nMore?" IDYES loop
357     done:
358     StrCpy $ghostscript_version $1
359    
360     ReadRegStr $R0 HKLM "Software\AFPL Ghostscript\$ghostscript_version" "GS_DLL"
361     IfFileExists "$R0" 0 no_ghostscript
362    
363     StrCpy $R0 $ghostscript_version
364     StrCpy $R1 $ghostscript_version_required
365     Math::Script "R2 = #[R0 >= R1, 1, 0]"
366     StrCmp $R2 "1" 0 no_ghostscript
367     Return
368    
369     no_ghostscript:
370     SetErrors
371    
372     FunctionEnd
373    
374    
375     Function install_ghostscript
376    
377     ; installer exe
378     StrCpy $R0 "gs850w32.exe"
379    
380     ; download base
381     StrCpy $R1 "ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs850/$R0"
382    
383     ; package title
384     StrCpy $R9 "AFPL Ghostscript 8.50"
385    
386     StrCpy $R2 ""
387     IfFileExists "$EXEDIR\$R0" 0 +2
388     StrCpy $R2 "$EXEDIR\R0"
389     IfFileExists "$INSTDIR\$R0" 0 +2
390     StrCpy $R2 "$INSTDIR\$R0"
391    
392     StrCmp $R2 "" 0 run_setup
393    
394     SetDetailsPrint textonly
395     DetailPrint "Downloading '$R9'"
396     SetDetailsPrint listonly
397    
398     MessageBox MB_YESNO "Download '$R9' from $R1?" IDYES NoCancelAbort
399     ;Abort ; causes uninstaller to not quit.
400     Return
401    
402     NoCancelAbort:
403     NSISdl::download $R1 $INSTDIR\$R0
404     StrCpy $R2 "$INSTDIR\$R0"
405    
406     run_setup:
407     IfFileExists $R2 0 +10
408     SetDetailsPrint textonly
409     DetailPrint "Installing '$R9'..."
410     SetDetailsPrint listonly
411     ExecWait '"$R2"'
412    
413     FunctionEnd
414    
415    
416     Function check_ghostview
417    
418     SetDetailsPrint both
419     DetailPrint "Checking for GSview installation..."
420    
421     ReadRegStr $R0 HKLM Software\Ghostgum\GSview "4.3"
422     IfFileExists "$R0\gsview\gsview32.exe" 0 +3
423     StrCpy $ghostview_version "4.3"
424     Goto ok_ghostview
425    
426     ReadRegStr $R0 HKLM Software\Ghostgum\GSview "4.6"
427     IfFileExists "$R0\gsview\gsview32.exe" 0 no_ghostview
428     StrCpy $ghostview_version "4.6"
429     Goto ok_ghostview
430    
431     ok_ghostview:
432     StrCpy $ghostview_exe "$R0\gsview\gsview32.exe"
433     ClearErrors
434     Return
435    
436     no_ghostview:
437     SetErrors
438    
439     FunctionEnd
440    
441    
442     Function install_ghostview
443    
444     ClearErrors
445    
446     ; installer exe
447     StrCpy $R0 "gsv46w32.exe"
448    
449     ; download base
450     StrCpy $R1 "ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/ghostgum/$R0"
451    
452     ; package title
453     StrCpy $R9 "GSview 4.6"
454    
455     StrCpy $R2 ""
456     IfFileExists "$EXEDIR\$R0" 0 +2
457     StrCpy $R2 "$EXEDIR\R0"
458     IfFileExists "$INSTDIR\$R0" 0 +2
459     StrCpy $R2 "$INSTDIR\$R0"
460    
461     StrCmp $R2 "" 0 run_setup
462    
463     SetDetailsPrint textonly
464     DetailPrint "Downloading '$R9'"
465     SetDetailsPrint listonly
466    
467     MessageBox MB_YESNO "Download '$R9' from $R1?" IDYES NoCancelAbort
468     ;Abort ; causes uninstaller to not quit.
469     Return
470    
471     NoCancelAbort:
472     NSISdl::download $R1 $INSTDIR\$R0
473     StrCpy $R2 "$INSTDIR\$R0"
474    
475     run_setup:
476     IfFileExists $R2 0 +10
477     SetDetailsPrint textonly
478     DetailPrint "Installing '$R9'..."
479     SetDetailsPrint listonly
480     ExecWait '"$R2"'
481    
482     FunctionEnd
483    
484    
485 joko 1.2 ; --------------------------------
486     ; Startup
487     ; --------------------------------
488     Function .onInit
489    
490     Call check_python
491     IfErrors 0 python_found
492     SectionSetFlags ${IDX_PYTHON} 1
493 joko 1.3 ;Return
494     Goto pythonwin
495 joko 1.2
496     python_found:
497     SectionSetFlags ${IDX_PYTHON} 0
498     SectionSetText ${IDX_PYTHON} "Python (found version $python_version)"
499     ;Return
500    
501    
502 joko 1.3 pythonwin:
503 joko 1.2 Call check_pythonwin
504     IfErrors 0 pythonwin_found
505     SectionSetFlags ${IDX_PYTHONWIN} 1
506 joko 1.3 ;Return
507     Goto ghostscript
508 joko 1.2
509     pythonwin_found:
510     SectionSetFlags ${IDX_PYTHONWIN} 0
511     SectionSetText ${IDX_PYTHONWIN} "Python for Win32 Extensions (found)"
512     ;Return
513 joko 1.3
514    
515     ghostscript:
516     Call check_ghostscript
517     IfErrors 0 ghostscript_found
518     SectionSetFlags ${IDX_GHOSTSCRIPT} 1
519     StrCmp $ghostscript_version "" 0 +1
520     SectionSetText ${IDX_GHOSTSCRIPT} "AFPL Ghostscript 8.50 (not found)"
521     SectionSetText ${IDX_GHOSTSCRIPT} "AFPL Ghostscript 8.50 (found $ghostscript_version < $ghostscript_version_required)"
522     ;Return
523     Goto ghostview
524    
525     ghostscript_found:
526     SectionSetFlags ${IDX_GHOSTSCRIPT} 0
527     SectionSetText ${IDX_GHOSTSCRIPT} "AFPL Ghostscript 8.50 (found $ghostscript_version)"
528    
529    
530     ghostview:
531     Call check_ghostview
532     IfErrors 0 ghostview_found
533     SectionSetFlags ${IDX_GHOSTVIEW} 1
534     Return
535    
536     ghostview_found:
537     SectionSetFlags ${IDX_GHOSTVIEW} 0
538     SectionSetText ${IDX_GHOSTVIEW} "GSview 4.6 (found $ghostview_version)"
539    
540     FunctionEnd
541    
542    
543     Function w2hfax_configure
544     ; (pre-)configure w2hfax here!
545     ; e.g. set tiff-viewer dependent of operating system: use shimgvw.dll for WinXP, use Kodak Imaging for Win2000 or others
546    
547     ; set PostScript viewer
548     WriteRegStr HKCU Software\GNU\w2hfax "psviewer" "$ghostview_exe"
549    
550     ; set TIFF viewer
551     StrCpy $R1 ""
552    
553     ; if os == xp
554     StrCpy $R2 ""
555     ReadRegStr $R2 HKLM "Software\Microsoft\Windows NT\CurrentVersion" "ProductName"
556     StrCmp $R2 "Microsoft Windows XP" 0 noWinXP
557     StrCpy $R1 "rundll32.exe shimgvw.dll,ImageView_Fullscreen"
558     Goto ok_tiffviewer
559    
560     noWinXP:
561     IfFileExists "$PROGRAMFILES\Windows NT\Zubehör\ImageVue\kodakimg.exe" 0 +2
562     StrCpy $R1 "$PROGRAMFILES\Windows NT\Zubehör\ImageVue\kodakimg.exe"
563     IfFileExists "$PROGRAMFILES\Windows NT\Accessories\ImageVue\wangimg.exe" 0 +2
564     StrCpy $R1 "$PROGRAMFILES\Windows NT\Accessories\ImageVue\wangimg.exe"
565    
566     ok_tiffviewer:
567     StrCmp $R1 "" no_tiffviewer
568     ;MessageBox MB_OK $R1
569     WriteRegStr HKCU Software\GNU\w2hfax "tifviewer" "$R1"
570     Return
571    
572     no_tiffviewer:
573     Return
574 joko 1.2
575     FunctionEnd

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed