;
; Installer script for ABackup installation
; $VER: Install_ABackup v36.3 (18.1.97)
;
;********* Initialisations ****************************************************
;
(set MainDir    	"")
(set PrefDir    	"")
(set DefPrefDir 	"SYS:Prefs")
(set SourceDir  	"/")
(set XPKSourceDir       (tackon SourceDir "libs/compressors"))
(set TmpFile    	(cat "T:RunABPrefs_" (database "total-mem")))
;
;********* Setup all the messages *********************************************
;
(procedure SetupMessages (
  (set DefHelpDir       (tackon "HELP:" @language))
  (set DefCatalogDir    (tackon "LOCALE:Catalogs" @language))

  (if (= @language "english")
    (
      (set #InstallWhat 	"What do you want to install ?")
      (set #InstallChoice1      "Main program")
      (set #InstallChoice1b     "Main program - 68060 version")
      (set #InstallChoice2      "Preferences program")
      (set #InstallChoice3      "Online help")
      (set #InstallChoice4      "XPK libraries")
      (set #InstallChoice5      "")
      (set #SelectMainDir       "Select the directory where to copy the Main program.")
      (set #CopyingMainProg     "Copying the Main program...")
      (set #SelectPrefDir       "Select the directory where to copy the Prefs program.")
      (set #BadPrefDir  	"Sorry, the Main program and the Prefs program can't be installed in the same directory !")
      (set #CopyingPrefProg     "Copying the Prefs program...")
      (set #UpdateMainTT1       "Updating the %s tooltype of the Main program...")
      (set #UpdateMainTT2       "Don't forget to update the %s tooltype of the Main program.")
      (set #UpdateMainTTH1      "This will allow the Main program to call the Prefs program.")
      (set #UpdateMainTTH2      "This will allow the Main program to find the help file.")
      (set #UpdatePrefTT1       "Updating the %s tooltype of the Prefs program...")
      (set #UpdatePrefTT2       "Don't forget to update the %s tooltype of the Prefs program.")
      (set #UpdatePrefTTH2      "This will allow the Prefs program to find the help file.")
      (set #SelectHelpDir       "Select the directory where to copy online help.")
      (set #CopyingHelp 	"Copying online help...")
      (set #SelectXPKDir	"Select the directory where to copy XPK libraries.")
      (set #CopyingXPK  	"Copying XPK libraries...")
      (set #SelectCatalogDir    "Select the directory where to copy the catalog file.")
      (set #CopyingCatalog      "Copying catalog file...")
      (set #RunPrefProg 	"Run the Pref program.")
      (set #RunPrefHelp 	"This will allow you to setup the ABackup Preferences.")
      (set #Shareware1  	"ABackup is a SHAREWARE program !")
      (set #Shareware2  	"If you like it and use it, a contribution of US $20 is asked.")
      (set #Shareware3  	"Please read the 'Diffusion' section of the documentation, for more details")
    )
  )
  (if (= @language "français")
    (
      (set #InstallWhat 	"Que voulez-vous installer ?")
      (set #InstallChoice1      "Programme principal")
      (set #InstallChoice1b     "Programme principal - Version 68060")
      (set #InstallChoice2      "Programme de paramétrage")
      (set #InstallChoice3      "Aide en ligne")
      (set #InstallChoice4      "Bibliothèques XPK")
      (set #InstallChoice5      "Catalogue")
      (set #SelectMainDir       "Indiquez dans quel répertoire installer le programme principal.")
      (set #CopyingMainProg     "Copie du programme principal...")
      (set #SelectPrefDir       "Indiquez dans quel répertoire installer le programme de paramétrage.")
      (set #BadPrefDir  	"Désolé, le programme principal et le programme de paramétrage ne peuvent être installés dans le même répertoire !")
      (set #CopyingPrefProg     "Copie du programme de paramétrage...")
      (set #UpdateMainTT1       "Mise à jour du type d'outil %s du programme principal...")
      (set #UpdateMainTT2       "N'oubliez pas de mettre à jour le type d'outil %s du programme principal.")
      (set #UpdateMainTTH1      "Ceci permettra au programme principal d'appeller le programme de paramétrage.")
      (set #UpdateMainTTH2      "Ceci permettra au programme principal de trouver le fichier d'aide.")
      (set #UpdatePrefTT1       "Mise à jour du type d'outil %s du programme de paramétrage...")
      (set #UpdatePrefTT2       "N'oubliez pas de mettre à jour le type d'outil %s du programme de paramétrage.")
      (set #UpdatePrefTTH2      "Ceci permettra au programme de paramétrage de trouver le fichier d'aide.")
      (set #SelectHelpDir       "Indiquez dans quel répertoire installer les fichiers d'aide.")
      (set #CopyingHelp 	"Copie des fichiers d'aide...")
      (set #SelectXPKDir	"Indiquez dans quel répertoire installer les bibliothèques XPK.")
      (set #CopyingXPK  	"Copie des bibliothèques XPK...")
      (set #SelectCatalogDir    "Indiquez dans quel répertoire installer le fichier catalogue.")
      (set #CopyingCatalog      "Copie du fichier catalogue...")
      (set #RunPrefProg 	"Appel du programme de paramétrage.")
      (set #RunPrefHelp 	"Ceci vous permettra de paramétrer ABackup.")
      (set #Shareware1  	"ABackup est un programme SHAREWARE !")
      (set #Shareware2  	"Si vous l'utilisez et l'appréciez, une contribution de 100 FF est demandée.")
      (set #Shareware3  	"Reportez-vous au chapitre 'Diffusion' de la documentation, pour plus de détails.")
    )
  )
  (if (= @language "deutsch")
    (
      (set #InstallWhat 	"Was möchten Sie installieren ?")
      (set #InstallChoice1      "Hauptprogramm")
      (set #InstallChoice1b     "Hauptprogramm - für 68060")
      (set #InstallChoice2      "Voreinstellungsprogramm")
      (set #InstallChoice3      "Online Hilfe")
      (set #InstallChoice4      "XPK Libraries")
      (set #InstallChoice5      "Katalog")
      (set #SelectMainDir       "Wählen Sie das Verzeichnis für das Hauptprogramm.")
      (set #CopyingMainProg     "Kopiere das Hauptprogramm...")
      (set #SelectPrefDir       "Wählen Sie das Verzeichnis für das Voreinstellungsprogramm.")
      (set #BadPrefDir  	"Sorry, Hauptprogramm und Voreinstellungsprogramm dürfen nicht in das selbe Verzeichnis !")
      (set #CopyingPrefProg     "Kopiere das Voreinstellungsprogramm...")
      (set #UpdateMainTT1       "Aktualisiere das %s Merkmal des Hauptprogramms...")
      (set #UpdateMainTT2       "Vergessen Sie nicht das %s Merkmal des Hauptprogramms zu aktualisieren.")
      (set #UpdateMainTTH1      "Dies erlaubt dem Hauptprogramm den Aufruf des Voreinstellungsprogramms.")
      (set #UpdateMainTTH2      "Dies erlaubt dem Hauptprogramm die Hilfe-Datei zu finden.")
      (set #UpdatePrefTT1       "Aktualisiere das %s Merkmal des Voreinstellungsprogramms...")
      (set #UpdatePrefTT2       "Vergessen Sie nicht das %s Merkmal des Voreinstellungsprogramms zu aktualisieren.")
      (set #UpdatePrefTTH2      "Dies erlaubt dem Voreinstellungsprogramm die Hilfe-Datei zu finden.")
      (set #SelectHelpDir       "Wählen Sie das Verzeichnis für die Online-Hilfe.")
      (set #CopyingHelp 	"Kopiere die Datei für die Online-Hilfe...")
      (set #SelectXPKDir	"Wählen Sie das Verzeichnis für die XPK Libraries.")
      (set #CopyingXPK  	"Kopiere die XPK Libraries...")
      (set #SelectCatalogDir    "Wählen Sie das Verzeichnis für die Katalogdatei.")
      (set #CopyingCatalog      "Kopiere die Katalogdatei...")
      (set #RunPrefProg 	"Starte das Voreinstellungsprogramm.")
      (set #RunPrefHelp 	"Dies erlaubt Ihnen die Voreinstellungen von ABackup zu ändern.")
      (set #Shareware1  	"ABackup ist SHAREWARE !")
      (set #Shareware2  	"Falls ihnen das Programm gefällt und Sie es regelmäßig benutzen, entrichten Sie bitte eine Gebühr von DM 30.")
      (set #Shareware3  	"Schlagen Sie bitte im Kapitel 'Diffusion' (Vertrieb) des Handbuchs nach, um mehr Informationen zu erhalten.")
    )
  )
  (if (= @language "italiano")
    (
      (set #InstallWhat 	"Che cosa vuoi installare ?")
      (set #InstallChoice1      "Programma Principale")
      (set #InstallChoice1b     "Programma Principale - 68060 version")
      (set #InstallChoice2      "Programma Preferenze")
      (set #InstallChoice3      "Aiuto in-linea")
      (set #InstallChoice4      "Librerie XPK")
      (set #InstallChoice5      "Catalogo Italiano")
      (set #SelectMainDir       "Seleziona la directory dove copiare il Programma Principale.")
      (set #CopyingMainProg     "Sto copiando il Programma Principale...")
      (set #SelectPrefDir       "Seleziona la directory dove copiare il Programma Preferenze.")
      (set #BadPrefDir  	"Spiacente, ma il programma Principale e quello delle Preferenze non possono essere installati nella stessa directory !")
      (set #CopyingPrefProg     "Sto copiando il programma per le Preferenze...")
      (set #UpdateMainTT1       "Sto aggiornando il tooltype %s del programma Principale...")
      (set #UpdateMainTT2       "Non dimenticare di aggiornare il tooltype %s del programma Principale.")
      (set #UpdateMainTTH1      "Questo permetterà al programma Principale di chiamare il programma Preferenze.")
      (set #UpdateMainTTH2      "Questo permetterà al programma Principale di trovare il file di aiuto.")
      (set #UpdatePrefTT1       "Sto aggiornando il tooltype %s del programma Preferenze...")
      (set #UpdatePrefTT2       "Non dimenticare di aggiornare il tooltype %s del programma Preferenze.")
      (set #UpdatePrefTTH2      "Questo permetterà al programma Preferenze di trovare il file di aiuto.")
      (set #SelectHelpDir       "Seleziona la directory dove copiare l'aiuto in-linea.")
      (set #CopyingHelp 	"Sto copiando aiuto in-linea...")
      (set #SelectXPKDir	"Seleziona la directory dove copiare librerie XPK.")
      (set #CopyingXPK  	"Sto copiando librerie XPK...")
      (set #SelectCatalogDir    "Seleziona la directory dove copiare il file catalogo.")
      (set #CopyingCatalog      "Sto copiando il file catalogo...")
      (set #RunPrefProg 	"Eseguo il programma per le Preferenze.")
      (set #RunPrefHelp 	"Questo ti permette di impostare le Preferenze di ABackup.")
      (set #Shareware1  	"ABackup è un programma SHAREWARE !")
      (set #Shareware2  	"Se ti piace e lo usi, è richiesto un contributo di US $20.")
      (set #Shareware3  	"Per favore, leggi la sezione 'Diffusione' della documentazione, per ulteriori dettagli")
    )
  )
))
;
;********* Install the main program *******************************************
;
(procedure InstallMainProg (
  (set MainDir
    (askdir
      (prompt #SelectMainDir)
      (help @askdir-help)
      (default "SYS:Utilities")
    )
  )
  (copyfiles
    (prompt #CopyingMainprog)
    (help @copyfiles-help)
    (source (tackon SourceDir ProgName))
    (dest MainDir)
    (newname "ABackup")
    (infos)
  )
))
;
;********* Install the Prefs program *******************************************
;
(procedure InstallPrefProg (
  (set PrefDir MainDir)
  (until (NOT (= PrefDir MainDir)) (
    (set PrefDir
      (askdir
	(prompt #SelectPrefDir)
	(help @askdir-help)
	(default DefPrefDir)
      )
    )
    (if (= PrefDir MainDir) (message #BadPrefDir))
  ))
  (copyfiles
    (prompt #CopyingPrefprog)
    (help @copyfiles-help)
    (source (tackon SourceDir "Prefs/ABackup"))
    (dest PrefDir)
    (infos)
  )
  (if (NOT (= PrefDir DefPrefDir))
    (if (BITAND ToInstall 1)
      (tooltype
	(prompt (#UpdateMainTT1 "PREFSPATH"))
	(help #UpdateMainTTH1)
	(dest (tackon MainDir "ABackup"))
	(settooltype "PREFSPATH" PrefDir)
	(confirm)
      )
      (message (cat (#UpdateMainTT2 "PREFSPATH") #UpdateMainTTH1))
    )
  )
))
;
;********* Install the help files **********************************************
;
(procedure InstallHelp (
  (set HelpDir
    (askdir
      (prompt #SelectHelpDir)
      (help @askdir-help)
      (default DefHelpDir)
    )
  )

  (if (= @language "français")
      (set SrcHelpDir "français")
      (set SrcHelpDir "english")
  )

  (copyfiles
    (prompt #CopyingHelp)
    (help @copyfiles-help)
    (source (tackon (tackon SourceDir (tackon "ABackup/Docs/" SrcHelpDir)) "ABackup.guide"))
    (dest HelpDir)
  )
  (if (NOT (= HelpDir DefHelpDir))
    (if (BITAND ToInstall 1)
      (tooltype
	(prompt (#UpdateMainTT1 "HELPPPATH"))
	(help #UpdateMainTTH2)
	(dest (tackon MainDir "ABackup"))
	(settooltype "HELPPATH" HelpDir)
	(confirm)
      )
      (message (cat (#UpdateMainTT2 "HELPPPATH") #UpdateMainTTH2))
    )
  )

  (copyfiles
    (prompt #CopyingHelp)
    (help @copyfiles-help)
    (source (tackon (tackon SourceDir (tackon "Prefs/Docs/" SrcHelpDir)) "ABackupPrefs.guide"))
    (dest HelpDir)
  )
  (if (NOT (= HelpDir DefHelpDir))
    (if (BITAND ToInstall 2)
      (tooltype
	(prompt (#UpdatePrefTT1 "HELPPPATH"))
	(help #UpdatePrefTTH2)
	(dest (tackon PrefDir "ABackup"))
	(settooltype "HELPPATH" HelpDir)
	(confirm)
      )
      (message (cat (#UpdatePrefTT2 "HELPPPATH") #UpdatePrefTTH2))
    )
  )
))
;
;********* Install XPK library ************************************************
;
(procedure InstallXPK (
  (set XPKDir
    (askdir
      (prompt #SelectXPKDir)
      (help @askdir-help)
      (default "LIBS:")
    )
  )
  (copylib
    (prompt #CopyingXPK)
    (help @copylib-help)
    (source (tackon SourceDir "libs/xpkmaster.library"))
    (dest XPKDir)
  )
  (foreach XPKSourceDir "#?.library"
    (copylib
      (prompt #CopyingXPK)
      (help @copylib-help)
      (source (tackon XPKSourceDir @each-name))
      (dest (tackon XPKDir "compressors"))
    )
  )
))
;
;********* Install the catalogs ***********************************************
;
(procedure InstallCatalog (
  (set CatalogDir
    (askdir
      (prompt #SelectCatalogDir)
      (help @askdir-help)
      (default DefCatalogDir)
    )
  )
  (copyfiles
    (prompt #CopyingCatalog)
    (help @copyfiles-help)
    (source (tackon (tackon (tackon SourceDir "ABackup/Catalogs") @language) "abackup.catalog"))
    (dest CatalogDir)
  )
  (copyfiles
    (prompt #CopyingCatalog)
    (help @copyfiles-help)
    (source (tackon (tackon (tackon SourceDir "Prefs/Catalogs") @language) "abackupprefs.catalog"))
    (dest CatalogDir)
  )
))
;
;********* Start of the installation program **********************************
;
(complete 0)
(user 2)
(set #InstallWhat "")
;
;********* Setup messages and check language
;
(SetupMessages)
(if (= #InstallWhat "")
  (
    (set langnum
      (askchoice
	(prompt "Which language do you speak ?")
	(help @askoptions-help)
	(choices "deutsch" "english" "français" "italiano")
      )
    )
    (set @language (select langnum "deutsch" "english" "français" "italiano"))
    (SetupMessages)
  )
)
;
;********* Displays the welcome message
;
(user 0)
(welcome)
;
;********* Ask which part is to be installed
;
(set ToInstall
  (askoptions
    (prompt #InstallWhat)
    (help @askoptions-help)
    (if (= #InstallChoice5 "")
	(choices #InstallChoice1 #InstallChoice1b #InstallChoice2 #InstallChoice3 #InstallChoice4)
	(choices #InstallChoice1 #InstallChoice1b #InstallChoice2 #InstallChoice3 #InstallChoice4 #InstallChoice5)
    )
  )
)
;
;******** Install each part
;
(complete 15)
(if (BITAND ToInstall  1)
  (
    (set ProgName "ABackup/ABackup")
    (InstallMainProg)
  )
)
(if (BITAND ToInstall  2)
  (
    (set ProgName "ABackup/ABackup_060")
    (InstallMainProg)
  )
)
(complete 30)
(if (BITAND ToInstall  4) (InstallPrefProg))
(complete 45)
(if (BITAND ToInstall  8) (InstallHelp))
(complete 60)
(if (BITAND ToInstall 16) (InstallXPK))
(complete 75)
(if (BITAND ToInstall 32) (InstallCatalog))
(complete 90)
;
;******** Call the Pref program
;
(if (BITAND ToInstall  4)
  (
    (textfile
      (dest TmpFile)
      (append (cat "Run <NIL: >NIL: " (tackon PrefDir "ABackup")))
    )
    (execute
      (TmpFile)
      (prompt #RunPrefProg)
      (help #RunPrefHelp)
      (confirm)
    )
    (delete TmpFile)
  )
)
;
;******** End
;
(if (= MainDir "")
  (set @default-dest PrefDir)
  (set @default-dest MainDir)
)
(message (cat #Shareware1 "\n" #Shareware2 "\n" #Shareware3))
(complete 100)
;
