;;
;;      $Source: Devel:enprint/inst/RCS/InstallScript,v $
;;      $Author: tsarna $
;;    $Revision: 37.21 $
;;        $Date: 1996/03/10 08:30:16 $
;;
;;        EnPrint Installation Script
;;
;;    (C) Copyright 1994-1996 Endicor Technologies, Inc.
;;        All Rights Reserved.
;;

;$VER: Install 37.21

(complete 0)

; prefs only if running 2.04 or better
(if (< (/ (getversion) 65536) 37)
   (abort "You must have Workbench 2.04 or later to use " 
          "This version of the EnPrint software."
   )
)

(welcome
   "Welcome to the EnPrint installation utility.\n\n"
)

(message
   "\nWelcome to the EnPrint installation utility.\n\n"
   "If you currently have EnPrint 2.0 installed and "
   "have customized the printer configurations, you "
   "may wish to abort installation and back them "
   "up before installing, to prevent them from being "
   "overwritten."
)

(if (= (/ (getversion "LIBS:diskfont.library") 65536) 36)
   (if
      (askbool
         (prompt
            "EnPrint 2.1 needs V37 or later of the diskfont.library, "
            "but you have V36 installed. Workbench 2.04 installs V36 by "
            "default, but V37 also included with Workbench 2.04 to "
            "support outline fonts. You will have to install V37 "
            "of the library of EnPrintPrefs will not work. Would "
            "you like to install it now? You will need your Workbench "
            "2.04 Fonts Installation Disk."
         )
         (help
            "Do you want to install the V37 diskfont.library from the "
            "Amiga Fonts 2.0 disk? If you don't, EnPrintPrefs won't work."
         )
      )
      (
         (copylib (source "AmigaFonts2.0:LIBS/diskfont.library")
            (dest "LIBS:")
            (optional "force" "askuser")
            (infos)
         )
         (message
            "diskfont.library V37 installed. YOU WILL NEED TO REBOOT "
            "THE SYSTEM AFTER INSTALLATION IS COMPLETELY FINISHED for "
            "the change to take effect."
         )
      )
   )
)

(complete 5)

(set olddir (getassign "StylusColor"))
(if
   (or 
      (or
         (strlen olddir)
         (exists "SYS:Prefs/StylusColor")
      )
      (or
         (exists "ENVARC:StylusColor")
         (exists "ENV:StylusColor")
      )
   )
   (if
      (askbool
         (prompt
            "\nYou have an old version of the Endicor Epson Stylus "
            "Color driver installed. We recommend deleting this "
            "old version.\n\n "
            "Would you like to do that now?"
         )
         (help
            "Select \"Yes\" to delete the old V1.x"
            "driver files or \"No\" to leave them."
         )
      )
      (
         (if (strlen olddir)
            (makeassign "StylusColor")
            (run (cat "Delete \"" olddir "(|.info)\" ALL FORCE QUIET"))
         )
         (run "Delete ENVARC:StylusColor ALL FORCE QUIET")
         (run "Delete ENV:StylusColor ALL FORCE QUIET")
         (run "Delete SYS:Prefs/StylusColor(|.info) ALL FORCE QUIET")
         (run "Delete DEVS:printers/EpsonStylusColo(r|r020|r030|r040)(|.info) ALL FORCE QUIET")
         (run "Delete DEVS:printers/EpsonStylusColor(|.info) ALL FORCE QUIET")
         (run "Avail >NIL: FLUSH ALL FORCE QUIET")
         (startup "EpsonStylusColor"
            (prompt "Select \"Proceed\" to have the StylusColor: "
                    "assign removed from your user-startup file "
            )
            (help "You should select \"Proceed\" to remove the "
                  "Assignment of StylusColor: that no longer "
                  "applies"
            )
            (command "; *** YOU CAN DELETE THESE THREE LINES NOW ***")
         )
      )
   )
)

(complete 10)

(set ddestdir
   (tackon
      (askdir
         (prompt
            "\nIn which disk (or drawer) should the EnPrint drawer "
            "be created or updated? This drawer will hold the "
            "documentation and other driver-related files. (the "
            "driver itself will be installed in the standard location)"
         )
         (help @askdir-help)
         (default "SYS:")
      )
      "EnPrint"
   )
)
(if (NOT (exists ddestdir))
   (makedir ddestdir
      (infos)
   )
)
(makeassign "EnPrint" ddestdir)

(complete 15)

(set btdef (getassign "BIG_T"))
(if (NOT (strlen btdef))
   (
      (if (NOT (exists "EnPrint:BIG_T"))
         (makedir "EnPrint:BIG_T")
      )
      (set btdef "EnPrint:BIG_T")
   )  
)

(set btdestdir
   (askdir
      (prompt
         "A directory named BIG_T: is needed to store data when using spooling "
         "and for the EnPrint printing program. This directory must "
         "have space for ~20M when using spooling, and ~3M otherwise. "
         "If your T: directory is on RAM: and has enough space you "
	 "may use it. Otherwise, create a directory somewhere else."
      )
      (help @askdir-help)
      (default btdef)
   )
)
(if (NOT (exists btdestdir))
   (makedir btdestdir
      (infos)
   )
)
(makeassign "BIG_T" btdestdir)

(set hasold 0)
(if
   (or
      (exists "EnPrint:Printers/EpsonStylusColor.epd")
      (exists "EnPrint:StylusCalib")
   )
   (set hasold 1)
)
(set delold hasold)
(if (and (>= @user-level 2) hasold)
   (if
      (askbool
         (prompt
            "\nSome files from EnPrint 2.0 are no longer needed by "
            "EnPrint 2.1 or have been replaced by differently named "
            "files. Would you like to delete the old files?\n\n"
         )
         (help
            "Select \"Yes\" to delete the files from "
            "EnPrint 2.0 that are no longer needed. "
            "We suggest deleteing them, but leaving them will cause "
            "no problems."
         )
      )
      (set delold 1)
      (set delold 0)
   )
)

(complete 20)

(if (exists "ENV:ESCP2OutSpecial")
   (set ovar (getenv "ESCP2OutSpecial"))
   ;else
   (set ovar "{creq}")
)
(set odef 0)
(if (patmatch "#?buffer#?" ovar)
   (set odef (BITOR odef 1))
)
(if (patmatch "#?spool#?" ovar)
   (set odef (BITOR odef 1))
)
(if (patmatch "#?creq#?" ovar)
   (set odef (BITOR odef 2))
)

(set opts (askoptions
   (prompt
      "Two special options for EnPrint can be set by an environment "
      "variable. The two options are graphics spooling, and an extra "
      "cancel requester. Select Help below for more information.\n\n"
      "Which options would you like set\nin your user-startup file?"
   )
   (help
      "Graphics spooling:\n\n"
      "This option causes graphics output to be buffered to disk "
      "one page at a time during processing, then printed. This option "
      "requires enough free space in the directory BIG_T: is assigned "
      "to for storage of one complete page of graphics output. This "
      "can be up to 20 megabytes of space for a full page 720dpi color "
      "print, but usually compression will reduct this to 12-18 "
      "megabytes. This option is useful if banding is experienced on "
      "output due to the ink drying unevenly during processing delays. "
      "This option avoids this problem.\n\n"
      "Cancel requester:\n\n"
      "This option causes an \"Abort Printing?\" requester to be "
      "displayed on Workbench. This is useful when printing with "
      "programs (like GraphicDump) that don't provide a cancel "
      "requester of their own.\n\n"
      "After installation, read EnPrint.guide for even more "
      "information on these and other options availible. See "
      "The section entitled \"Special Output Hooks\"."
   )
   (choices "Graphics Spooling (takes 20M)" "EnPrint Cancel Requester")
   (default odef)
))

(if (and (in opts 0) (in opts 1))
   (set hook "{creq}{spool}{creq}")
   (if (in opts 0)
      (set hook "{spool}")
      (if (in opts 1)
         (set hook "{creq}")
         (set hook "")
      )
   )
)

(set us (cat
   "; Make sure LIBS: includes Sys:Classes\n"
   "If Not Exists LIBS:window.class\n"
   "   Assign LIBS: Sys:Classes Add\n"
   "EndIf\n"
   "Assign EnPrint: " ddestdir "\nAssign BIG_T: " btdestdir "\n"
   "Assign LIBS: EnPrint:LIBS Add\n"
))
(set stus (cat
   "SetEnv ESCP2OutSpecial \"" hook "\"\n"
))

(startup "EnPrint"
   (prompt
      "\nSome instructions need to be added to the system startup file(s):\n\n"
      ";BEGIN EnPrint\n" us ";END EnPrint\n"
   )
   (help "This will add some lines to user-startup script to assign "
	"EnPrint: to the directory you specified before."
   )
   (command us)
)
(complete 25)
(run stus)
(startup "EnPrint_Stylus"
   (prompt
      "\nSome more instructions need to be added to the system startup file(s):\n\n"
      ";BEGIN EnPrint_Stylus\n" stus ";END EnPrint_Stylus\n"
   )
   (help "This will add some lines to user-startup script to enable "
	"the special output option(s) you have selected."
   )
   (command stus)
)

(complete 30)

(working
   "\n\nDecompressing files from floppy for installation."
   "\n\nThis can take a while -- please be patient."
)
(if (run "LHEX -qfw=BIG_T: x EnPrint.LHA")
   (abort "\nError dearchiving driver\nfiles -- floppy corrupt?!!!")
)

(complete 40)
(copylib (source "BIG_T:arc/SysLibs/endicor.library")
   (dest "LIBS:")
   (optional "force" "askuser")
   (infos)
)
(if (NOT (exists "Sys:Classes"))
   (makedir "Sys:Classes")
)
(copylib (source "BIG_T:arc/Classes/aghelp.engui")
   (dest "Sys:Classes")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/Classes/window.class")
   (dest "Sys:Classes")
   (optional "force" "askuser")
   (infos)
)
(if (NOT (exists "Sys:Classes/Images"))
   (makedir "Sys:Classes/Images")
)
(copylib (source "BIG_T:arc/Classes/Images/glyph.image")
   (dest "Sys:Classes/Images")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/Classes/Images/label.image")
   (dest "Sys:Classes/Images")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/Classes/Images/drawlist.image")
   (dest "Sys:Classes/Images")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/Classes/Images/bevel.image")
   (dest "Sys:Classes/Images")
   (optional "force" "askuser")
   (infos)
)
(if (NOT (exists "Sys:Classes/Gadgets"))
   (makedir "Sys:Classes/Gadgets")
)
(copylib (source "BIG_T:arc/Classes/Gadgets/button.gadget")
   (dest "Sys:Classes/Gadgets")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/Classes/Gadgets/clicktab.gadget")
   (dest "Sys:Classes/Gadgets")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/Classes/Gadgets/scroller.gadget")
   (dest "Sys:Classes/Gadgets")
   (optional "force" "askuser")
   (infos)
)
(run "Assign LIBS: Sys:Classes Add\n")
(complete 44)
(set lay020 0)
(if
   (and
      (>= (/ (getversion) 65536) 39)
      (>= (database "cpu") 68020)
   )
   (set lay020 1)
)
(copylib (source "BIG_T:arc/Classes/Gadgets/layout.gadget.020")
   (dest "Sys:Classes/Gadgets")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/Classes/Gadgets/layout.gadget.000")
   (dest "Sys:Classes/Gadgets")
   (optional "force" "askuser")
   (infos)
)
(if lay020
   (run (cat
      "Copy Sys:Classes/Gadgets/layout.gadget.020 "
      "Sys:Classes/Gadgets/layout.gadget"
   ))
   (run (cat
      "Copy Sys:Classes/Gadgets/layout.gadget.000 "
      "Sys:Classes/Gadgets/layout.gadget"
   ))
)
(complete 46)
(copylib (source "BIG_T:arc/Drivers/EpsonStylusCOLOR")
   (dest "DEVS:printers")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/Drivers/EpsonStylusCOLOR_II")
   (dest "DEVS:printers")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/Drivers/EpsonStylusIIsBlack")
   (dest "DEVS:printers")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/Drivers/EpsonStylusIIsColor")
   (dest "DEVS:printers")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/Drivers/EpsonStylusPro")
   (dest "DEVS:printers")
   (optional "force" "askuser")
   (infos)
)
(complete 50)
(if (NOT (exists "EnPrint:LIBS"))
   (makedir "EnPrint:LIBS")
)
; make LIBS: assign active now too
(run "Assign LIBS: EnPrint:LIBS add")
(copylib (source "BIG_T:arc/EnPrintLibs/enprint.library")
   (dest "EnPrint:LIBS")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/EnPrintLibs/enprint_prfdrv.library")
   (dest "EnPrint:LIBS")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/EnPrintLibs/enprint.opfile")
   (dest "EnPrint:LIBS")
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/EnPrintLibs/escp2.enpex")
   (dest "EnPrint:LIBS")
   (optional "force" "askuser")
   (infos)
)
(complete 54)
(copylib (source "BIG_T:arc/Progs/EnPrintPrefs")
   (dest "Sys:Prefs")
   (optional "force" "askuser")
   (infos)
)
(complete 56)
(copylib (source "BIG_T:arc/Progs/ConfEd")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(complete 58)
(copylib (source "BIG_T:arc/Progs/ESCP2Out")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(complete 60)
(copylib (source "BIG_T:arc/Progs/MakePic")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(complete 62)
(copylib (source "BIG_T:arc/Progs/IFFLoad")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(complete 64)
(copylib (source "BIG_T:arc/Progs/Manip")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(complete 66)
(copylib (source "BIG_T:arc/Progs/EnPrint")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(complete 68)
(copylib (source "BIG_T:arc/Progs/AspectWhiz")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(complete 70)
(copylib (source "BIG_T:arc/EnPrint.guide")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/EnPrint.TXT")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(complete 72)
(copyfiles (source "BIG_T:arc/EnPrintStylus.FW")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(complete 74)
(copylib (source "BIG_T:arc/Epson.guide")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(copylib (source "BIG_T:arc/Epson.TXT")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(complete 76)
(copylib (source "README.FIRST")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)
(complete 78)
(copylib (source "BIG_T:arc/Progs/EpsonSpecial")
   (dest ddestdir)
   (optional "force" "askuser")
   (infos)
)

(if (NOT (exists "EnPrint:Config"))
   (makedir "EnPrint:Config")
)
(if (NOT (exists "EnPrint:Config/Defaults"))
   (makedir "EnPrint:Config/Defaults")
)
(if (NOT (exists "EnPrint:Printers"))
   (makedir "EnPrint:Printers")
)
(if (NOT (exists "EnPrint:Dithers"))
   (makedir "EnPrint:Dithers")
)

(complete 80)

(copyfiles (source "BIG_T:arc/Config")
   (dest "EnPrint:Config")
   (optional "force" "askuser")
   (all)
)
(copyfiles (source "BIG_T:arc/Config")
   (dest "EnPrint:Config/Defaults")
   (optional "force" "askuser")
   (all)
)
(complete 82)
(copyfiles (source "BIG_T:arc/Printers")
   (dest "EnPrint:Printers")
   (optional "force" "askuser")
   (all)
)
(complete 83)

(if delold
   (
      (if (exists "EnPrint:Printers/EpsonStylusColor.epd")
         (run "Delete EnPrint:Printers/#?.epd ALL FORCE QUIET")
      )
      (delete "EnPrint:StylusCalib" (optional "force" "askuser"))
   )
)

(complete 84)
(copyfiles (source "BIG_T:arc/Dithers")
   (dest "EnPrint:Dithers")
   (optional "force" "askuser")
   (all)
)

(complete 88)
(copylib (source "Installer")
   (dest "C:")
   (optional "force" "askuser")
   (infos)
)
(complete 90)
(copylib (source "BIG_T:arc/ag/AmigaGuide")
   (dest "Sys:Utilities")
   (optional "force" "askuser")
   (infos)
)
(complete 92)
(copylib (source "BIG_T:arc/ag/WDisplay")
   (dest "Sys:Utilities")
   (optional "force" "askuser")
   (infos)
)
(complete 94)
(copylib (source "BIG_T:arc/ag/amigaguide.library")
   (dest "libs:")
   (optional "force" "askuser")
   (infos)
)
(complete 96)
(copylib (source "BIG_T:arc/ag/help.guide")
   (dest "s:")
   (optional "force" "askuser")
   (infos)
)

(complete 98)

(working "\nDeleteing temporary files.")
(run "Delete BIG_T:arc ALL FORCE QUIET")

(complete 99)

(message
   "\nNOTE: Several people have reported strange problems with printing "
   "after installation which went away after powering the system down. "
   "We believe we have traced this to an error in the Installer program "
   "by Commodore. We recommend that you proceed to exit this program "
   "and then reboot before continuing. We are looking for a better "
   "workaround."
)

(complete 100)

;(run "Run <nil: >nil: Sys:Utilities/More README.BETA")
(run "Run <nil: >nil: Sys:Utilities/More EnPrint:README.FIRST")

(message
   "\nInstallation Complete!\n\n"
   "Please read the README.FIRST file now!\n\n"
   "DON'T FORGET to send in your registration card for full "
   "upgrade and techincal support!"
)

;(message
;   "\nBETA NOTE:\n\nPlease read the file README.BETA on the disk!"
;)
   
(exit (quiet))
