;
; $VER: install 34.2 (24 Apr 1996)
;
; Installer script for SANA2Meter package.
;
; (C) Copyright 1996 Marius Gröger
;     All Rights Reserved.
;
; $HISTORY:
;

(set #cpu (database "cpu"))
(set #level @user-level)
(set #programdrawer "SANA2Meter")
(set #program "SANA2Meter")
(set #programdir "Bin")
(set #helpdir "Help")
(set #helpfile "SANA2Meter.guide")
(set #catdir "Catalogs")
(set #defcatinstalldir1 "LOCALE:")
(set #mwbicons "Icons/MagicWB")
(set #stdicons "Icons/Standard")
(set #definstallprogramdir "AMITCP:")

; -------------------------- Installation mode ---------------------------

(complete 0)

; (The installer documentation says not to use this call
; final distribtions, but I know no way to let the next decision
; popping up in novice mode. If you do, please mail to
; mag@sysgo.de. Thanks.)
(user 2)
(set mode
   (askoptions
       (prompt "Which parts should be installed ?")
       (choices "SANA2Meter program" "AmigaGuide documentation")
       (help @askoptions-help)
       (default 3)
   )
)
(user #level)

(complete 5)

(if (= mode 0)
   (
      (message "\n\n"\
               "You have nothing selected---Probably you had quite a hard day today. "\
               "Maybe it's better to try again tomorrow morning."
      )
      (exit (quiet))
   )
)

(set #installprogram (IN mode 0))
(set #installguide (IN mode 1))

(complete 10)

; -------------------------- Installation setup ---------------------------

(if #installprogram
   (
      (set #installprogramdir
         (tackon
            (askdir
               (prompt "Please locate the installation directory:\n"\
                       "(A drawer \"" #programdrawer "\" will be created there)")
               (help @askdir-help)
               (default #definstallprogramdir)
            )
            #programdrawer
         )
      )
      (if (= 1 (exists (tackon #installprogramdir #program) (noreq)))
         (
            (user 2)
            (set #update
               (askbool
                   (prompt "\n\nThere is an older version of " #program " installed. "\
                           "Do you want to keep the old icon and it's tooltype settings?"
                           )
                   (help (cat "Selecting \"Yes\" will only update the program code but "\
                              "won't touch the icon, thus preserving it's tooltype settings.\n\n"\
                              "Selecting \"No\" will do normal installation.\n\n"
                         @askbool-help))
               )
            )
            (user #level)
         )
      )

(complete 15)
      ; ---------------------------------------------------------------------
      (foreach #catdir "#?" (set #catchoices (cat #catchoices @each-name)))
      (user 2)
      (set #catalogs
         (askoptions
             (prompt "Which language catalogs should be installed?\n"
                     "The built-in default language is english.")
             (choices #catchoices)
             (help @askoptions-help)
             (default 1)
         )
      )
      (user #level)
(complete 20)
      (if #catalogs
         (
            (set #wherecat
               (askchoice
                  (prompt "Please locate the destination directory for the catalog file(s):\n"\
                          "(Non-existing drawers will be created when neccessary)")
                  (choices (tackon #defcatinstalldir1 "Catalogs/")
                           (tackon #installprogramdir "Catalogs/")
                  )
                  (help (cat "If you decide for the suggested default setting, the locale catalog(s) "\
                             "will be copied right beside the program file. This avoids overflowing "
                             "system locale catalog directories.\n\n"
                             @askchoice-help
                        )
                  )
                  (default 1)
               )
            )
            (set #installcatdir (select #wherecat #defcatinstalldir1 #installprogramdir))
         )
      )
(complete 25)
      ; ---------------------------------------------------------------------
      (set #proc
        (askchoice
           (prompt (cat "There are diffent versions of \"" #program "\", each one optimized "
                        "for a specific CPU type.\n"
                        "Please select one: "))
           (choices  "MC68000"
                     "MC68020"
                     "MC68040"
           )
           (help (cat "  Select here the CPU type that is installed in your system. "
                 "\n\n  Currently, this is a MC" #cpu ".\n\n  If you select a certain CPU type "
                 "in the choice box, \"" #program "\" will run on any CPU which "
                 "type is higher or equal to the selection. However, it won't "
                 "run on a system equipped with a lower type.\n\n"
                 @askchoice-help)
           )
           (default 0)
        )
      )
(complete 30)
      ; ---------------------------------------------------------------------
      (if (NOT #update)
         (
            (user 2)
            (set #device
               (select
                  (askchoice
                          (prompt "Which SANA-II network are you using?")
                          (choices  "none of the listed"
                                    "magPLIP"
                                    "SLIP"
                                    "CSLIP"
                                    "rhSLIP"
                                    "rhCSLIP"
                                    "PPP"
                                    "A2060"
                                    "A2065"
                                    "RS485"
                                    "AX25"
                          )
                          (help (cat "You should select the device you are using most frequently. "\
                                     "It will then be entered in the tooltype list of " #program ".\n\n"
                                     @askchoice-help
                                )
                          )
                          (default 0)
                  )
                  "<none>"
                  "magplip.device"
                  "slip.device"
                  "cslip.device"
                  "rhslip.device"
                  "rhcslip.device"
                  "ppp.device"
                  "a2060.device"
                  "a2065.device"
                  "rs485.device"
                  "ax25.device"
            ))
            (user #level)
         )
      )
   )
)

(complete 35)

(if #installguide
   (set #installhelpdir
      (askdir
         (prompt "Please locate the directory for AmigaGuide-Documents:")
         (help (cat "Select here the directory where you keep your "\
                    "AmigaGuide online help documents.\n\n"
                     @askdir-help
               )
         )
         (newpath)
         (default #installprogramdir)
      )
   )
)

(complete 40)

(user 2)
(set #iconkind
   (askchoice
           (prompt "Which flavour of icons do you want to install?")
           (choices  "4-Color Standard"
                     "8-Color MagicWB"
           )
           (help @askchoice-help)
           (default 0)
   )
)
(set #magicwb (= 1 #iconkind))
(user #level)


; ------------------------- Program Installation --------------------------

(complete 45)

(if (= 0 (exists #installprogramdir (noreq))) (makedir #installprogramdir (infos)))

(complete 50)

(if #installprogram
   (
      (copyfiles
         (prompt (cat "Copying the program"))
         (help @copyfiles-help)
         (source (cat (tackon #programdir #program)
                    (if (= 0 #proc) ".000")
                    (if (= 1 #proc) ".020")
                    (if (= 2 #proc) ".040")
         ))
         (dest #installprogramdir)
         (newname #program)
         (confirm)
      )
(complete 55)
      (if (NOT #update)
         (copyfiles
                 (prompt "Copying Icon")
                 (help @copyfiles-help)
                 (source (tackon
                       (if #magicwb #mwbicons #stdicons)
                       "Program.info")
                 )
                 (dest #installprogramdir)
                 (newname (cat #program ".info"))
                 (confirm)
         )
      )
(complete 60)
      (protect (tackon #installprogramdir #program) "prwed")
(complete 65)
      (if (NOT #update)
         (tooltype
                 (prompt "\n\nInitialising the icon's device information")
                 (help @tooltype-help)
                 (dest (tackon #installprogramdir #program))
                 (settooltype "DEVICE" (tackon "devs:networks" #device))
                 (confirm)
         )
      )
(complete 70)
      (if #catalogs
         (
            (set #mask 1)
            (set #installcatdir (tackon #installcatdir "Catalogs"))
            (set #catname (cat #program ".catalog"))
            (makedir #installcatdir)
            (foreach #catdir "#?"
               (
                  (if (AND #catalogs #mask)
                     (
                        (makedir (tackon #installcatdir @each-name))
(complete 75)
                        (copyfiles
                           (prompt (cat "Copying the \"" @each-name "\" catalog"))
                           (help @copyfiles-help)
                           (source (tackon (tackon #catdir @each-name) #catname))
                           (dest (tackon #installcatdir @each-name))
                           (confirm)
                        )
                     )
                  )
                  (set #mask (shiftleft #mask 1))
               )
            )
         )
      )
   )
)

(complete 80)

; ------------------------- Guide Installation --------------------------

; install AmigaGuide file
(if #installguide
   (
      (copyfiles
              (prompt "Copying AmigaGuide file")
              (help @copyfiles-help)
              (source (tackon #helpdir #helpfile))
              (dest #installhelpdir)
              (confirm)
      )
(complete 85)
      (copyfiles
              (prompt "Copying Icon")
              (help @copyfiles-help)
              (source (tackon
                    (if #magicwb #mwbicons #stdicons)
                    "AmigaGuide.info")
              )
              (dest #installhelpdir)
              (newname (cat #helpfile ".info"))
              (confirm)
      )
   )
)

(complete 100)

(user 2)
(message "\n\nInstallation completed!\n" @app-name " can be found in your \""
         #installprogramdir "\" drawer (or partition).\n\n"
         "You should view the tooltypes of \"" #program
         "\" to check whether they meet your configuration.\n\n"
         "Enjoy!"
)
(user #level)
(exit (quiet))

