; XPKatana Installer Script
; $Ver: 1.0 (28.11.95)
; Written by Philip A. Vedovatti


(set #bad-kick
   (cat "\n\nSorry! You must have Workbench 2.0 or"
        "higher to to use this package."))

(set #hello-message
   (cat "\n\n\"Chop yer file sizes to bits!\""
        "\n\nWelcome to the XPKatana Installer Script."
        "\n\nPlease read the documentation to get the most out"
        "\nof this package."
        "\n\n\nCLICK TO PROCEED"))

(set #install-which
   (cat "\nWhich part(s) of the XPKatana archive would"
        "\nyou like to install onto your hard drive?\n"))

(set #tools-dest
   (cat "\nWhich drawer would you like the main"
        "\nXPKatana program to be installed?\n"))

(set #docs-dest
   (cat "\nWhere would you like the documentation"
        "\nto be installed?\n"))

(set #rexx-dest
   (cat "\nWhere would you like the Katana Arexx"
        "\nscripts to be installed?\n"))

(set #install-arexx-help
   (cat "\nThis installs the Arexx scripts to"
        "\nenhance XPKatana's functionality."))

(set #exit-message
   (cat "\nXPKatana is now fully installed!"
        "\nEnjoy."))

(set #install-library
   ("\nInstalling FileID.library to Libs:"))

; ------------------------------
; Check Kickstart Version
; ------------------------------

 (if (< (getversion "LIBS:version.library") (* 37 65536))
        (abort #bad-kick)
 )

(message #hello-message)

; ------------------------------
; What should I install?
; ------------------------------

(set InstallOpt
      (askoptions (prompt #install-which)
                  (help @askoptions-help)
                  (choices "XPKatana" "Arexx Scripts" "FileID.library"
                           "Documentation")
      )
)

(if (= InstallOpt 0)
      (abort (cat "\n\nInstallation Aborted :(")
                  "\n\nNo files selected to install!")
)


;-------------------------------------------------------
;Install binary, Icons, and support files
;-------------------------------------------------------


(if (BITAND InstallOpt 1)

  ((set destdir
      (askdir
            (prompt #tools-dest)
            (help @askdir-help)
            (default "Sys:Utilities")
      )
   )

   (set @default-dest destdir)
   (copyfiles
      (source "/XPKatana")
      (dest destdir)
      (infos)
   )
  )
)

;-------------------------------------------------------
;Insall Arexx scripts
;-------------------------------------------------------



(if (BITAND InstallOpt 2)

  ((set destdir
      (askdir
            (prompt #rexx-dest)
            (help #install-arexx-help)
            (default "REXX:")
      )
   )

   (copyfiles
      (source "/ARexx")
      (dest destdir)
      (all)
   )
  )
)

;-------------------------------------------------------
;Install FileID.library files
;-------------------------------------------------------

(if (BITAND InstallOpt 4)

  ((copylib
      (prompt #install-library)
      (source "/Libs/FileID.library")
      (dest "Libs:")
   )

   (if (exists "Locale:catalogs/deutsch")
       (copyfiles
          (source "/Locale/catalogs/deutsch/FileID_lib.catalog")
          (dest "Locale:catalogs/deutsch")
       )
   )
  )
)

;-------------------------------------------------------
;Install FileID.library files
;-------------------------------------------------------

(if (BITAND InstallOpt 8)

  ((set destdir
      (askdir
            (prompt #docs-dest)
            (help @askdir-help)
            (default "Help:")
      )
   )
   (copyfiles
      (source "/Docs/XPKatana.guide")
      (dest destdir)
      (newname "XPKatana.guide")
      (infos)
   )
  )
)
(exit #exit-message)