;
;                       PalmBackup © 1998-1999 W.F.M.H.
;
;           ---------------------------------------------------------
;
;              ###    ###    #########  ###    ###    ###    ###
;              ###    ###    ###        ####  ####    ###    ###
;              ###    ###    ###        ### ## ###    ###    ###
;              ###    ###    ########   ### ## ###    ##########
;              ### ## ###    ########   ###    ###    ##########
;              ### ## ###    ###        ###    ###    ###    ###
;              ####  #### ## ###     ## ###    ### ## ###    ### ##
;              ###    ### ## ###     ## ###    ### ## ###    ### ##
;
;           ---------------------------------------------------------
;
;                              W.F.M.H.
;                              ul. Radomska 38
;                              71-002 Szczecin
;                              Poland
;
;                              tel. ++48 91 4836425
;
;                      Internet:   carlos@amiga.com.pl
;                      WWW     :   http://amiga.com.pl
;
;--------------------------------------------------------------------
;
;             W.F.M.H. PalmBackup 1.0 - Installer script
;           Written by Marcin Orlowski <carlos@amiga.com.pl>
;
;--------------------------------------------------------------------
;
; $VER: WFMH PalmBackup - Installer 1.0 (26.02.99) © Marcin Orlowski
;
;--------------------------------------------------------------------

;/// Presets
(set _debug 0)

(set __version  1)
(set __revision 0)
(set __date "26.02.1999")

(set __destdir "PalmBackup/")
(set __src     "/")
;//|

;/// English strings - default

;************************ DEFAULT ENGLISH STRINGS ************************

(set msg_err_dizzy            "Unexpected error occured! Instalation aborted.")
(set msg_err_cleanup          "Installation aborted. Cleaning up")
(set msg_err_wrongos          "\n\nPalmBackup requires at least OS 2.0 or later to run")
(set msg_err_request          "\n\nInstallation aborted at user request")

(set msg_copyrights           "This is a shareware product!\n\nCopyright © 1998-1999 W.F.M.H.\n\nAll rights reserved")

(set msg_installdir           "Where do you want to install PalmBackup?\nDrawer \"%s\" will be created there.")
(set msg_installdir_help      "Please select the directory you want PalmBackup to be installed in. A new drawer named \"%s\" will be automatically created there, and ALL NECESSARY files belong to PalmBackup will be placed in that directory.")
(set msg_err_destfile         "\nCan't create directory \"%s\" because a file with that name already exists here. Remove it manually or chose another destination drawer. Aborting installation...")
(set msg_destdir_over         "\nYour destination drawer\n\n\"%s\"\n\nalready exists!\n\nDo you really want to continue?\nRefer to help text for more information.")
(set msg_destdir_over_help    "The destination directory you just selected is already present on your hard drive. Make the choice if you really want to install PalmBackup over existing files.\n\nPressing \"%s\" will contine the instalation and PalmBackup will be installed in the drawer you chose. Pressing \"%s\" will abort the installation - nothing will be installed.")
(set msg_destdir_button_yes   "Continue")
(set msg_destdir_button_no    "Abort")

(set msg_sure                 "\n\n\nPalmBackup will be installed on your hard drive in drawer:\n\n\"%s\"\n\nDo you want to proceed?")

(set msg_copy_fonts           "\n\nCopying required fonts...\n\nStay tuned, your FONTS: won't be affected...")
(set msg_copy_libs            "\n\nCopying required libraries...\n\nStay tuned, your LIBS: won't be affected...")
(set msg_update_libs          "\n\nUpdating required libraries...")
(set msg_copy_data            "\n\nCopying required data files...\n\nStay tuned...")
(set msg_copy_binaries        "\n\nInstalling program executable file...\n\nStay tuned...")

(set _def_alt_lang 0)

;//|
;/// German strings
;**************************** GERMAN STRINGS *****************************

(if (= @language "deutsch")
 (
  (set _language_version 0)
  (set _def_alt_lang 1)

  (set msg_err_dizzy            "Unerwarteter Fehler aufgetreten! Installation abgebrochen.")
  (set msg_err_cleanup          "Installation abgebrochen. Neuaufbau...")
  (set msg_err_wrongos          "\n\nPalmBackup benötigt zum Starten mindestens OS 2.0 oder besser")
  (set msg_err_request          "\n\nInstallation nach Anwendereingabe abgebrochen")

  (set msg_copyrights           "Dies ist ein shareware Produkt!\n\nCopyright © 1998-1999 W.F.M.H.\n\nAlle Rechte reserviert")

  (set msg_installdir           "Wohin möchten Sie PalmBackup installieren?\nEine Schublade \"%s\" wird hier erstellt.")
  (set msg_installdir_help      "Bitte wählen Sie das Verzeichnis aus, wohin PalmBackup installiert werden soll. Ein neuer Ordner namens \"%s\" wird dort automatisch angelegt und alle zum Starten von PalmBackup BENÖTIGTEN Dateien werden dort abgelegt.")
  (set msg_err_destfile         "\nKonnte das Verzeichnis \"%s\" nicht anlegen, weil bereits eine Datei mit diesem Namen hier existiert. Entfernen Sie sie manuell oder wählen Sie ein anderes Zielverzeichnis. Abbruch der Installation...")
  (set msg_destdir_over         "\nIhr Zielverzeichnis \n\n\"%s\"\n\n existiert bereits!\n\nMöchten Sie wirklich fortfahren?\nSehen Sie in den Hilfe-Text für weitere Informationen.")
  (set msg_destdir_over_help    "Das von Ihnen ausgewählte Zielverzeichnis wurde bereits auf der Festplatte angelegt. Entscheiden Sie sich, ob PalmBackup wirklich über existierende Dateien installiert werden soll.\n\nDas Drücken von \"%s\" setzt die Installation fort und PalmBackup wird in das von Ihnen ausgewählte Verzeichnis installiert. Drücken Sie \"%s\" , um die Installation abzubrechen - nichts wird dann installiert.")
  (set msg_destdir_button_yes   "Fortfahren")
  (set msg_destdir_button_no    "Abbrechen")

  (set msg_sure                 "\n\n\nPalmBackup wird auf Ihrer Festplatte im Verzeichnis:\n\n\"%s\"\n\n installiert. Möchten Sie fortfahren?")

  (set msg_copy_libs            "\n\nKopieren der benötigten Libraries...\n\nKeine Sorge, Ihr Verzeichnis LIBS: wird nicht berührt...")
  (set msg_update_libs          "\n\nAktualizieren der benötigten Libraries...")
  (set msg_copy_data            "\n\nKopieren der benötigten Daten...\n\nKeine Sorge...")
  (set msg_copy_binaries        "\n\nInstallieren des Hauptprogramms...\n\nKeine Sorge...")

 )
)
;//|
;/// Polish strings

;**************************** POLISH STRINGS *****************************

(if (= @language "polski")
 (
  (set _language_version 1)
  (set _def_alt_lang 1)

  (set msg_err_dizzy            "Wystāpiī niespodziewany bīād! Instalacja przerwana.")
  (set msg_err_cleanup          "Instalacja przerwana. Koļczė pracė")
  (set msg_err_wrongos          "\n\nPalmBackup wymaga co najmniej systemu w wersji OS 2.0")
  (set msg_err_request          "\n\nInstalacja przerwana na ūādanie uūytkownika")

  (set msg_copyrights           "To jest program komercyjny!\n\nCopyright © 1998-1999 W.F.M.H.\n\nWszelkie prawa zastrzeūone")

  (set msg_installdir           "Gdzie chcesz zainstalowaź program PalmBackup?\nKatalog \"%s\" zostanie utworzony.")
  (set msg_installdir_help      "Wybierz proszė katalog, w którym chcesz zainstalowaź program PalmBackup. Nowy podkatalog \"%s\" zostanie automatycznie utworzony, i wszystkie NIEZBĖDNE pliki zostanā w nim umieszczone.")
  (set msg_err_destfile         "\nNie mogė utworzyź katalogu \"%s\" poniewaū plik o takiej nazwie juū tu istnieje. Usuļ go rėcznie lub wybierz inny katalog docelowy. Instalacja przerwana.")
  (set msg_destdir_over         "\nKatalog docelowy\n\n\"%s\"\n\njuū istnieje!\n\nNa pewno chcesz kontynuoowaź?\nSzczegóīy znajdziesz w tekscie pomocy.")
  (set msg_destdir_over_help    "Katalog w którym chcesz zainstalowaź PalmBackupa juū istnieje na Twoim dysku. Zdecyduj, czy chcesz zainstalowaź w nim PalmBackupa.\n\nJeōli wybierzesz \"%s\", instalacja bėdzie kontynuowana i program zostanie zainstalowany w tym katalogu (pliki o nazwach identycznych z instalowanymi zostanā przez nie zastāpione). Jeōli chcesz przerwaź instalacjė, wybierz \"%s\" - nic nie zostanie w takim przypadku zainstalowane.")
  (set msg_destdir_button_yes   "Kontynuuj")
  (set msg_destdir_button_no    "Przerwij")

  (set msg_sure                 "\n\n\nPalmBackup bėdzie zainstalowany na Twoim dysku w katalogu:\n\n\"%s\"\n\nNa pewno chcesz kontynuowaź?")

  (set msg_copy_libs            "\n\nKopiujė niezbėdne biblioteki...\n\nSpokojnie, Twój katalog LIBS: pozostanie nienaruszony...")
  (set msg_update_libs          "\n\nAktualizujė niezbėdne biblioteki...")
  (set msg_copy_data            "\n\nKopiujė niezbėdne pliki danych...\n\nProszė czekaź...")
  (set msg_copy_binaries        "\n\nInstalujė program...\n\nProszė czekaź...")

 )
)

;//|
;/// Italian strings
;**************************** ITALIAN STRINGS *****************************

(if (= @language "italiano")
 (
  (set _language_version 2)
  (set _def_alt_lang 1)

  (set msg_err_dizzy            "Si č verificato un errore imprevisto! Installazione interrotta.")
  (set msg_err_cleanup          "Installazione interrotta. Ripristino i file.")
  (set msg_err_wrongos          "\n\nPalmBackup richiede AmigaOS 2.0 o superiore per funzionare.")
  (set msg_err_request          "\n\nInstallazione interrotta su richiesta dell'utente.")

  (set msg_copyrights           "Questo č un prodotto shareware!\n\nCopyright © 1998-1999 W.F.M.H.\n\nTutti i diritti riservati.")

  (set msg_installdir           "Dove volete installare PalmBackup?\nSarą creato un cassetto \"%s\" nella locazione scelta.")
  (set msg_installdir_help      "Scegliete la directory in cui volete che PalmBackup sia installato. Sarą automaticamente creato un nuovo cassetto di nome \"%s\" nella locazione scelta, e TUTTI i file di PalmBackup saranno copiati in quel cassetto.")
  (set msg_err_destfile         "\nNon posso creare la directory \"%s\" perché esiste gią un file con quel nome nella locazione scelta. Cancellatelo manualmente oppure scegliete un'altra directory di destinazione. Installazione interrotta...")
  (set msg_destdir_over         "\nIl cassetto di destinazione\n\n\"%s\"\n\nesiste gią!\n\nVolete veramente continuare?\nFate riferimento al testo d'aiuto per maggiori informazioni.")
  (set msg_destdir_over_help    "La directory di destinazione che avete appena selezionato č gią presente sul vostro disco rigido. Scegliete se volete davvero installare PalmBackup sovrascrivendo i file esistenti.\n\nPremendo \"%s\" continuerete l'installazione ed PalmBackup sarą installato nel cassetto da voi scelto. Premendo \"%s\" interromperete l'installazione - niente sarą installato.")
  (set msg_destdir_button_yes   "Continua")
  (set msg_destdir_button_no    "Annulla")

  (set msg_sure                 "\n\n\nPalmBackup sarą installato sul vostro disco rigido nel cassetto:\n\n\"%s\".\n\nVolete continuare?")

  (set msg_icon                 "Saranno ora impostati i parametri di icona del programma.")
  (set msg_icon_help            "Saranno ora impostati i parametri di icona del programma. NON saltate questa parte, altrimenti PalmBackup non funzionerą dopo l'installazione!")

  (set msg_copy_libs            "\n\nCopio le librerie necessarie...\n\nAttendere prego, la vostra directory LIBS: non sarą modificata...")
  (set msg_update_libs          "\n\nAggiorno le librerie necessarie......")
  (set msg_copy_data            "\n\nCopio i file dati necessari...\n\nAttendere prego...")
  (set msg_copy_binaries        "\n\nInstallo il file eseguibile del programma...\n\nAttendere prego...")

 )
)
;//|

;/// OnError

;###########################################################################
;## OnError
;###########################################################################

(onerror
    (working msg_err_cleanup)
    (P_CleanUp)
)
;//|
;/// Bug
;###########################################################################
;## Bug
;###########################################################################

(procedure bug #tekst  (if (> _debug 0) (message #tekst (all))))

;//|

;/// P_CleanUp

;###########################################################################
;## P_CleanUp
;###########################################################################

(procedure P_CleanUp

)
;//|
;/// P_Makedir
;###########################################################################
;## P_Makedir
;###########################################################################

(procedure P_Makedir #katalog

    (if (= (exists #katalog) 0)
       (
        (makedir #katalog)
       )
    )
)
;//|

;/// Preparing...
;###########################################################################
;## Preparing...
;###########################################################################

(bug "\n\nDebug is ON!")


(message "\n\n\nW.F.M.H. PalmBackup " __version  "."  __revision "\n\n"
         msg_copyrights
)

(complete 0)




(set OS_Version (/ (getversion "exec.library" (resident)) 65536))

(if (<  OS_Version 36) (abort msg_err_wrongos))
(if (<= OS_Version 38) (set _os 0))
(if (>= OS_Version 39) (set _os 1))

;###########################################################################
;## Ask where shall we put the files?
;###########################################################################

(set @default-dest "Work:")
(set @default-dest (askdir (prompt  (msg_installdir __destdir))
                           (help    (msg_installdir_help __destdir))
                           (default @default-dest)
                   )
)
(set @default-dest (tackon @default-dest __destdir))

(bug (cat "DestDir: " @default-dest))

;//|
;/// R U sure?

;###########################################################################
;## R U sure?
;###########################################################################

(message (msg_sure @default-dest) (all))

;//|

;/// De szou mast gou on...

;###########################################################################
;## De szou mast gou on...
;###########################################################################

(complete 0)


;###########################################################################
;## Let's check if there's nothing with that name...
;###########################################################################


(if (= (exists @default-dest) 0)
    (
     (makedir @default-dest (infos))
    )

;  else

    (
     (if (= (exists @default-dest) 1)
      (
       (abort (msg_err_destfile @default-dest))
      )

;    else

      (if (= (exists @default-dest) 2)
       (
        (set _user (user 2))
        (if (= (askbool (prompt (msg_destdir_over @default-dest)) (help (msg_destdir_over_help msg_destdir_button_yes msg_destdir_button_no)) (choices msg_destdir_button_yes msg_destdir_button_no)) 0)
           (abort msg_err_request)
                )
                (user _user)
       )
;    else
       (
        (abort msg_err_dizzy)
       )
      )
     )
    )
)

;###########################################################################
;## Let's make some necesary drawers
;###########################################################################

(complete 10)

(P_Makedir (tackon @default-dest "Catalogs"))
(P_Makedir (tackon @default-dest "Images"))

;###########################################################################
;## Let's copy libs we need... We won't touch your LIBS: if not needed...
;###########################################################################

(complete 20)

(set #palmlink_name "palmlink.library")
(set #dest_libs     "LIBS:")
(set #src_libs      (tackon __src ""))

(set _palmlink_2_libs 0)


(if (= (exists "LIBS:palmlink.library" (noreq)) 1) (set _palmlink_2_libs 1))

(if (= (+ _palmlink_2_libs) 0)
    (working msg_copy_libs)
; else
    (working msg_update_libs)
)

;/// Let's play with palmlink.library

(set #old_library (tackon #dest_libs #palmlink_name))
(set #new_library (tackon #src_libs  #palmlink_name))

(if (= _palmlink_2_libs 0)
    (
     (bug (cat "\n\nNo " #palmlink_name " in LIBS: found..."))
     (copyfiles
        (source #new_library)
        (dest   @default-dest)
        (nogauge)
     )
    )
; else
    (
     (set _old_version (getversion #old_library))
     (set _new_version (getversion #new_library))

     (bug (cat "\n\nChecking version of " #palmlink_name ":\n\nOld:" _old_version "\nNew:" _new_version))

     (if (> _new_version _old_version)
          (
           (bug (cat "\n\nUpdating " #palmlink_name "..."))

           (rename #old_library (cat #old_library "." (getsum #old_library)))
           (copyfiles
             (source #new_library)
             (dest   "LIBS:")
             (nogauge)
           )
          )
;       else
          (
           (bug (cat "\n\n" #palmlink_name " is up to date..."))
          )
     )
    )
)
;//|


;###########################################################################
;## Data files
;###########################################################################

(complete 30)
(working msg_copy_data)

(copyfiles
    (source (tackon __src "Images"))
    (dest   (tackon @default-dest "Images"))
    (all)
    (nogauge)
)

;###########################################################################
;## Guide and docs follow...
;###########################################################################

(complete 40)
(working)

(copyfiles
    (source  __src)
    (dest    @default-dest)
	(pattern "PalmBackup.#?")
    (nogauge)
)

;###########################################################################
;## Catalogs...
;###########################################################################

(complete 50)
(working)

(copyfiles
    (source  (tackon __src "Catalogs"))
    (dest    (tackon @default-dest "Catalogs"))
	(all)
    (nogauge)
)

;###########################################################################
;## MUI classes follow...
;###########################################################################

(complete 70)
(working msg_copy_binaries)
(set _mui_dest "MUI:Libs/MUI/")

(copylib
    (source  "/MUI/File.mcc")
    (dest    _mui_dest)
    (nogauge)
)

(copylib
    (source  "/MUI/NewDirlist.mcc")
    (dest    _mui_dest)
    (nogauge)
)
(copylib
    (source  "/MUI/NewDirlist.mcp")
    (dest    _mui_dest)
    (nogauge)
)

;###########################################################################
;## Binaries follow...
;###########################################################################

(complete 80)
(working msg_copy_binaries)

(set _bin_src (tackon __src "PalmBackup"))

(copyfiles
    (source  _bin_src)
    (dest    @default-dest)
    (nogauge)
)

;###########################################################################
;## Seems it's over...
;###########################################################################

(complete 100)

(exit)

;//|
