; PhonePak VFX Installation script
; $VER: PhonePak Install 2.0 (05-May-93)
; 

; Written for use with Commodore's Installer.

(set phonepak "PhonePak_2.0:")
(set messages1 "Messages1:")
(set messages2 "Messages2:")
(set ppak "PPAK:")

; ====================
; Install the libraries, devices, and other system files...
;

(if (askbool (prompt "Is this an A3000/A3000T?")
             (choices "Yes" "No")
             (default "No")
             (help "The A3000 and A3000T have a design problem which prevents "
                   "DMA from functioning properly, so a different version of "
                   "PhonePak.library must be installed.  This problem has been "
                   "corrected in the A4000.\n\n"))
    (
      (copyfiles (source (tackon phonepak "libs/PPak3000.library"))
                 (dest "LIBS:")
                 (confirm)
                 (newname "PhonePak.library")
                 (prompt "Shall I install the PhonePak.library into your LIBS: "
                     "drawer?")
                 (help "PhonePak.library is a collection of commonly used routines "
                     "required by the PhonePak VFX software.\n\n"
                     @copylib-help))
    )
    (
      (copyfiles (source (tackon phonepak "libs/PPak2000.library"))
                 (dest "LIBS:")
                 (confirm)
                 (newname "PhonePak.library")
                 (prompt "Shall I install the PhonePak.library into your LIBS: "
                     "drawer?")
                 (help "PhonePak.library is a collection of commonly used routines "
                     "required by the PhonePak VFX software.\n\n"
                     @copylib-help))
    ))

(copylib (source (tackon phonepak "devs/PhonePak.device"))
         (dest "DEVS:")
         (confirm)
         (prompt "Shall I install the PhonePak.device into your DEVS: drawer?")
         (help "PhonePak.device controls the PhonePak VFX hardware\n\n"
               @copylib-help))

(copyfiles (source (tackon phonepak "devs/Printers/PPakFax"))
           (dest "DEVS:Printers")
           (confirm)
           (prompt "Shall I install the PPakFax printer driver into your "
                   "DEVS:Printers drawer?")
           (help "The PPakFax printer driver allows you to fax "
                 "directly from almost any standard Amiga application. To "
                 "enable this, the printer driver must be placed in the "
                 "DEVS:Printers drawer.\n\n"
                 @copylib-help))

(copyfiles (source (tackon phonepak "fonts"))
           (dest "FONTS:")
           (fonts)
           (all)
           (confirm)
           (prompt "Shall I install the fonts required by PhonePak VFX?")
           (help "These fonts are provided for the text to fax conversion "
                 "performed by the PhonePak VFX software. PhonePak.font is "
                 "the default font used, and LGMono.font is an alternate "
                 "fixed width font provided for your convenience.\n\n"
                 @copyfiles-help))

(copyfiles (source (tackon phonepak "rexx"))
           (dest "REXX:")
           (all)
           (confirm)
           (prompt "Shall I install the PhonePak ARexx scripts?")
           (help "These scripts provide useful examples of how to interact "
                 "with LineMan using the ARexx programming language.  "
                 "Message Forwarding uses the Forwarding.ppak script "
                 "by default.\n\n"
                 @copyfiles-help))

(set os_ver (/ (getversion) $0000FFFF))
(if (>= os_ver 36)
    (
      (copyfiles (source (tackon phonepak "Prefs/Presets/PPakFax.pre"))
                 (dest "SYS:Prefs/Presets")
                 (confirm)
                 (prompt "Shall I copy the PPakFax.pre presets file to the "
                         "SYS:Prefs/Presets drawer?\n\n")
                 (help "The PPakFax.pre file allows you to quickly set Prefs to "
                       "use the PPakFax printer driver.\n\n"
                       @copyfiles-help))
      (copylib (source (tackon phonepak "c/SetPatchWTAM"))
               (dest "C:")
               (confirm)
               (prompt "Shall I copy the SetPatchWTAM program to your C: directory?")
               (help "The SetPatchWTAM program is a patch supplied by Commodore to "
                     "fix a problem with font aspect ratios under Workbench 2.0.\n\n"
                     @copylib-help))
    )
)

(copylib (source (tackon phonepak "libs/req.library"))
         (dest "LIBS:")
         (confirm)
         (prompt "Shall I install req.library into your LIBS: drawer?")
         (help "req.library provides some of the requesters used by "
               "the PhonePak VFX software.\n\n"
               @copylib-help))

(if (NOT (exists "S:PhonePak.config"))
    (
      (copyfiles (source (tackon phonepak "s/PhonePak.config"))
                 (dest "S:"))
    ))

; ====================
; All libraries/system files are installed. Now install the software.
; 

(set target (tackon @default-dest "PhonePak"))

(if (askbool (prompt "I am going to install the PhonePak VFX software and "
                     "tools in:\n\n"
                     target
                     "\n\n"
                     "Is this OK?")
             (help "If this directory is OK, the directory will be created "
                   "and the software will be installed.\n\n")
             (choices "Yes" "No")
             (default "Yes"))
   (
      (makedir target (infos))
   )
   (
      (set target (askdir (prompt "In which directory should the PhonePak "
                                  "software and tools be installed?")
                                  (help @askdir-help)
                                  (default @default-dest)))
   ))

(makeassign "PPAK" target)

(copyfiles (source (tackon phonepak "c/LZ"))
           (dest "RAM:")
           (nogauge))

(working "Decompressing and installing PhonePak...")
(run ("RAM:LZ -N x %s %s" (tackon phonepak "PhonePak.LHA")
                           ppak))

(working "Decompressing and installing LineMan...")
(run ("RAM:LZ -N x %s %s" (tackon phonepak "LineMan.LHA")
                           ppak))

(working "Decompressing and installing PPakTools...")
(run ("RAM:LZ -N x %s %s" (tackon phonepak "PPakTools.LHA")
                           ppak))

; === Copy databases if they don't already exist

(if (NOT (exists (tackon target "AreaCodes.dat")))
    (
        (copyfiles (source phonepak)
            (dest target)
            (pattern "AreaCodes.#?"))
    ))
    
(if (NOT (exists (tackon target "Demo.dat")))
    (
        (copyfiles (source phonepak)
            (dest target)
            (pattern "Demo.#?"))
    ))

; === Install the 1.3 icons if the OS version is < 36.xx

(if (< os_ver 36)
   (
      (copyfiles (source (tackon phonepak "1.3_Icons"))
                 (dest target)
                 (all)
                 (infos))
   ))

; === Install the default system messages from messages disk one

(set master (tackon target "(Master)"))

(if (askbool (prompt "Are you upgrading from a previous version of PhonePak?")
             (help "If you are upgrading from a previous version of "
                   "PhonePak, you must specify the directory where your "
                   "system messages are located.  Only new system "
                   "messages will be copied.")
             (choices "Yes" "No")
             (default "No"))
   (
      (set flag 1)
      (set master (askdir (prompt "In which directory should new "
                                  "system messages be installed?")
                                  (help @askdir-help)
                                  (default master)))
   )
   (
      (set flag 0)
      (makedir master)
   ))

(makeassign "SYSMSG" master)

(if flag 0
  (
    (askdisk (dest "Messages1")
         (prompt "Please insert the Messages1 disk in any drive")
         (help "The Messages1 disk contains default system messages.\n\n"
         @askdisk-help))

    (working "Decompressing and installing default system messages...")
    (run ("RAM:LZ -m -N x %s %s/" (tackon messages1 "Messages.LHA")master))
  )
)

; === Install the default system messages from messages disk two

(askdisk (dest "Messages2")
         (prompt "Please insert the Messages2 disk in any drive")
         (help "The Messages2 disk contains default system messages.\n\n"
         @askdisk-help))

(if flag 0
    (run ("RAM:LZ -m -N x %s %s/" (tackon messages2 "AuxMsgs.LHA") master))
)

(run ("RAM:LZ -m -N x %s %s/" (tackon messages2 "Messages2.LHA") master))

(delete "RAM:LZ")

; === Setup the default-dest so the user is informed where PhonePak was installed.

(set @default-dest target)

; === Modify startup sequence.

(if (>= os_ver 36)
   (
    (onerror (message "Sorry, but either your startup-sequence was missing, "
                      "or it is too non-standard for the Installer program to "
                      "understand. You will have to make these modifications "
                      "by hand.\n\n"
                      "To patch the 2.0 font aspect ratio bug, add the "
                      "following line to your S:User-Startup or "
                      "Startup-Sequence:\n\n"
                      "SetPatchWTAM >NIL:\n")
             (message "To have PPAK: assigned to the directory in which "
                      "PhonePak is installed, add the following line to your "
                      "S:User-Startup or Startup-Sequence:\n\n"
                      ("Assign PPAK: %s\n\n" target)
                      "Note: This assignment is only required for the default "
                      "system setup.")
             (message "To have SYSMSG: assigned to the directory containing "
                      "your system messages, add the following line to your "
                      "S:User-Startup or Startup-Sequence:\n\n"
                      ("Assign SYSMSG: %s\n\n" master))
             (exit))
    (startup "PhonePak VFX"
             (prompt "Shall I modify your startup sequence to add the PPAK: "
                     "and SYSMSG: assigns and to automatically execute SetPatchWTAM?")
             (help "This will add the following lines to your S:User-Startup "
                   "file:\n\n"
                   "SetPatchWTAM >NIL:\n"
                   ("Assign PPAK: %s\n" target)
                   ("Assign SYSMSG: %s\n\n" master)
                   "The PPAK: assign is only used by the default system setup. "
                   "The SYSMSG: assign provides a path to your system "
                   "messages, making the creation of multiple systems easier.\n\n"
                   @startup-help)
             (command ("SetPatchWTAM >NIL:\n"))
             (command ("Assign PPAK: %s\n" target))
             (command ("Assign SYSMSG: %s" master)))
   )
   (
    (onerror (message "Sorry, but either your startup-sequence was missing, "
                      "or it is too non-standard for the Installer program to "
                      "understand. You will have to make this modification "
                      "by hand.\n\n"
                      "To have PPAK: assigned to the directory in which "
                      "PhonePak is installed, add the following line to your "
                      "S:User-Startup or Startup-Sequence:\n\n"
                      ("Assign PPAK: %s\n\n" target)
                      "Note: This assignment is only required for the default "
                      "system setup.")
             (message "To have SYSMSG: assigned to the directory containing "
                      "your system messages, add the following line to your "
                      "S:User-Startup or Startup-Sequence:\n\n"
                      ("Assign SYSMSG: %s\n\n" master))
             (exit))
    (startup "PhonePak VFX"
             (prompt "Shall I modify your startup sequence to add the PPAK: and SYSMSG: assigns?")
             (help "This will add the following lines to your S:User-Startup file:\n\n"
                   ("Assign PPAK: %s\n" target)
                   ("Assign SYSMSG: %s\n\n" master)
                   "The PPAK: assign is only used by the default system setup. "
                   "The SYSMSG: assign provides a path to your system "
                   "messages, making the creation of multiple systems easier.\n\n"
                   @startup-help)
             (command ("Assign PPAK: %s\n" target))
             (command ("Assign SYSMSG: %s" master)))
   ))
