;*********************************************************************************************
; Install-Script for the MovieDataBase V3.5
; (c) 1993, 94, 95, 96, 97 by Andre Bernhardt
;*********************************************************************************************

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

(message "WELCOME to the MovieDataBase V3.5.\n\n"
"This Installer-script expects that you have about 220 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")


(@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"))
(set tools              (tackon @default-dest "tools"))

(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)
)
(copyfiles
        (prompt "Copying all Binaries & Documentation ...")
        (help @copyfiles-help)
        (source "")
        (dest @default-dest)
        (pattern "~(MDB-#?|Installer|#?.info)")
        (infos)
        (files)
        (confirm)
)

(copyfiles
        (prompt "Copying all ARexx-Scripts ...")
        (help @copyfiles-help)
        (source "rexx/")
        (dest arexx)
        (all)
        (infos)
        (confirm)
)

(copyfiles
        (prompt "Copying all Tools ...")
        (help @copyfiles-help)
        (source "tools/")
        (dest tools)
        (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 "\nDo you want me to unpack the Listfiles?\nNote: you need to have 'lha' in your C: directory!")
                   (help @askfile-help)
                   (default 1)
   )
         (


            (set archivedir
               (askdir
                  (prompt "Where are the Internet Movie Database listfile archives?")
                  (help @askdir-help)
                  (default @default-dest)
                  (newpath)
               )
            )

            (set archives (tackon archivedir "#?.list.lha"))

            (set unpack (cat "c:lha x " archives " " 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 100 MB 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)
   )
)
