; UAE-App installer shit (c) 1999 by Hippie2000

(set @default-dest "")

(if (= (exists "ADF:" (noreq)) 0) (
        (abort
                 "Volume \"ADF:\" not found.\n\n"
                 "You must have mounted the volume \"ADF:\" before you run installation!\n"
                 "ADF: must be a native filesystem mounted directory, not a disk image!\n"
                 "Quit UAE, mount \"ADF:\" using the UAE-GUI and run this script again!\n"
        )
))

(set #hostpath
        (askstring
                (prompt "HOST-PATH variable:\n\n"
                        "Specify the path in your host filesystem\n"
                        "which you have mounted as volume \"ADF:\"\n\n"
                        "MUST END WITH A DELIMITER!\n\n"
                        "Example:    D:\\amiga\\adf\\")
                (help @askstring-help)
                (default (getenv "ENV:UAE-App/HOST-PATH") )
        )
)
(if (= #hostpath "") (
        (abort
                 "You did not specify HOST-PATH!\n\n"
                 "Run the script again and try to be more precise!\n"
        )
))

(set #hostslash
        (askstring
                (prompt "HOST-SLASH variable:\n\n"
                        "Specify the slash character your host filesystem uses\n"
                        "to divide directorynames from filenames within pathes.\n\n"
                        "MUST BE A SINGLE CHARACTER!\n\n"
                        "Example:    \\")
                (help @askstring-help)
                (default (getenv "ENV:UAE-App/HOST-SLASH") )
        )
)
(if (= #hostslash "") (
        (abort
                 "You did not specify HOST-SLASH!\n\n"
                 "Run the script again and try to be more precise!\n"
        )
))
(if (<> (strlen #hostslash) 1) (
        (abort
                 "HOST-SLASH can not be more than one character!\n\n"
                 "Run the script again and try to be more precise!\n"
        )
))


(if (<> (exists "ENV:UAE-App/BIN-PATH" (noreq)) 0) (
        (set #binpath (getenv "ENV:UAE-App/BIN-PATH") )
) (
        (set #binpath "C:" )
))
(if (<> (exists "C:UA" (noreq)) 0) (
        (set #quitapp "C:UA quitapp" )
) (
        (set #quitapp "Sys:WBStartup/UAE-App quitapp" )
))
(run #quitapp
        (prompt "I will now shut down your old UAE-App server!\n(if it is running)")
        (help "No help for this function")
        (confirm)
)
(delete "Sys:WBStartup/UAE-App" (infos))



(if (<> (exists "3rdparty" (noreq)) 0) (
         (copyfiles
                  (prompt "I will now install UAE-App\nand all 3rdparty executables")
                  (help @copyfiles-help)
                  (source "")
                  (dest #binpath)
                  (choices "bin/ua" "docs/uae-app.guide" "docs/uae-app.readme" "3rdparty/gzip" "3rdparty/unzip" "3rdparty/xdms")
                  (confirm)
         )
         (copylib
                  (prompt "I will now install \"ixemul.library\" to Libs:")
                  (help @copylib-help)
                  (source "3rdparty/ixemul.library")
                  (dest "libs:")
                  (confirm)
         )
) (
         (copyfiles
                  (prompt "I will now install UAE-App")
                  (help @copyfiles-help)
                  (source "")
                  (dest #binpath)
                  (choices "bin/ua" "docs/uae-app.guide" "docs/uae-app.readme")
                  (confirm)
         )
))



(if (= @user-level 2) (
        (message   "I will now create the environment variables")
))

(set #amigapath "ADF:")

(makedir   "Envarc:UAE-App")
(copyfiles (source "icons")    (dest "Envarc:UAE-App") (all) )
(textfile  (append #hostpath)  (dest "Envarc:UAE-App/HOST-PATH") )
(textfile  (append #hostslash) (dest "Envarc:UAE-App/HOST-SLASH") )
(textfile  (append #amigapath) (dest "Envarc:UAE-App/AMIGA-PATH") )
(textfile  (append #binpath)   (dest "Envarc:UAE-App/BIN-PATH") )

(makedir   "Env:UAE-App")
(copyfiles (source "Envarc:UAE-App") (dest "Env:UAE-App") (all) )


(startup "UAE-App"
         (prompt "I will now modify \"S:User-Startup\",\nUAE-App will be launched from there in future.")
         (help "No help for this function")
         (command "c:run <NIL: >NIL: C:ua startup\n")
)

(run "c:run <NIL: >NIL: C:ua startup"
        (prompt "I will now run the UAE-App server!")
        (help "No help for this function")
        (confirm)
)

