; $VER: Install-AB (21.4.96)
; Script to install AmigaBase V2.3

(complete 0)

;=============================================================================
; English strings

(if (= @language "english")
    (
        (set #transcript "Installation of AmigaBase V2.3.")

        (set #install-prompt "Choose installation:")
        (set #install-help
            (cat "The harddisk installation installs all files "
                 "in a seperate directory, while the floppy "
                  "installation creates a working disk.")
        )
        (set #install-hd "Harddisk installation")
        (set #install-floppy "Floppy installation")

        (set #dir-prompt
            (cat "Select disk/directory where AmigaBase should be installed. "
                 "The installation program automatically creates the directory "
                 "\"AmigaBase\" in this directory.")
        )
        (set #floppy-message
            (cat "The installation script assumes that you have already "
                "created a copy of your Workbench disk which has at "
                "least 100 kBytes free, rebooted your computer from "
                "that disk and formatted a new disk with name \"AmigaBase\".\n\n"
                "If not then please abort the installation now, "
                "do the steps above and restart the installation.\n\n"
                "The floppy installation will first copy all needed files "
                "to RAM:AmigaBase and then copy them to the disk."
            )
        )

        (set #exists-message
            (cat
               "You have already installed AmigaBase in this directory. "
               "If you continue the old installation will be overwritten!"
            )
        )

        (set #copy-ab-prompt "Copying AmigaBase.")

        (set #unpack-ab "Extracting AmigaBase...")

        (set #copy-textfiles "Copying text files.")

        (set #unpack-updates "Extracting Updates.lha...")

        (set #install-reqtools "Installing 'reqtools.library'.")

        (set #install-gadget "Installing 'gadget.library'.")

        (set #make-assign
            (cat
                "An assign instruction need to be added to the \"S:user-startup\" "
                "so that AmigaBase can be started by double clicking an "
                "AmigaBase project."
            )
        )

        (set #catalog-prompt "Which additional languages should AmigaBase support?")
        (set #catalog-help "The builtin language of AmigaBase is 'English'. ")

        (set #copy-examples "Copying optional examples.")

        (set #copy-mandel "Copying Mandel picture.")

        (set #copy-german-examples "Copying German example projects.")
        (set #copy-english-examples "Copying English example projects.")
        (set #unpack-archive "Extracting archive...")

        (set #floppy-ready
            (cat
                "All necessary files have been copied to RAM:AmigaBase. "
                "Please insert now the disk \"AmigaBase\"."
            )
        )

        (set #exit
            (cat
                "Note that you may need to reboot your computer "
                "if older versions of reqtools.library or gadget.library "
                "are still in memory."
            )
        )
    )
)

;=============================================================================
; German strings

(if (= @language "deutsch")
    (
        (set #transcript "Installation von AmigaBase V2.3.")

        (set #install-prompt "Bitte wählen Sie das Installations-Medium:")
        (set #install-help
            (cat "Die Festplatten-Installation kopiert alle Dateien "
               "in ein eigenes Verzeichnis, während die Disketten-Installation "
               "eine Arbeits-Diskette erstellt.")
        )
        (set #install-hd "Festplatten-Installation")
        (set #install-floppy  "Disketten-Installation")

        (set #dir-prompt
            (cat "Wählen Sie das Verzeichnis, in das AmigaBase installiert werden soll. "
                 "Das Installations-Programm legt hier automatisch das Verzeichnis "
                 "\"AmigaBase\" an.")
        )
        (set #floppy-message
            (cat "Das Installations-Programm nimmt an, daß Sie bereits "
                "eine Kopie Ihrer Workbench-Diskette mit mindestens "
                "100 kByte freiem Platz angelegt, von dieser Diskette "
                "neu gestartet und eine leere Diskette mit dem Namen "
                "\"AmigaBase\" formatiert haben.\n\n"
                "Falls dem nicht so ist, so brechen Sie bitte die Installation "
                "nun ab, führen die oben aufgeführten Anweisungen durch "
                "und starten die Installation neu.\n\n"
                "Die Disketten-Installation kopiert zuerst alle benötigten Dateien "
                "nach RAM:AmigaBase und kopiert diese dann auf die Diskette."
            )
        )

        (set #exists-message
            (cat
               "Sie haben AmigaBase bereits in diesem Verzeichnis installiert. "
               "Falls Sie fortfahren, so wird die alte Installation überschrieben!"
            )
        )

        (set #copy-ab-prompt "Kopiere AmigaBase.")

        (set #unpack-ab "Packe AmigaBase aus...")

        (set #copy-textfiles "Kopiere die Text-Dateien.")

        (set #unpack-updates "Packe Updates.lha aus...")

        (set #install-reqtools "Installiere die 'reqtools.library'.")

        (set #install-gadget "Installiere die 'gadget.library'.")

        (set #make-assign
            (cat
                "Ein \"Assign\"-Befehl sollte in die Datei \"S:User-Startup\" "
                "eingetragen werden, damit AmigaBase automatisch gestartet "
                "wird, wenn Sie ein AmigaBase-Projekt doppelt anklicken."
            )
        )

        (set #catalog-prompt "Welche zusätzlichen Sprachen soll AmigaBase unterstützen?")
        (set #catalog-help "Die eingebaute Sprache von AmigaBase ist englisch. ")

        (set #copy-examples "Kopiere optionale Beispielprojekte.")

        (set #copy-mandel "Kopiere Mandel-Bild.")

        (set #copy-german-examples "Kopiere deutsche Beispielprojekte.")
        (set #copy-english-examples "Kopiere englische Beispielprojekte.")
        (set #unpack-archive "Packe Archiv aus...")

        (set #floppy-ready
            (cat
                "Alle benötigten Dateien wurden nach RAM:AmigaBase kopiert. "
                "Bitte legen Sie nun die Diskette \"AmigaBase\" in ein Laufwerk."
            )
        )

        (set #exit
            (cat
                "Beachten Sie bitte, daß Sie Ihren Rechner eventuell "
                "neu starten müssen, falls sich noch ältere Versionen "
                "der reqtools.library oder der gadget.library im Speicher befinden."
            )
        )
    )
)

;=============================================================================
; BEGIN

(set OS_version (/ (getversion) 65536))
(set IsKick20 (>= OS_Version 36))

(transcript #transcript)

(set HD_Installation
    (=
        (askchoice
            (prompt #install-prompt)
            (help #install-help)
            (choices #install-hd #install-floppy)
            (default 0)
        )
        0
    )
)

(if HD_Installation
   (set AB_dest_parent
      (askdir
         (prompt #dir-prompt)
         (help @askdir-help)
         (default @default-dest)
      )
   )
   (
      (set AB_dest_parent "RAM:")
      (message #floppy-message)
   )
)

(set AB_dest (tackon AB_dest_parent "AmigaBase"))

(if HD_Installation
   (
      (set @default-dest AB_dest)

         (if (exists AB_dest)
            (message #exists-message)
         )
    )
)

(complete 5)

; Make dest directory and create icon
(makedir AB_dest)
(copyfiles
   (source "/AB_dir.icon")
   (dest AB_dest_parent)
   (newname "AmigaBase.info")
)

(complete 10)

;copy AmigaBase
(set packed (exists "/AmigaBase.lha"))
(if packed
   (set lha (expandpath "lha"))
)

(copyfiles
   (prompt #copy-ab-prompt)
   (help @copyfiles-help)
   (source (if packed "/AmigaBase.lha" "/AmigaBase"))
   (dest AB_dest)
   (infos)
   (confirm)
)

(if packed
   (
      (working #unpack-ab)
      (run ("cd \"%s\"\n\"%s\" x AmigaBase.lha\n delete AmigaBase.lha" AB_dest lha))
   )
)

(complete 15)

;copy some text files
(copyfiles
   (prompt #copy-textfiles)
      (help @copyfiles-help)
      (source "/")
      (dest AB_dest)
      (pattern "(ReadMe#?|LiesMich|BUGS|HISTORY|TODO|Updates#?|Reg_Form#?)")
      (infos)
      (confirm)
)

(complete 20)

(if (exists (tackon AB_dest "Updates.lha"))
    (
        (working #unpack-updates)
        (run ("cd \"%s\"\n\"%s\" x Updates.lha\n delete Updates.lha" AB_dest lha))
    )
)

(complete 30)

;copy reqtools.library
(copylib
   (prompt #install-reqtools)
   (help @copylib-help)
   (source
      (if IsKick20
         "/libs20/reqtools.library"
         "/libs13/reqtools.library"
      )
   )
   (dest "libs:")
   (confirm)
)

(complete 35)

;copy gadget.library
(copylib
   (prompt #install-gadget)
   (help @copylib-help)
   (source "/libs13/gadget.library")
   (dest "libs:")
   (confirm)
)

(complete 40)

(if HD_Installation
   (
      ;make AmigaBase assign in startup-sequence

      (startup "AmigaBase"
         (prompt #make-assign)
         (help @startup-help)
         (command (cat "assign AmigaBase: " AB_dest "\n"))
      )
      (if (exists AB_dest)
         (makeassign "AmigaBase" AB_dest)
      )
   )
)

(complete 50)

;copy catalog files
(if IsKick20
   (copyfiles
      (prompt #catalog-prompt)
      (help #catalog-help)
      (source "/Catalogs")
      (dest "LOCALE:Catalogs")
      (pattern "#?")
      (confirm)
   )
)

(complete 60)

;create "Data" directory
(makedir (tackon AB_dest "Data"))
(copyfiles
   (source "/Data.info")
   (dest AB_dest)
   (newname "Data.info")
)

(complete 70)

;copy optional examples
(set choice
   (askoptions
      (prompt #copy-examples)
      (help @askoptions-help)
      (choices "Deutsch" "English")
   )
)

(if choice
   (
      (set Data_dest (tackon AB_dest "Data"))

      (copyfiles
         (prompt #copy-mandel)
         (help @copyfiles-help)
         (source "/Data")
         (dest Data_dest)
         (choices "Graphics")
         (infos)
      )

      (set packed (exists "/Data/Deutsch.lha"))
      (if packed
         (set lha (expandpath "lha"))
      )

      (if (BITAND choice 1)
         (
            (copyfiles
               (prompt #copy-german-examples)
               (help @copyfiles-help)
               (source "/Data")
               (dest Data_dest)
               (choices (if packed "Deutsch.lha" "Deutsch"))
               (infos)
            )
            (if packed
               (
                  (working #unpack-archive)
                  (run ("cd \"%s\"\n\"%s\" x Deutsch.lha\n delete Deutsch.lha" Data_dest lha))
               )
            )
         )
      )
      (if (BITAND choice 2)
         (
            (copyfiles
               (prompt #copy-english-examples)
               (help @copyfiles-help)
               (source "/Data")
               (dest Data_dest)
               (choices (if packed "English.lha" "English"))
               (infos)
            )
            (if packed
               (
                  (working #unpack-archive)
                  (run ("cd \"%s\"\n\"%s\" x English.lha\n delete English.lha" Data_dest lha))
               )
            )
         )
      )
   )
)

(complete 80)

(if (NOT HD_Installation)
   (
      (askdisk
         (prompt #floppy-ready)
         (help @askdisk-help)
         (dest "AmigaBase")
      )
      (copyfiles
         (source AB_dest)
         (dest "AmigaBase:")
         (all)
      )
      (run "delete ram:AmigaBase ram:AmigaBase.info ALL QUIET FORCE")

      (set @default-dest "AmigaBase:")
   )
)

(complete 100)

(exit #exit)

