;*********************************************************************************************
; Install-Script for the MovieDataBase V3.0
; (c) 21.07.1994 by Andre Bernhardt
;*********************************************************************************************

(if (< (/ (getversion) 65536) 37)
  (abort "This program requires Kickstart 2.04 or greater to run !")
)

(message "WELCOME to the MovieDataBase V3.0.\n\n"
"This Installer-script expects that you have about 37 MByte available on your harddisc.\n"
"If this is not the case read the Manual!\n\n"
"Please read the Documentation before you install the MovieDataBase anyway!")

(message "IMPORTANT!!!\n\nYou do have to install the MagicUserInterface (MUI) "
"first to work with the GUI of the MovieDataBase. (Refer to the docs about that)\n\n"
"If you want this script to completely install the database, ARexx has be installed on your System.\n"
"You should install AmigaGuide if you want to use the Online Help System.\n\n"
"One more thing...\n"
"If you have already installed an older Version of the MovieDatabase, you should delete it first.")


(@default-dest "SYS:")

(set destdir
  (askdir
    (prompt "Select where to install the MovieDataBase\nA directory 'MovieDataBase' will be created automatically.")
    (help @askdir-help)
    (default @default-dest)
    (newpath)
  )
)

(set @default-dest      (tackon destdir "MovieDataBase"))
(set arexx              (tackon @default-dest "rexx"))

(transcript "On making \"MovieDataBase\"...")

;******************************************************************************
;****   First create the main directory and copy files and scripts and docs
;******************************************************************************

(makedir @default-dest
        (prompt "\ncreating directory 'MovieDataBase' ...")
        (help @makedir-help)
        (infos)
        (confirm)
)
(makedir arexx
        (prompt "\ncreating directory 'MovieDataBase/rexx' ...")
        (help @makedir-help)
        (infos)
        (confirm)
)

(copyfiles
        (prompt "Copying all Binaries & Documentation ...")
        (help @copyfiles-help)
        (source "")
        (dest @default-dest)
        (pattern "MovieMUI#?")
        (infos)
        (files)
        (confirm)
)
(copyfiles
        (prompt "Copying all ARexx-Scripts ...")
        (help @copyfiles-help)
        (source "rexx/")
        (dest arexx)
        (all)
        (infos)
        (confirm)
)

;******************************************************************************
;****   Now create the lists/ and dbs/ directories
;******************************************************************************

(set lists
  (askdir
    (prompt "Select where to put the raw listfiles\nA directory 'lists' will be created automatically.")
    (help @askdir-help)
    (default @default-dest)
    (newpath)
  )
)

(set listsdir (tackon lists "lists"))

(makedir listsdir
        (prompt "\ncreating directory 'lists' ...")
        (help @makedir-help)
        (infos)
        (confirm)
)

; Jetzt das DBS-Verzeichnis

(set dbs
  (askdir
    (prompt "Select where to install the database files\nA directory 'dbs' will be created automatically.")
    (help @askdir-help)
    (default @default-dest)
    (newpath)
  )
)

(set dbsdir (tackon dbs "dbs"))

(makedir dbsdir
        (prompt "\ncreating directory 'MovieDataBase/dbs' ...")
        (help @makedir-help)
        (infos)
        (confirm)
)

;******************************************************************************
;****   Uncompress the Datafiles
;******************************************************************************

(
 (if (askbool (prompt "\nThere are three Data-Archives available (approx. 8MB LhA-packed...)\n\nDo you want to unpack the 1st Data-Archive?")
                   (help @askfile-help)
                   (default 1)
     )
     (
      (set data (askfile (prompt "\n" "Please show me your Datafile...")
                          (help @askfile-help)
                          (default "mdb3_0_data1.lha")
                )
      )

      (set unpack (cat "c:lha x " data " " listsdir "/"))
      (working unpack)
      (run unpack)
     )
 )
)

(
 (if (askbool (prompt "\nDo you want to unpack the 2nd Data-Archive?")
                   (help @askfile-help)
                   (default 1)
     )
     (
      (set data (askfile (prompt "\n" "Please show me your Datafile...")
                          (help @askfile-help)
                          (default "mdb3_0_data2.lha")
                )
      )

      (set unpack (cat "c:lha x " data " " listsdir "/"))
      (working unpack)
      (run unpack)
     )
 )
)

(
 (if (askbool (prompt "\nDo you want to unpack the 3rd Data-Archive?")
                   (help @askfile-help)
                   (default 1)
     )
     (
      (set data (askfile (prompt "\n" "Please show me your Datafile...")
                          (help @askfile-help)
                          (default "mdb3_0_data3.lha")
                )
      )

      (set unpack (cat "c:lha x " data " " listsdir "/"))
      (working unpack)
      (run unpack)
     )
 )
)

;******************************************************************************
;****  Now ask if the database shall be installed immediately
;******************************************************************************

(set #mdb-install-help
  (cat "In order to be able to access the MovieDataBase, the listfiles "
       "have to be transformed in another format. You can do this now "
       "by clicking 'YES' or you'll have to do it later manually. \n"
       "Please refer to the docs for more information.\n")
)

(if (askbool
   (prompt "\n" "Shall I process the Data now (needs about 18MB diskspace)?")
      (help #mdb-install-help)
      (default 1)
      (choices "Yes" "No, I'll do it manually.")
   )
   (
      (set mdb_install (cat "MDB-Install-Support " listsdir " " dbsdir))
      (execute mdb_install)
   )
)
