; Hey Emacs, this script might as well be -*- lisp -*-
;
; Ftree installation script for Installer
;
; Copyright © 1994 P. Ivcimey-Cook
;
; $Id: install-ftree,v 1.1 1994/04/27 12:06:27 peteric Exp peteric $
;
; This script has been tested with Installer 1.24:
;
;     Installer and Installer project icon
;     (c) Copyright 1991-93 Commodore-Amiga, Inc.  All Rights Reserved.
;     Reproduced and distributed under license from Commodore.
;
;     INSTALLER SOFTWARE IS PROVIDED "AS-IS" AND SUBJECT TO CHANGE;
;     NO WARRANTIES ARE MADE.  ALL USE IS AT YOUR OWN RISK.  NO LIABILITY
;     OR RESPONSIBILITY IS ASSUMED.
;
; Use following Icon tooltypes / Command line options:
; APPNAME=FTree
; MINUSER=AVERAGE
;
(set version "0.3")
(set app-vname (cat @app-name " version " version))
(set need-memory (* 400 1024))

(transcript "Installing the Family Tree Charter Version " version)

(welcome "    Welcome to " app-vname ".\n"
		"Please note that " @app-name " can ONLY be run from a shell (CLI) at present."
)

(set instdir (pathonly @icon))

(transcript "Checking available memory.")
(set avail-mem (+ (database "total-mem")))
(if (< avail-mem need-memory)
	((message "Your system has only " (/ avail-mem 1024) " kilobytes of "
		"free memory, while " @app-name " needs at least "
		(/ need-memory 1024) " to be useful.\n"
		"You can continue the installation but be warned!")
	(transcript "User decided to continue installation while available "
		"memory was below the recommended minimum.")))

(if
	(askbool
		(prompt @app-name " is currently installed in directory " instdir "\n"
					"Do you wish to copy the files elsewhere?")
		(help	"The installer can set up the system to use files"
				"in their current locations, or copy them elsewhere.\n"
				"Select Yes if you wish for the files to be copied somewhere else.")
		(default 0)
		(choices "Yes - Copy" "No - Leave")
	)
	(
		(set newinstdir
			(askdir
				(prompt "Please select a new directory for the " app-vname " files.")
				(help @askdir-help)
				(default (cat "TOOLS:FTree-" version))
			)
		)
		
		(set n 1)
		(set m 10)					; number of files in this list
		(while (set thisfile (select n
					"bin/ftree"
					"guide/ftree.guide"
					"guide/ftree.guide"
					"examples/example"
					"examples/people"
					"examples/cooks"
					"examples/mccallums"
					"libs/ixemul.library"
					"libs/arp.library"
					"ps/ftinit.ps"
				))
		(
			
			(copyfiles 
				(prompt "Copying file " thisfile " to new directory")
				(help @copyfiles-help)
				(icons)
				(source thisfile)
				(dest (tackon newinstdir thisfile))
			)
			
			(transcript "Copying file \"" thisfile "\" to new directory.")
			(complete (+ 10 (* (/ n m) 10)) )
		))
		(set instdir newinstdir)
		(complete 20)
	)
	(
		(transcript "Installed directory \"" instdir "\" being left as-is.")
		(complete 20)
	)
)

(set psfonts-assigned (exists "PSFONTS:" (noreq)))
(set psfontdir (getassign "PSFONTS:" "vad"))

(if (NOT psfonts-assigned)
	(
		(transcript "\"PSFONTS:\" volume not defined.")
		(set psfontdir (askdir
				(prompt "Please enter the directory in which PostScript fonts can be found.\n"
					"A directory \"afm\" will be created in this for the Adobe Font Metric files required by " @app-name)
				(help @askdir-help)
				(default "SYS:PSFonts")
				(newpath)
			)
		)
		(makedir psfontdir)
		(makedir (tackon psfontdir "afm"))
		(makeassign "PSFONTS" psfontdir)
		(startup @app-name
				(prompt @app-name " needs to modify the user-startup file so that the directory \"PSFONTS\" is available.")
				(help @startup-help)
				(command	"assign PSFONTS: " psfontdir "\n"
							"path " (tackon instdir "bin") " add\n")
		)
	)
	(
		(transcript "PSFONTS: assigned to " psfontdir )
	)
)

(complete 30)

(transcript "Installing ixemul.library")

(copylib
	(help @copylib-help)
	(prompt "Installing System Library (Ixemul.library)")
	(confirm)
	(source "Libs/ixemul.library")
	(dest
		(askdir
			(prompt "Please select a place for \"ixemul.library\".")
			(help @askdir-help)
			(default "LIBS:")
		)
	)
)

(complete 40)

(set vernum (getversion "exec.library" (resident)))
(set execver (/ vernum 65536))
(set execrel (- vernum (* execver 65536))

(transcript "Exec version " execver "." execrel " found.")

(if (< execver 37)
	(
		(transcript "Installing arp.library")

		(message "You are using an Amiga with an operating system earlier than Kickstart 2.\n"
				"The standard PostScript interpreter \"Post\" requires Kickstart 2 to work correctly.\n"
				"However, an external PostScript LaserPrinter can still be used to print " app-vname "'s output.\n"
				"Therefore the OS1.2/1.3 support library \"arp.library\" will be copied.")
		
		(copylib
			(help @copylib-help)
			(prompt "Installing System Library (Arp.library)")
			(confirm)
			(source "Libs/arp.library")
			(dest
				(askdir
					(prompt "Please select a place for \"arp.library\".")
					(help @askdir-help)
					(default "LIBS:")
				)
			)
		)
	)
)

(complete 50)

