; EGS System 7.1 Installation utility

(message "Welcome to the EGS System 7.1\n"
         "This is not an official EGS Update. "
         "It is just a collection of free available "
         "EGS System 7 files and the older 6.2 installation. "
         "I've put the things together to make it easer to "
         "install System 7 to your machine. "
         "This Archive does not include any drivers except "
         "for Native Amiga and the EGSWB driver.\n\n"
         "EGS is (c)1992-94 Viona\n"
         "This archive was brought to you by Jürgen Schober\n"
         "enjoy ...")

(set opt
    (askoptions
        (prompt "choose files to install : \n")
        (choices "EGS-System7.1" "EGS-Tools" "EGS-Games" "EGS-Pictures")
        (default 15)
        (help @askoptions-help)
    )
)

(set Sys7  (BITAND opt 1))
(set Tools (BITAND opt 2))
(set Games (BITAND opt 4))
(set Pics  (BITAND opt 8))
; * install the system itself
(if Sys7
    (
        (set @dest (expandpath "sys:"))

        (copyfiles
            (prompt "Installing EGS System 7.1...")
        	(source "dh3:EGS-System")
            (pattern "(egs-sys#?|lha)")
            (dest   "ram:")
            (help   @copyfiles-help)
        )

        (set destination
            (askdir
                (prompt "Where should I put the EGS System 7.1 ?\n"
                        "(EGS Drawer will be created)")
                (help @askdir-help)
                (default @dest)
            )
        )

        (set destination (cat destination "EGS"))
        (set @egsdir destination)
        (run "lha x ram:egs-system.lha ram:")
        (delete "ram:egs-system.lha")
        (makedir destination
            (prompt "Make EGS Directory")
            (infos)
            (help @makedir-help)
        )

        (copyfiles
            (prompt "Copy files to " destination)
            (source "ram:EGS-System/")
            (pattern "~(Env-Archive|Env-Archive.info)")
            (dest destination)
            (infos)
            (help @copyfiles-help)
        )

        (copyfiles
            (prompt "copy the default settings into envarc:")
            (source "ram:EGS-System/Env-Archive/")
            (all)
            (dest "envarc:")
            (help @copyfiles-help)
        )
        (run "delete ram:EGS-Sys#? all")

;        (askdisk
;            (prompt "Please insert 'EGS-Storage' in any Driver.")
;            (assigns)
;            (dest "dh3:EGS-Storage")
;            (help @askdisk-help)
;        )

        (copyfiles
            (prompt "copy EGS-Storage.lha to ram:")
            (source "dh3:EGS-Storage/EGS-Storage.lha")
            (dest   "ram:")
            (help   @copyfiles-help)
        )
        (run "ram:lha x ram:egs-storage.lha ram:")
        (delete "ram:EGS-Storage.lha")
        (copyfiles
            (prompt "copy EGS-System 2 to EGS:")
            (source "ram:EGS-Storage")
            (all)
            (dest destination)
            (help @copyfiles-help)
        )
        (run "delete ram:EGS-Stor#? all")
        (copyfiles
            (source (cat destination "/Storage/Monitors/EGS"))
            (dest "devs:Monitors")
            (infos)
        )
        (run (cat "assign EGS: " destination))

        (if (= (exists (cat destination "/Startup") (noreq)) 0)
            (makedir (cat destination "/Startup"))
        )
        (if (= (exists (cat destination "/Storage/Border") (noreq)) 0)
            (makedir (cat destination "/Storage/Border"))
        )
        (if (= (exists (cat destination "/Storage/Driver") (noreq)) 0)
            (makedir (cat destination "/Storage/Driver"))
        )
        (if (= (exists (cat destination "/Config/Border") (noreq)) 0)
            (makedir (cat destination "/Config/Border"))
        )
    )
    (
        (exit)
    )
)
(if Games
    (
        (copyfiles
            (prompt "copy EGS-Games.lha to ram:")
            (source "dh3:EGS-Storage/EGS-Games.lha")
        (dest   "ram:")
        (help   @copyfiles-help)
        )

        (run "ram:lha x ram:egs-games.lha egs:")
        (delete "ram:egs-games.lha")
    )
)
(if Tools
    (
;        (askdisk
;            (prompt "Please insert 'EGS-Tools' in any Driver.")
;            (assigns)
;            (dest "dh3:EGS-Tools")
;            (help @askdisk-help)
;        )

        (copyfiles
            (prompt "copy EGS-Tools.lha to ram:")
            (source "dh3:EGS-Tools/EGS-Tools.lha")
            (dest   "ram:")
            (help   @copyfiles-help)
        )

        (run "ram:lha x ram:egs-tools.lha egs:")
        (delete "ram:egs-tools.lha")
    )
)
(if Pics
    (
;        (askdisk
;            (prompt "Please insert 'EGS-Pictures' in any Driver.")
;            (assigns)
;            (dest "dh3:EGS-Pictures")
;            (help @askdisk-help)
;        )

        (copyfiles
            (prompt "copy EGS-Pictures.lha to ram:")
            (source "dh3:EGS-Pictures/EGS-Pictures.lha")
            (dest   "ram:")
            (help   @copyfiles-help)
        )

        (run "ram:lha x ram:egs-pictures.lha egs:")
        (delete "ram:egs-pictures.lha")
    )
)
(if (exists "ram:lha" (noreq))
    (delete "ram:lha")
)
(message "\n\n\nPlease check out the path in the \"devs:Monitors/egs\" file !\n"
         "Change the EGS-path to \"assign EGS: " @egsdir "\" if needed !")

(set @default-dest @egsdir)
(exit)
