
/*********************************************************************************************
 *
 * installation script for the SavInstaller $VER: 0.8 (20.03.99)
 *
 * note, that this script makes use of seveal new features of the Savage-Installer
 * like multilined comments, the new builtin variable @system-language and the
 * enhanced pattern-match functionality of the DATABASE function
 *
 *********************************************************************************************/

(if (= @system-language "english")

    (
      (set #msg_welcome (cat "Welcome to the Installation of the Savage-Installer\n\n"
                             "The Savage-Installer wants to be a substitution of\n"
                             "the original Installer by C=\n"
                             "It offers many new features, looks much better and is\n"
                             "smaller than the C= Installer"
                        )
      )
      (set #msg_askfile_prompt "Where is the default Installer located?")
      (set #msg_askfile_help (cat "Please select the original Installer by C=. "
                                  "This script will make a backup copy of the "
                                  "Installer and then, it will replace the "
                                  "original by the new Savage-Installer."
                             )
      )
      (set #msg_copylib_prompt "Now copying the Savage-Installer to \"%s\"")
      (set #msg_copylib_help "")
      (set #msg_askbool_prompt (cat "Your prefered language is \"%s\"\n"
                                    "Do you want to install the related catalog (if it exists)?"
                               )
      )
      (set #msg_askbool_help "")
      (set #msg_done (cat "Done!\n"
                          "The Savage-Installer replaced the original Installer\n"
                          "and made a copy of the old one in \"%s\".\n\n"
                          "Have fun with the new Installer and its features"
                     )
      )
      (set #msg_rename_prompt "Now renaming the C= installer")
      (set #msg_rename_help "")

      (set #msg_copytools_prompt "Which additional tools you want to install? (see Help)")
      (set #msg_copytools_help "")

      (set #msg_tooltypes_prompt "Which Tooltypes you want to preset?")
      (set #msg_tooltypes_help "")

      (set #message_letsgo "Installation prepared. Ready to proceed?")
    )
)

(if (= @system-language "deutsch")

    (
      (set #msg_welcome (cat "Willkommen zur Installation des Savage-Installer\n\n"
                             "Der Savage-Installer soll ein Ersatz für den\n"
                             "originalen Installer von C= sein\n"
                             "Er bietet viele neue Eigenschaften, sieht viel besser aus\n"
                             "und ist kleiner als der C= Installer"
                        )
      )
      (set #msg_askfile_prompt "Wo befindet sich der Installer?")
      (set #msg_askfile_help (cat "Bitte wählen Sie den originalen Installer von C=. "
                                  "Dieses Skript macht eine Kopie des originalen "
                                  "Installers und wird danach den originalen durch "
                                  "den neuen Savage-Installer ersetzen."
                             )
      )
      (set #msg_copylib_prompt "Kopiere jetzt den Savage-Installer nach \"%s\"")
      (set #msg_copylib_help "")
      (set #msg_askbool_prompt (cat "Ihre eingestellte Sprache ist \"%s\"\n"
                                    "Wollen Sie einen entsprechenden Katalog (falls "
                                    "vorhanden) installieren?"
                               )
      )
      (set #msg_askbool_help "")
      (set #msg_done (cat "Fertig!\n"
                          "Der Savage-Installer hat Ihren originalen Installer\n"
                          "ersetzt und eine Kopie des alten als \"%s\" erzeugt.\n\n"
                          "Viel Spaß mit dem neuen Installer und seinen Möglichkeiten"
                     )
      )
      (set #msg_rename_prompt "Benenne nun den C= Installer um")
      (set #msg_rename_help "")

      (set #msg_copytools_prompt "Welche zusätzlichen Programme wollen Sie installieren?")
      (set #msg_copytools_help "")

      (set #msg_tooltypes_prompt "Welche Tooltypes möchten Sie voreinstellen? (siehe Hilfe)")
      (set #msg_tooltypes_help "")

      (set #message_letsgo "Installation vorbereitet. Soll nun weitergemacht werden?")
    )
)

/*********************************************************************************************/

(set @app-name "Savage-Installer")
(user expert)
(message #msg_welcome)
(welcome)
(complete 0)

; -----------------------------------------------------------------------------
; the default settings

(set #default_installer "c:installer"
     #default_localize 0
     #default_tools 0
     #default_tooltypes 0
)

; -----------------------------------------------------------------------------
; first of all let the user make all the required settings
; for the installation

(swing

  (set #default_installer (askfile (prompt #msg_askfile_prompt)
                                   (default #default_installer)
                                   (help #msg_askfile_help)
                          )
  )

  (set #default_localize (askbool (prompt (#msg_askbool_prompt @system-language))
                                  (help #msg_askbool_help)
                                  (default #default_localize)
                         )
  )

  (set #default_tools (askoptions (prompt #msg_copytools_prompt)
                                  (help #msg_copytools_help)
                                  (default #default_tools)
                                  (choices "CloseScreenPatch" "GetSum")
                      )
  )

  (set #default_tooltypes (askoptions (prompt #msg_tooltypes_prompt)
                                      (help #msg_tooltypes_help)
                                      (default #default_tooltypes)
                                      (choices "LAZYCOMPILE" "DEBUGMODE"
                                               "CREATEUNSINSTALL" "COPYFILESCOMMENT"
                                               "ALWAYSCONFIRM" "NOSYSDELETE"
                                      )
                          )
  )

  (message #message_letsgo)
)

; -----------------------------------------------------------------------------
; now the installation process itself

(set #installer_backup (cat #default_installer ".backup"))

(if (not (exists #installer_backup (noreq)))
    (
      (rename #default_installer #installer_backup (confirm average)
                                                   (prompt #msg_rename_prompt)
                                                   (help #msg_rename_help)
      )
    )
) 

(complete 20)

(copylib (prompt (#msg_copylib_prompt #default_installer))
         (help #msg_copylib_help)
         (confirm average)
         (source (if (database "cpu" "(68000|68010)")
                     ("c/installer000")
                     ("c/installer020")
                 )
         )
         (dest (pathonly #default_installer))
         (newname (fileonly #default_installer))
         (infos)
)

(complete 40)

(if #default_localize

    (
      (set #catalog_source (tackon (tackon "catalogs" @system-language) "savageinstaller.catalog"))
      (if (exists #catalog_source (noreq))
          (copyfiles (source #catalog_source)
                     (dest (tackon "locale:catalogs" @system-language))
          )
      )
    )
)

(complete 60)

(
  (if (bitand #default_tools 1)
      (
        (copyfiles (source "tools/GetSum")
                   (dest "C:")
        )
      )
  )

  (if (bitand #default_tools 2)
      (
        (copyfiles (source "tools/CloseScreenPatch")
                   (dest "C:")
        )
      )
  )
)

(complete 80)

(tooltype (dest #default_installer)
          (setstack 50000)
          (if (bitand #default_tooltypes  1) (settooltype "LAZYCOMPILE" "")
                                             (settooltype "(LAZYCOMPILE)" ""))
          (if (bitand #default_tooltypes  2) (settooltype "DEBUGMODE" "")
                                             (settooltype "(DEBUGMODE)" ""))
          (if (bitand #default_tooltypes  4) (settooltype "CREATEUNINSTALL" "")
                                             (settooltype "(CREATEUNINSTALL)" ""))
          (if (bitand #default_tooltypes  8) (settooltype "COPYFILECOMMENT" "")
                                             (settooltype "(COPYFILECOMMENT)" ""))
          (if (bitand #default_tooltypes 16) (settooltype "ALWAYSCONFIRM" "")
                                             (settooltype "(ALWAYSCONFIRM)" ""))
          (if (bitand #default_tooltypes 32) (settooltype "NOSYSDELETE" "")
                                             (settooltype "(NOSYSDELETE)" ""))
)

(complete 100)

(exit (#msg_done #installer_backup) (quiet))

