;$VER: Squirrel SCSI 1.11 (26.3.95)

;;-
;;- $Id: SCSI-Install,v 1.15 1995/08/29 15:49:03 alex Rel $
;;-
;;- Squirrel SCSI Installation Script
;;-
;;- Copyright © 1994, 1995 HiSoft. All Rights Reserved.
;;-

;;-
;;- Selectors for the installation options
;;-
(set kCOMPONENTSCSI 0)
(set kCOMPONENTCD 1)
(set kCOMPONENTCD32DISK 2)
(set kCOMPONENTCDONLYDISK 3)
(set kCOMPONENTHDDISK 4)
(set kCOMPONENTWBCOPY 5)

;;-
;;- Library routines
;;-

;;-
;;- SetDrive - select additional drive for use during installation
;;-
;;- Inputs:
;;-		None
;;-
;;- Outputs:
;;-		DRIVE - drive number of extra drive
;;-
(procedure SetDrive
	(user 2)
	(set DEFAULTDRIVE 0)
	(set df0 (getassign "DF0" "d"))
	(set df1 (getassign "DF1" "d"))
	(set df2 (getassign "DF2" "d"))
	(set df3 (getassign "DF3" "d"))

	(if (= df0 SOURCEPATH) ( (set DEFAULTDRIVE "DF0:") (set df0 "")))
	(if (= df1 SOURCEPATH) ( (set DEFAULTDRIVE "DF1:") (set df1 "")))
	(if (= df2 SOURCEPATH) ( (set DEFAULTDRIVE "DF2:") (set df2 "")))
	(if (= df3 SOURCEPATH) ( (set DEFAULTDRIVE "DF3:") (set df3 "")))

	(set NDRIVES 0)
	(if (<> df0 "")
		(	(select NDRIVES
				(set d0 "DF0:")
				(set d1 "DF0:")
				(set d2 "DF0:")
				(set d3 "DF0:")
			)
			(set NDRIVES (+ NDRIVES 1))
		)
	)
	(if (<> df1 "")
		(	(select NDRIVES
				(set d0 "DF1:")
				(set d1 "DF1:")
				(set d2 "DF1:")
				(set d3 "DF1:")
			)
			(set NDRIVES (+ NDRIVES 1))
		)
	)
	(if (<> df2 "")
		(	(select NDRIVES
				(set d0 "DF2:")
				(set d1 "DF2:")
				(set d2 "DF2:")
				(set d3 "DF2:")
			)
			(set NDRIVES (+ NDRIVES 1))
		)
	)
	(if (<> df3 "")
		(	(select NDRIVES
				(set d0 "DF3:")
				(set d1 "DF3:")
				(set d2 "DF3:")
				(set d3 "DF3:")
			)
			(set NDRIVES (+ NDRIVES 1))
		)
	)

	(set XDPROMPT "Select the floppy drive to use during installation and formatting")
	(select
		(select NDRIVES
			(+ 4)
			(askchoice (prompt XDPROMPT) (help @askchoice-help) (choices d0))
			(askchoice (prompt XDPROMPT) (help @askchoice-help) (choices d0 d1))
			(askchoice (prompt XDPROMPT) (help @askchoice-help) (choices d0 d1 d2))
			(askchoice (prompt XDPROMPT) (help @askchoice-help) (choices d0 d1 d2 d3))
		)
		(set DRIVE d0)
		(set DRIVE d1)
		(set DRIVE d2)
		(set DRIVE d3)
		(set DRIVE DEFAULTDRIVE)
	)
	(user DEFAULT-USER)
)

;;-
;;- Walk - traverse directories performing an action on all files
;;-
;;- Inputs:
;;-		WALKACTION:
;;-			0 => delete target files encountered
;;-			1 => perform swapcolors on files
;;-			2 => copylib file
;;-			3 => move files into file named directories
;;-		WALKROOT: initial directory (including trailing slash/colon)
;;-		WALKPAT: required matching pattern
;;-		WALKPROMPT: prompt to use (if required)
;;-		WALKDEST: destination location
;;- Outputs:
;;-		None
;;-
(procedure Walk
	(procedure WalkDown
		(select WALKACTION
			("")
			(tooltype
				(dest CURRENTNAME)
				(swapcolors)
			)
			(copylib
				(source CURRENTNAME)
				(dest (tackon WALKDEST CURRENTDRAWER))
				(optional "askuser")
				(infos)
				(confirm)
				(prompt (WALKPROMPT @each-name))
				(help @copylib-help)
			)
			("")
		)
	)
	(procedure WalkUp
		(select WALKACTION
			(delete CURRENTNAME
				(optional "force")
				(safe)
			)
			("")
			("")
			(	(if (= CURRENTDRAWER "")
					(if (= (exists CURRENTNAME) 1)
						(	(rename CURRENTNAME ("%s$" CURRENTNAME))
							(makedir CURRENTNAME)
							(rename ("%s$" CURRENTNAME) ("%s/%s" CURRENTNAME CURRENTPATH))
						)
					)
				)
			)
		)
	)
	(set EN0 WALKROOT)
	(set EP0 "")
	(set ED0 "")
	(foreach EN0 WALKPAT
		(	(set EP1 (cat EP0 @each-name))
			(set EN1 (cat EN0 @each-name))
			(set CURRENTPATH EP1)
			(set CURRENTNAME EN1)
			(set CURRENTDRAWER ED0)
			(WalkDown)
			(if (>= @each-type 0)
				(	(set ED1 (cat ED0 @each-name))
					(foreach EN1 WALKPAT
						(	(set EP2 (cat EP1 "/" @each-name))
							(set EN2 (cat EN1 "/" @each-name))
							(set CURRENTPATH EP2)
							(set CURRENTNAME EN2)
							(set CURRENTDRAWER ED1)
							(WalkDown)
							(if (>= @each-type 0)
								(	(set ED2 (cat ED1 "/" @each-name))
									(foreach EN2 WALKPAT
										(	(set EP3 (cat EP2 "/" @each-name))
											(set EN3 (cat EN2 "/" @each-name))
											(set CURRENTPATH EP3)
											(set CURRENTNAME EN3)
											(set CURRENTDRAWER ED2)
											(WalkDown)
											(if (>= @each-type 0)
												(	(set ED3 (cat ED2 "/" @each-name))
													(foreach EN3 WALKPAT
														(	(set EP4 (cat EP3 "/" @each-name))
															(set EN4 (cat EN3 "/" @each-name))
															(set CURRENTPATH EP4)
															(set CURRENTNAME EN4)
															(set CURRENTDRAWER ED3)
															(WalkDown)
															(if (>= @each-type 0)
																(	(set ED4 (cat ED3 "/" @each-name))
																	(foreach EN4 WALKPAT
																		(	(set EP5 (cat EP4 "/" @each-name))
																			(set EN5 (cat EN4 "/" @each-name))
																			(set CURRENTPATH EP5)
																			(set CURRENTNAME EN5)
																			(set CURRENTDRAWER ED4)
																			(WalkDown)
																			(set CURRENTPATH EP5)
																			(set CURRENTNAME EN5)
																			(set CURRENTDRAWER ED4)
																			(WalkUp)
																		)
																	)
																)
															)
															(set CURRENTPATH EP4)
															(set CURRENTNAME EN4)
															(set CURRENTDRAWER ED3)
															(WalkUp)
														)
													)
												)
											)
											(set CURRENTPATH EP3)
											(set CURRENTNAME EN3)
											(set CURRENTDRAWER ED2)
											(WalkUp)
										)
									)
								)
							)
							(set CURRENTPATH EP2)
							(set CURRENTNAME EN2)
							(set CURRENTDRAWER ED1)
							(WalkUp)
						)
					)
				)
			)
			(set CURRENTPATH EP1)
			(set CURRENTNAME EN1)
			(set CURRENTDRAWER ED0)
			(WalkUp)
		)
	)
)

;;-
;;- UpdateSetPatch
;;-		Update C:SetPatch to the latest version
;;-
;;- Inputs:
;;-		SOURCEPATH: Path to SetPatch directory
;;- Outputs:
;;-		None
;;-
(procedure UpdateSetPatch
	(set uspSOURCE "")
	(if (>= (/ (getversion "LIBS:version.library") 65536) 37)
		(if (>= (/ (getversion "C:IPrefs") 65536) 38)
			(set uspSOURCE "C/SetPatch")
		)
		(set uspSOURCE "RAM:Morsels/Updates/SetPatch_37.39")
	)
	(if (strlen uspSOURCE)
		(copylib
			(source uspSOURCE)
			(dest "SYS:C")
			(newname "SetPatch")
			(confirm)
			(prompt "Update \"C:SetPatch\"?")
			(help @copylib-help)
		)
	)
)

;;-
;;- SetNVLocation
;;-		Set up location for nonvolatile storage
;;-
;;- Inputs:
;;-		None
;;- Outputs:
;;-		snvlDRAWERPATH
;;-
(procedure SetNVLocation
	(if (= (exists "SYS:Prefs/Env-Archive/Sys/nv_location") 1)
		(	(copyfiles
				(source "SYS:Prefs/Env-Archive/Sys/nv_location")
				(dest "ENV:")
				(safe)
			)
			(set theDefaultDest (getenv "nv_location"))
		)
		(set theDefaultDest "SYS:")
	)
	(set snvlDRAWERPATH
		(askdir
			(prompt "Select the location for the \"nonvolatile\" Drawer")
			(help
				(cat "When running CD32 titles which wish to save the state of the title "
					"(high scores, progress, state of play etc.) a directory containing "
					"the information is used, rather than the non-volatile RAM on a CD32. "
					"You should choose a drawer in which you wish to create the "
					"\"nonvolatile\" drawer, where all the files used by the CD32 titles "
					"will be placed.\n\n"
					@askdir-help
				)
			)
			(default theDefaultDest)
		)
	)
	(if (= (exists "SYS:Prefs/Env-Archive/Sys/nv_location") 1)
		(if
			(<>
				(expandpath (pathonly theDefaultDest))
				(expandpath (pathonly snvlDRAWERPATH))
			)
			(set snvlDRAWERPATH (tackon snvlDRAWERPATH "nonvolatile"))
		)
		(set snvlDRAWERPATH (tackon snvlDRAWERPATH "nonvolatile"))
	)
	(makedir snvlDRAWERPATH)
)

(procedure SetSCSILocation
	(set SCSI_DEST
		(tackon
			(askdir
				(prompt "Select the location for the SquirrelSCSI Drawer")
				(help @askdir-help)
				(default "SYS:")
			)
			"SquirrelSCSI")
	)
)

(procedure SetCD32Location
	(if (<> (getassign "CD32" 'a') "")
		(set theDefaultDest (expandpath "CD32:/"))
		(set theDefaultDest "SYS:")
	)
	(set CD32_DEST
		(tackon
			(askdir
				(prompt "Select the location for the CD32 drawer")
				(help @askdir-help)
				(default theDefaultDest)
			)
			"CD32"
		)
	)
)


;;-
;;- UnconditionalSystemUpdates:
;;-		Perform system updates which are independent of what is being
;;-		installed
;;-
;;- Inputs:
;;-		None
;;- Outputs:
;;-		None
;;-
(procedure UnconditionalSystemUpdates
	(if (= (exists "SYS:Utilities/Installer") 0)
		(copyfiles
			(source "Installer")
			(dest "SYS:Utilities")
		)
	)
)

;;-
;;- CreateDevsDrawers
;;-		Create Devs drawers if missing (Devs, DOSDrivers & Storage)
;;-
;;- Inputs:
;;-		None
;;- Outputs:
;;-		None
;;-
;;-
(procedure CreateDevsDrawers
	(makedir "SYS:Devs" (infos))
	(if (not (exists "SYS:Devs.info"))
		(copyfiles
			(source "WB-3/Devs.info")
			(dest "SYS:")
		)
	)
	(makedir "SYS:Devs/DOSDrivers" (infos))
	(if (not (exists "SYS:Devs/DOSDrivers.info"))
		(copyfiles
			(source "WB-3/Devs/DOSDrivers.info")
			(dest "SYS:Devs")
		)
	)
	(makedir "SYS:Storage" (infos))
	(if (not (exists "SYS:Storage.info"))
		(copyfiles
			(source "WB-3/Devs.info")
			(dest "SYS:")
			(newname "Storage.info")
		)
	)
	(makedir "SYS:Storage/DOSDrivers" (infos))
	(if (not (exists "SYS:Storage/DOSDrivers.info"))
		(copyfiles
			(source "WB-3/Devs/DOSDrivers.info")
			(dest "SYS:Devs")
			(newname "DOSDrivers.info")
		)
	)
)

;;-
;;- Gestalt - generate system configuration information
;;-
;;- Inputs:
;;-		None
;;-
;;- Outputs:
;;-		gProcessor - 0=>68000/68010, 1=>68020/68030/68040, 2=>68060
;;-		SOURCEPATH - path name of installation disk (w/ :)
;;-		SOURCEVOLUME - path name of installation disk (w/o :)
;;-		SYSPATH - full path name of SYS: (w/ :)
;;-
(procedure Gestalt
	(run "GetCPU >ENV:SCSI-Install-PROCESSOR" (safe))
	(set gestaltProcessor (getenv "SCSI-Install-PROCESSOR"))
	(if (or (= gestaltProcessor "68000") (= gestaltProcessor "68010"))
		(set gProcessor 0)
		(if (= gestaltProcessor "68060")
			(set gProcessor 2)
			(set gProcessor 1)
		)
	)

	(set SOURCEPATH (expandpath (pathonly @icon)))
	(set SOURCEPATH (pathonly (pathonly SOURCEPATH)))
	(set SOURCEVOLUME (substr SOURCEPATH 0 (- (strlen SOURCEPATH) 1)))

	(set SYSPATH (expandpath "SYS:"))
	(set SYSPATH (pathonly (pathonly SYSPATH)))
)

;;-
;;- StashOldFiles:
;;-		Move old files which should not be overwritten
;;-
;;- Inputs:
;;-		None
;;- Outputs:
;;-		None
;;-
(procedure StashOldFiles
	(set sofS-STARTUP-SEQUENCE "SYS:S/Startup-Sequence")
	(set sofDEVS-CD0 "SYS:Devs/DOSDrivers/CD0")
	(set sofSTORAGE-CD0 "SYS:Storage/DOSDrivers/CD0")
	(set sofOLDFILES "")
	(if (in COMPONENTS kCOMPONENTCD)
		(if (exists sofS-STARTUP-SEQUENCE)
			(set sofOLDFILES (cat sofOLDFILES sofS-STARTUP-SEQUENCE "\n"))
		)
	)
	(if (exists sofDEVS-CD0)
		(set sofOLDFILES (cat sofOLDFILES sofDEVS-CD0 "\n"))
	)
	(if (exists sofSTORAGE-CD0)
		(set sofOLDFILES (cat sofOLDFILES sofSTORAGE-CD0 "\n"))
	)
	(if (strlen sofOLDFILES)
		(if
			(askbool
				(prompt	"\n\nShould the following files be moved to the \"SYS:OLD\" drawer?\n\n"
					sofOLDFILES)
				(help "Installation of the Squirrel SCSI software updates several system "
					"files. If you have made changes to these that might be lost during the "
					"installation process they will be moved to the \"SYS:OLD\" drawer "
					"where you can find them after the installation has completed."
				)
				(choices "Proceed with Move" "Skip This Part")
				(default 1)
			)
			(	(makedir "SYS:OLD" (infos))
				(if (in COMPONENTS kCOMPONENTCD)
					(if (exists sofS-STARTUP-SEQUENCE)
						(	(makedir "SYS:OLD/S")
							(copyfiles
								(source sofS-STARTUP-SEQUENCE)
								(dest "SYS:OLD/S")
								(optional "force")
								(nogauge)
							)
						)
					)
				)
				(if (exists sofDEVS-CD0)
					(	(makedir "SYS:OLD/Devs" (infos))
						(makedir "SYS:OLD/Devs/DOSDrivers" (infos))
						(delete "SYS:OLD/Devs/DOSDrivers/CD0")
						(delete "SYS:OLD/Devs/DOSDrivers/CD0.info")
						(rename sofDEVS-CD0 "SYS:OLD/Devs/DOSDrivers/CD0")
						(rename (cat sofDEVS-CD0 ".info") "SYS:OLD/Devs/DOSDrivers/CD0.info")
					)
				)
				(if (exists sofSTORAGE-CD0)
					(	(makedir "SYS:OLD/Devs" (infos))
						(makedir "SYS:OLD/Devs/DOSDrivers" (infos))
						(delete "SYS:OLD/Devs/DOSDrivers/CD0")
						(delete "SYS:OLD/Devs/DOSDrivers/CD0.info")
						(rename sofSTORAGE-CD0 "SYS:OLD/Devs/DOSDrivers/CD0")
						(rename (cat sofSTORAGE-CD0 ".info") "SYS:OLD/Devs/DOSDrivers/CD0.info")
					)
				)
			)
		)
	)
)

;;-
;;- CopyCD0
;;-		Copy suitable CD0 driver either to Devs or Storage
;;-
;;- Inputs:
;;-		None
;;- Outputs:
;;-		None
;;-
;;-
(procedure CopyCD0
	(CreateDevsDrawers)
	(if (in COMPONENTS kCOMPONENTCD)
		(	(copyfiles
				(source "RAM:Morsels/DOSDrivers/CD0")
				(dest "SYS:Devs/DOSDrivers")
				(optional "force")
			)
			(copyfiles
				(source "RAM:Morsels/DOSDrivers.CD32.CD0.info")
				(dest "SYS:Devs/DOSDrivers")
				(newname "CD0.info")
				(optional "force")
			)
		)
		(if (in COMPONENTS kCOMPONENTSCSI)
			(	(copyfiles
					(source "RAM:Morsels/DOSDrivers/CD0")
					(dest "SYS:Storage/DOSDrivers")
					(optional "force")
				)
				(copyfiles
					(source "RAM:Morsels/DOSDrivers.SCSI.CD0.info")
					(dest "SYS:Storage/DOSDrivers")
					(newname "CD0.info")
					(optional "force")
				)
			)
		)
	)
)

;;-
;;- ExtractMorsels
;;-		Extract installation morsels to RAM:
;;-
;;- Inputs:
;;-		None
;;- Outputs:
;;-		None
;;-
;;-
(procedure ExtractMorsels
	(working "Extracting Morsels...")
	(run "LHex >NIL: -qw=RAM: x Morsels.lha" (safe))
)

;********************request a disk******************************
(procedure REQUESTINSTALL
	(askdisk
		(Prompt "\n\nPlease insert the Squirrel SCSI\n\nMaster disk in any drive")
		(help @askdisk-help)
		(DEST "SquirrelSCSI")
	)
)

(procedure REQUESTCD32BOOT
	(askdisk
		(Prompt "\n\nPlease insert the CD32 boot floppy \n\nwhich is being prepared in any drive")
		(help @askdisk-help)
		(DEST "CD32Boot")
	)
)

(procedure REQUESTCDONLYBOOT
	(askdisk
		(Prompt "\n\nPlease insert the CD only boot floppy \n\nwhich is being prepared in any drive")
		(help @askdisk-help)
		(DEST "CDBoot")
	)
)

(procedure REQUESTSCSIHDBOOT
	(askdisk
		(Prompt "\n\nPlease insert the SCSI hard disk boot \n\nfloppy which is being prepared in any drive")
		(help @askdisk-help)
		(DEST "SCSIHDBoot")
	)
)

;;-
;;- InstallComponentSCSI - install SCSI component to hard disk
;;-
;;- Inputs:
;;-		None
;;-
;;- Outputs:
;;-		None
;;-

(procedure InstallComponentSCSI
	(procedure UpdateWorkbench-SCSI
		(makedir "SYS:Tools" (infos))
		(makedir "SYS:C")
		(makedir "SYS:L")
		(set theItem 0)
		(while
			(set theFileName
				(select theItem
					"Tools/HDToolBox"
					"RAM:Morsels/L/CDFileSystem"
					"L/FastFileSystem"
					"C/Mount"
					""
				)
			)
			(	(set theDestDrawer
					(select theItem
						"SYS:Tools"
						"SYS:L"
						"SYS:L"
						"SYS:C"
					)
				)
				(copylib
					(source theFileName)
					(dest theDestDrawer)
					(optional "askuser" "force")
					(confirm)
					(prompt
						("Updating Workbench File \"%s\""
							(tackon theDestDrawer (fileonly theFileName))
						)
					)
					(help @copylib-help)
				)
				(set theItem (+ theItem 1))
			)
		)
	)
	(procedure CopyFiles-SCSI
		(copyfiles
			(source "Tools/SquirrelHDToolBox")
			(dest "SYS:Tools")
			(optional "force")
			(infos)
		)
		(copyfiles
			(source
				(select gProcessor
					"Devs/squirrelscsi.device"
					"RAM:Morsels/Devs.68020/squirrelscsi.device"
					"RAM:Morsels/Devs.68060/squirrelscsi.device"
				)
			)
			(dest "DEVS:")
			(optional "force")
		)
		(copyfiles
			(source "RAM:Morsels/C/SquirrelSCSI")
			(dest "C:")
			(optional "force")
		)
		(makedir SCSI_DEST (infos))
		(copyfiles
			(source "RAM:Morsels/SquirrelSCSI/")
			(dest SCSI_DEST)
			(all)
			(infos)
			(optional "force")
		)
		(copyfiles
			(source "SCSIMounter/")
			(dest (tackon SCSI_DEST "SCSIMounter"))
			(all)
			(infos)
			(optional "force")
		)
		(copyfiles
			(source "ReadMe")
			(dest SCSI_DEST)
			(all)
			(infos)
			(optional "force")
		)
	)

	(UpdateWorkbench-SCSI)
	(CopyFiles-SCSI)
	(startup "SquirrelSCSI"
		(prompt "Place SquirrelSCSI hard-drive mounting support in your \"User-Startup\"?")
		(help @startup-help)
		(command
			"SquirrelSCSI >NIL: MOUNT"
		)
	)
	(startup "SCSIMounter"
		(prompt "Place SCSIMounter path in your \"User-Startup\"?")
		(help @startup-help)
		(command ("Path \"%s/SCSIMounter\" ADD\n" SCSI_DEST))
	)
)

;;-
;;- InstallComponentCD32 - install CD32 component to hard disk
;;-
;;- Inputs:
;;-		None
;;-
;;- Outputs:
;;-		None
;;-

(procedure InstallComponentCD32
	;;-
	;;- OutdateCD32 - outdate CD32 files on hard disk
	;;-
	(procedure OutdateCD32
		;;- have we been here before?
		(if (<> (getassign "CD32" 'a') "")
			(	;;- delete obsolete files
				(set n 0)
				(while
					(set theName
						(select n
							"TitleSetup/Bundle"
							"TitleSetup/TOWERASSAULT"
							"TitleSetup/RoboCod_CD"
							"TitleSetup/ZOOL2"
							"TitleSetup/CDTV_TEST"
							"TitleMount/TOWERASSAULT"
							"C/ResetVBR"
							""
						)
					)
					(set theFileName (tackon "CD32:" theName))
					(if (= (exists theFileName) 1)
						(delete theFileName)
					)
					(set n (+ n 1))
				)
				;;- update directory structure for any user files
				(set WALKROOT "CD32:TitleSetup/")
				(set WALKACTION 3)
				(set WALKPAT "~(#?.info)")
				(Walk)
			)
		)
	)
	(procedure UpdateWorkbench-CD32
		(if (exists "SYS:C/LoadResource")
			(if (= (getsum "SYS:C/LoadResource") -546165909)
				(delete "SYS:C/LoadResource"
					(optional "askuser" "force")
					(confirm)
					(prompt
						"Delete \"C:LoadResource\"?\n\n"
						"Carefully read the \"Help\" before you decide _not_ to "
						"perform this operation."
					)
					(help
						"The version of \"C:LoadResource\" you have installed has "
						"a serious bug in its dos.library LoadSeg patch which will "
						"stop certain CD32 titles from working correctly. You should "
						"choose to delete this file and allow the Installer to replace "
						"it with a patched version which fixes this bug."
					)
				)
			)
		)
		(set theItem 0)
		(while
			(set theFileName
				(select theItem
					"C/Mount"
					"RAM:Morsels/C/LoadResource"
					"RAM:Morsels/Libs/lowlevel.library"
					"RAM:Morsels/Libs/nonvolatile.library"
					"RAM:Morsels/Libs/debox.library"
					"RAM:Morsels/Libs/playerprefs.library"
					"Libs/locale.library"
					"RAM:Morsels/L/CDFileSystem"
					""
				)
			)
			(	(set theDestDrawer
					(select theItem
						"SYS:C"
						"SYS:C"
						"SYS:Libs"
						"SYS:Libs"
						"SYS:Libs"
						"SYS:Libs"
						"SYS:Libs"
						"SYS:L"
					)
				)
				(copylib
					(source theFileName)
					(dest theDestDrawer)
					(optional "askuser" "force")
					(confirm)
					(prompt
						("Updating Workbench File \"%s\""
							(tackon theDestDrawer (fileonly theFileName))
						)
					)
					(help @copylib-help)
				)
				(set theItem (+ theItem 1))
			)
		)
	)
	(procedure CopyFiles-CD32
		(set theItem 0)
		(while
			(set theFileName
				(select theItem
					"RAM:Morsels/Libs/freeanim.library"
					"RAM:Morsels/Devs/cd.device.config"
					"RAM:Morsels/Devs/bookmark.device"
					"RAM:Morsels/S/CD32-Startup"
					"RAM:Morsels/C/SquirrelSCSI"
					""
				)
			)
			(	(copyfiles
					(source theFileName)
					(dest
						(select theItem
							"SYS:Libs"
							"SYS:Devs"
							"SYS:Devs"
							"SYS:S"
							"SYS:C"
						)
					)
					(optional "force")
				)
				(set theItem (+ theItem 1))
			)
		)
		(set theItem 0)
		(while
			(set theFileName
				(select gProcessor
					(select theItem
						"RAM:Morsels/Devs.68000/cd.device"
						"Devs/squirrelscsi.device"
						""
					)
					(select theItem
						"RAM:Morsels/Devs.68020/cd.device"
						"RAM:Morsels/Devs.68020/squirrelscsi.device"
						""
					)
					(select theItem
						"RAM:Morsels/Devs.68060/cd.device"
						"RAM:Morsels/Devs.68060/squirrelscsi.device"
						""
					)
				)
			)
			(	(copyfiles
					(source theFileName)
					(dest "SYS:Devs")
					(optional "force")
				)
				(set theItem (+ theItem 1))
			)
		)
	)

	(OutdateCD32)
	(UpdateWorkbench-CD32)
	(CopyFiles-CD32)

	(makedir CD32_DEST (infos))
	(copyfiles
		(source "RAM:Morsels/CD32")
		(dest CD32_DEST)
		(all)
		(optional "force")
	)

	(textfile
		(dest "ENVARC:CD32-Path")
		(append ("%s" CD32_DEST))
	)

	(copyfiles
		(source "RAM:Morsels/nonvolatile/")
		(dest snvlDRAWERPATH)
		(all)
	)
	(textfile
		(dest "SYS:Prefs/Env-Archive/Sys/nv_location")
		(append (expandpath snvlDRAWERPATH))
	)

	(set FILETOBEPATCHED "S:Startup-Sequence")
	(if
		(>=
			(run ("C/Search >NIL: FROM \"%s\" SEARCH \";CD32\" QUIET" FILETOBEPATCHED))
			5
		)
		(	(set PATCHFILE "RAM:Patchfile")

			(textfile
				(dest ("%s" PATCHFILE))
				(append "TR+; M1; F U/SetPatch/; N; I\n\n")
				(append ";CD32 Startup added by Squirrel SCSI Installation\n")
				(append "IF EXISTS S:CD32-Startup\n")
				(append "  C:Assign T: RAM:\n")
				(append "  Execute S:CD32-Startup\n")
				(append "EndIF\n")
				(append ";End CD32 Startup\n\n")
				(append "Z\n")
			)

			(run
				("C/Edit FROM \"%s\" WITH \"%s\" OPT W5000" FILETOBEPATCHED PATCHFILE)
				(confirm)
				(prompt "Place CD32 auto-start modifications in \"S:Startup-Sequence\"")
				(help
					"In order to auto-start CD32 titles the installation process adds the "
					"lines:\n\n"
					"IF EXISTS S:CD32-Startup\n"
					"  C:Assign T: RAM:\n"
					"  Execute S:CD32-Startup\n"
					"EndIF\n\n"
					"immediately after the SetPatch line in your Startup-Sequence. "
					"Note that without these changes you will not be able to auto-start "
					"CD32 titles."
				)
			)
			(delete PATCHFILE)
		)
	)
)

;;-
;;- FormatFloppy - format a floppy disk
;;-
;;- Inputs:
;;-		DRIVE - which drive to use
;;-		inDiskName - name for the disk
;;-		inDiskDescription - description for the disk
;;-
;;- Outputs:
;;-		None
;;-

(procedure FormatFloppy
	(SetDrive)
	(set theUserLevel @user-level)
	(user 2)
	(message
		("\nPlease insert a blank disk in drive \"%s\"" DRIVE)
		"\n\nWait for the Drive light\n to go off before proceeding"
	)
	(working
		("\nFormatting \"%s\" disk\n\n\n This will take aproximately 2 minutes..."
			inDiskDescription
		)
	)
	(run "RAM:Morsels/C/Wait 10")
	(run
		("RAM:Morsels/System/Format DRIVE \"%s\" NAME \"%s\" NOICONS FFS"
			DRIVE inDiskName
		)
	)
	(run ("RAM:Morsels/C/Install DRIVE \"%s\" FFS" DRIVE))
	(user theUserLevel)
)


;;-
;;- CreateComponentCDOnly - create CD only boot floppy
;;-
;;- Inputs:
;;-		None
;;-
;;- Outputs:
;;-		None
;;-

(procedure CreateComponentCDOnly
	(procedure DeletePac-CDOnly
		(set theItem 0)
		(while
			(set theDrawer
				(select theItem
					"RAM:Morsels/Libs/"
					"RAM:Morsels/CD32/"
					"RAM:Morsels/nonvolatile/"
					"RAM:Morsels/Devs/"
					"RAM:Morsels/Updates/"
					"RAM:Morsels/SquirrelSCSI/"
					"RAM:Morsels/Locale/"
					"RAM:Morsels/Prefs/"
					"RAM:Morsels/Prefs.info"
					"RAM:Morsels/DOSDrivers.CD32.CD0.info"
					"RAM:Morsels/Devs/bookmark.device"
					"RAM:Morsels/Devs.68000/cd.device"
					"RAM:Morsels/Devs.68020/cd.device"
					""
				)
			)
			(	(if (= (exists theDrawer) 2)
					(	(set WALKROOT theDrawer)
						(set WALKACTION 0)
						(set WALKPAT "#?")
						(Walk)
					)
				)
				(delete theDrawer (safe))
				(set theItem (+ theItem 1))
			)
		)
	)
	(procedure CopyFiles-CDOnly
		(copyfiles
			(source "")
			(dest "RAM:Morsels")
			(safe)
			(optional "force")
			(pattern "~(Installer|#?.lha|LHex|SCSI-Install|SCSI-Install.info|SCSIMounter|SCSIMounter.info|Tools|Tools.info)")
		)
		(set theItem 0)
		(while
			(set theFileName
				(select theItem
					"RAM:Morsels/DOSDrivers.SCSI.CD0.info"
					"RAM:Morsels/DOSDrivers"
					""
				)
			)
			(	(set theNewName
					(select theItem
						"RAM:Morsels/DOSDrivers/CD0.info"
						"RAM:Morsels/Devs/DOSDrivers"
					)
				)
				(rename theFileName theNewName (safe))
				(set theItem (+ theItem 1))
			)
		)
		(copyfiles
			(source "RAM:Morsels/System.info")
			(dest "RAM:Morsels")
			(newname "Devs.info")
			(safe)
		)
		(copyfiles
			(source "RAM:Morsels/System.info")
			(dest "RAM:Morsels/Devs")
			(newname "DOSDrivers.info")
			(safe)
		)
		(set theItem 0)
		(while
			(set theFileName
				(select theItem
					"RAM:Morsels/SCSIMounter"
					"RAM:Morsels/S/CD32-Startup"
					"RAM:Morsels/L/FastFileSystem"
					""
				)
			)
			(	(delete theFileName (safe))
				(set theItem (+ theItem 1))
			)
		)
		(if (= gProcessor 1)
			(	(delete
					"RAM:Morsels/Devs/squirrelscsi.device"
					(safe)
				)
				(rename
					"RAM:Morsels/Devs.68020/squirrelscsi.device"
					"RAM:Morsels/Devs/squirrelscsi.device"
					(safe)
				)
			)
			(delete
				"RAM:Morsels/Devs.68020/squirrelscsi.device"
				(safe)
			)
		)
		(delete "RAM:Morsels/Devs.68020" (safe))
		(delete "RAM:Morsels/Devs.68000" (safe))
	)
	(DeletePac-CDOnly)
	(CopyFiles-CDOnly)
	(set inDiskName "CDBoot")
	(set inDiskDescription "CD Only Boot Disk")
	(FormatFloppy)
	(copyfiles
		(source "RAM:Morsels/")
		(dest "CDBoot:")
		(all)
	)
)


;;-
;;- CreateComponentCD32Disk - create CD32 boot floppy
;;-
;;- Inputs:
;;-		None
;;-
;;- Outputs:
;;-		None
;;-

(procedure CreateComponentCD32Disk
	(procedure DeletePac-CD32Only
		(set theItem 0)
		(while
			(set theDrawer
				(select theItem
					"RAM:Morsels/Updates/"
					"RAM:Morsels/SquirrelSCSI/"
					"RAM:Morsels/S/HD-Startup"
					"RAM:Morsels/DOSDrivers.SCSI.CD0.info"
					""
				)
			)
			(	(if (= (exists theDrawer) 2)
					(	(set WALKROOT theDrawer)
						(set WALKACTION 0)
						(set WALKPAT "#?")
						(Walk)
					)
				)
				(delete theDrawer (safe))
				(set theItem (+ theItem 1))
			)
		)
	)
	(procedure CopyFiles-CD32Disk
		(copyfiles
			(source "")
			(dest "RAM:Morsels")
			(safe)
			(optional "force")
			(pattern "~(Installer|#?.lha|LHex|SCSI-Install|SCSI-Install.info|SCSIMounter|SCSIMounter.info|Tools|Tools.info)")
		)
		(set theItem 0)
		(while
			(set theFileName
				(select theItem
					"RAM:Morsels/DOSDrivers.CD32.CD0.info"
					"RAM:Morsels/DOSDrivers"
					"RAM:Morsels/System.info"
					""
				)
			)
			(	(set theNewName
					(select theItem
						"RAM:Morsels/DOSDrivers/CD0.info"
						"RAM:Morsels/Devs/DOSDrivers"
						"RAM:Morsels/Devs.info"
					)
				)
				(rename theFileName theNewName (safe))
				(set theItem (+ theItem 1))
			)
		)
		(copyfiles
			(source "RAM:Morsels/Devs.info")
			(dest "RAM:Morsels/Devs")
			(newname "DOSDrivers.info")
			(safe)
		)
		(copyfiles
			(source "RAM:Morsels/Devs.info")
			(dest "RAM:Morsels")
			(newname "CD32.info")
			(safe)
		)
		(set theItem 0)
		(while
			(set theFileName
				(select theItem
					"RAM:Morsels/SCSIMounter"
					"RAM:Morsels/L/FastFileSystem"
					"RAM:Morsels/S/Startup-Sequence"
					""
				)
			)
			(	(delete theFileName (safe))
				(set theItem (+ theItem 1))
			)
		)
		(rename
			"RAM:Morsels/S/Startup-CD32BootFloppy"
			"RAM:Morsels/S/Startup-Sequence"
			(safe)
		)
		(if (= gProcessor 1)
			(	(delete
					"RAM:Morsels/Devs/squirrelscsi.device"
					(safe)
				)
				(rename
					"RAM:Morsels/Devs.68020/squirrelscsi.device"
					"RAM:Morsels/Devs/squirrelscsi.device"
					(safe)
				)
				(rename
					"RAM:Morsels/Devs.68020/cd.device"
					"RAM:Morsels/Devs/cd.device"
					(safe)
				)
				(delete
					"RAM:Morsels/Devs.68000/cd.device"
					(safe)
				)
			)
			(	(rename
					"RAM:Morsels/Devs.68000/cd.device"
					"RAM:Morsels/Devs/cd.device"
					(safe)
				)
				(delete
					"RAM:Morsels/Devs.68020/squirrelscsi.device"
					(safe)
				)
				(delete
					"RAM:Morsels/Devs.68020/cd.device"
					(safe)
				)
			)
		)
		(delete "RAM:Morsels/Devs.68020" (safe))
		(delete "RAM:Morsels/Devs.68000" (safe))
	)
	(DeletePac-CD32Only)
	(CopyFiles-CD32Disk)
	(set inDiskName "CD32Boot")
	(set inDiskDescription "CD32 Boot Disk")
	(FormatFloppy)
	(copyfiles
		(source "RAM:Morsels/")
		(dest "CD32Boot:")
		(all)
	)
)

;;-
;;- CreateComponentHDDisk - create HD boot floppy
;;-
;;- Inputs:
;;-		None
;;-
;;- Outputs:
;;-		None
;;-

(procedure CreateComponentHDDisk
	(procedure DeletePac-HDDisk
		(set theItem 0)
		(while
			(set theDrawer
				(select theItem
					"RAM:Morsels/Libs/"
					"RAM:Morsels/CD32/"
					"RAM:Morsels/nonvolatile/"
					"RAM:Morsels/Devs/"
					"RAM:Morsels/Updates/"
					"RAM:Morsels/Locale/"
					"RAM:Morsels/Prefs/"
					"RAM:Morsels/S/Startup-CD32BootFloppy"
					"RAM:Morsels/Prefs.info"
					"RAM:Morsels/DOSDrivers/CD0"
					"RAM:Morsels/DOSDrivers.CD32.CD0.info"
					"RAM:Morsels/DOSDrivers.SCSI.CD0.info"
					"RAM:Morsels/Devs/bookmark.device"
					"RAM:Morsels/Devs.68000/cd.device"
					"RAM:Morsels/Devs.68020/cd.device"
					"RAM:Morsels/L/CDFileSystem"
					""
				)
			)
			(	(if (= (exists theDrawer) 2)
					(	(set WALKROOT theDrawer)
						(set WALKACTION 0)
						(set WALKPAT "#?")
						(Walk)
					)
				)
				(delete theDrawer (safe))
				(set theItem (+ theItem 1))
			)
		)
	)
	(procedure CopyFiles-HDDisk
		(copyfiles
			(source "")
			(dest "RAM:Morsels")
			(safe)
			(optional "force")
			(pattern "~(Installer|#?.lha|LHex|SCSI-Install|SCSI-Install.info)")
		)
		(set theItem 0)
		(while
			(set theFileName
				(select theItem
					"RAM:Morsels/SCSIMounter/SCSIMounter"
					"RAM:Morsels/SCSIMounter/SCSIMounter.info"
					"RAM:Morsels/SCSIMounter.info"
					"RAM:Morsels/DOSDrivers"
					""
				)
			)
			(	(set theNewName
					(select theItem
						"RAM:Morsels/SquirrelSCSI/SCSIMounter/SCSIMounter"
						"RAM:Morsels/SquirrelSCSI/SCSIMounter/SCSIMounter.info"
						"RAM:Morsels/SquirrelSCSI.info"
						"RAM:Morsels/Devs/DOSDrivers"
					)
				)
				(rename theFileName theNewName (safe))
				(set theItem (+ theItem 1))
			)
		)
		(copyfiles
			(source "RAM:Morsels/Tools.info")
			(dest "RAM:Morsels/")
			(newname "Devs.info")
			(safe)
		)
		(copyfiles
			(source "RAM:Morsels/Tools.info")
			(dest "RAM:Morsels/Devs")
			(newname "DOSDrivers.info")
			(safe)
		)
		(set theItem 0)
		(while
			(set theFileName
				(select theItem
					"RAM:Morsels/S/Startup-Sequence"
					"RAM:Morsels/SCSIMounter"
					"RAM:Morsels/S/CD32-Startup"
					""
				)
			)
			(	(delete theFileName (safe))
				(set theItem (+ theItem 1))
			)
		)
		(rename
			"RAM:Morsels/S/HD-Startup"
			"RAM:Morsels/S/Startup-Sequence"
			(safe)
		)
		(if (= gProcessor 1)
			(	(delete
					"RAM:Morsels/Devs/squirrelscsi.device"
					(safe)
				)
				(rename
					"RAM:Morsels/Devs.68020/squirrelscsi.device"
					"RAM:Morsels/Devs/squirrelscsi.device"
					(safe)
				)
			)
			(delete
				"RAM:Morsels/Devs.68020/squirrelscsi.device"
				(safe)
			)
		)
		(delete "RAM:Morsels/Devs.68020" (safe))
		(delete "RAM:Morsels/Devs.68000" (safe))
	)
	(DeletePac-HDDisk)
	(CopyFiles-HDDisk)
	(set inDiskName "HDBoot")
	(set inDiskDescription "Hard Drive Boot Disk")
	(FormatFloppy)
	(copyfiles
		(source "RAM:Morsels/")
		(dest "HDBoot:")
		(all)
	)
)

;***********************check if Workbench************************
(procedure WORKBENCH
(if (<> QUICKFORMAT 2)
(
(USER 2)
(message ("\nPlease insert your Workbench disk in drive %s " DRIVE)
"\n\n\n\n Select Proceed to continue")
(procedure SCANDISK
(set WBDisk (expandpath DRIVE))
(set WBDisk1 (substr WBDisk 0 9))
(set WBDisk2 (substr WBDisk 8 9))
(if (OR (= WBDisk1 "Workbench") (= WBDisk2 "Workbench"))
	(set WBDisk3 0)
	(set WBDisk3 1)
)
)
(procedure NOTWBDISK
(SCANDISK)
(set TESTDISK 0)
(if (= WBDisk3 1)
	(set TESTDISK
	(askbool
	(Prompt "This does not look like a Workbench disk\n\n\nPlease insert an"
	(" original (unaltered in any way) Workbench disk in drive %s " DRIVE)
	"\n\n\n Select Retry to scan the disk or Ignore to carry on regardless")
	(Help ("The disk you have inserted in drive %s does not look like a" DRIVE)
	" Workbench disk to the installer.\n\nPlease insert an original Amiga"
	(" Workbench disk in drive %s select Retry for the installer to" DRIVE)
	" scan the disk again.\n\nYou can proceed without a Workbench disk but"
	" the disks created may not work correctly and the installation"
	" may stop due to an incorrect file/directory structure! \n\nIf you"
	" wish to carry on regardless of the warnings, select Ignore.")
	(Choices "Retry" "Ignore")
	)
	)
)
)
(NOTWBDISK)
(While (= TESTDISK 1)
	(NOTWBDISK)
)
(SCANDISK)
(user DEFAULT-USER)
)
)
)

;**************************copy workbench files********************************
(procedure PART5
	(USER 2)
	(SetDrive)
	(Message
		"The installation of the Workbench files to a Squirrel SCSI external hard disk"
		" requires that you have already partitioned and formatted the hard disk"
		" and that it is visible on the Workbench as a device. If you cannot access the"
		" the hard disk then you must repartition or format the drive."
	)
	(WORKBENCH)

	(set wbdiskver (getversion ("%sLibs/version.library" DRIVE)))
	(set ver (/ wbdiskver 65536))
	(set rev (- wbdiskver (* ver 65536) ) )

	(if (>= ver 40)
		;wb 3.1
		(set WBVERSION 4)
	)

	(if (= ver 39)
		;wb 3
		(set WBVERSION 3)
	)

	(if (= ver 38)
		;wb 2.10
		(set WBVERSION 2)
	)

	(if (= ver 37)
		(	(if (= rev 71)
				;wb 2.05
				(set WBVERSION 1)
			)
			(if (< rev 71)
				;wb 2.04
				(set WBVERSION 0)
			)
		)
	)

	(procedure SELECTDEVICE
		(USER 2)

		(set device
			(askdir
				(prompt "Select the SCSI device to copy\nWorkbench files to.")
				(help @askdir-help)
				(default "Workbench:")
				(disk)
			)
		)

		(set devicename (expandpath device))

		(set n 0)

		(while (<> x ":")
			(	(set x (substr devicename n 1))

				(set WBCOPYDEST (substr devicename 0 (+ n 1)))

				(set n (+ n 1))
			)
		)

		(set reselect
			(askbool
				(prompt ("Copy Workbench files to \"%s\"" WBCOPYDEST))
				(help @askbool-help)
				(choices "Yes" "No (Reselect)")
			)
		)
	)

	(SELECTDEVICE)

	(while (= reselect 0)
		(SELECTDEVICE)
	)

	(procedure COPYDISKS
		(set floppyname (substr diskname 0 (- (strlen diskname) 1)))
		(askdisk
			(Prompt ("\n\nPlease insert the %s disk in any drive" diskname))
			(help @askdisk-help)
			(DEST floppyname)
		)

		(copyfiles
			(source diskname)
			(dest diskdest)
			(all)
		)
	)

	(set n 0)
	(if (or (= WBVERSION 0) (= WBVERSION 1))
		(	(while (set diskname (select n "Workbench2.0:" "AmigaFonts2.0:" "Extras2.0:" ""))
				(	(set diskdest WBCOPYDEST)
					(COPYDISKS)
					(set n (+ n 1))
				)
			)
		)
	)

	(if (= WBVERSION 2)
		(	(while (set diskname (select n "Workbench2.1:" "Fonts:" "Extras2.1:" "Locale:" ""))
				(	(set diskdest (select n WBCOPYDEST ("%sFonts" WBCOPYDEST) WBCOPYDEST ("%sLocale" WBCOPYDEST) ""))
					(COPYDISKS)
					(set n (+ n 1))
				)
			)
		)
	)

	(if (= WBVERSION 3)
		(	(while (set diskname (select n "Workbench3.0:" "Fonts:" "Extras3.0:" "Locale:" "Storage3.0:" ""))
				(	(set diskdest (select n WBCOPYDEST ("%sFonts" WBCOPYDEST) WBCOPYDEST ("%sLocale" WBCOPYDEST) ("%sStorage" WBCOPYDEST) ""))
					(if (<> (exists ("%sStorage" WBCOPYDEST)) 2)
						(makedir ("%sStorage" WBCOPYDEST) (infos))
					)
					(COPYDISKS)
					(set n (+ n 1))
				)
			)
		)
	)

	(if (= WBVERSION 4)
		(	(while	(set diskname (select n "Workbench3.1:" "Fonts:" "Extras3.1:" "Locale:" "Storage3.1:" ""))
				(	(set diskdest (select n WBCOPYDEST ("%sFonts" WBCOPYDEST) WBCOPYDEST ("%sLocale" WBCOPYDEST) ("%sStorage" WBCOPYDEST) ""))
					(if (<> (exists ("%sStorage" WBCOPYDEST)) 2)
						(makedir ("%sStorage" WBCOPYDEST) (infos))
					)
					(COPYDISKS)
					(set n (+ n 1))
				)
			)
		)
	)

	(user default-user)
)

;*************************run cd config program ****************************
(procedure CDCONFIG
	(user 2)
	(if (in COMPONENTS kCOMPONENTCD)
		(	(Message "About to run the CD configuration program check everything"
				" is plugged in and switched on")
			(run
				("%s/Prefs/CDDevice FROM DEVS:cd.device.config" CD32_DEST)
			)
		)
	)

	(if (in COMPONENTS kCOMPONENTCD32DISK)
		(	(Message "About to run the CD configuration program check everything"
				" is plugged in and switched on")
			(REQUESTCD32BOOT)
			(RUN "CD32Boot:CD32/Prefs/CDDevice FROM CD32Boot:Devs/cd.device.config")
		)
	)
	(user default-user)
)


;****************************bye bye************************
(procedure BYE
	(REQUESTINSTALL)
	(USER 2)
	(Message "Squirrel SCSI Installation is complete."
		"\nTo obtain your 30 days free technical support and notification of"
		" updates, please complete your registration card and return"
		" it to:-\n\n"
		;* text starts at * and ends at *                   *
		"          North America            Rest of world    \n"
		"         Oregon Research              HiSoft        \n"
		"    16200 S.W. Pacific Highway    The Old School    \n"
		"            Suite 162               Greenfield      \n"
		"             Tigard                 Bedford, UK     \n"
		"            OR 97224                 MK45 5DE       \n"
		"Phone: +1 503 620 4919            +44 1525 718181   \n"
		"FAX:   +1 503 624 2940            +44 1525 713716   \n"
		"EMail: orres@teleport.com hisoft@cix.compulink.co.uk\n"
		)

	(Message "Please remember, UK technical support is\n between 2-3p.m."
			" Mon-Fri\nIf you need technical support, please remember to have when you"
		" phone, your:-\nSerial Number\nSoftware version number\nMachine"
		" configuration (RAM,Processor,Hard disk etc.)\n\n Please also have a"
		" clear and concise description of the problem you are having to ensure"
		" that we can deal with your problem as quickly as possible.\n\n"
		" Select Proceed to quit to Workbench")

	(if (= (exists "SYS:Utilities/Multiview") 1)
		(Run "Run SYS:Utilities/Multiview ReadMe" (safe))
		(Run "Run More ReadMe" (safe))
	)
)

;*********************************COMPONENTS*********************************
(procedure PARTS
	(USER 2)
	(set pDEFAULT 1)
	(set COMPONENTS
		(shiftleft 1
			(askchoice
				(Prompt "Which part of the package would you like to install?\n\nSee Help for more details")
				(help (cat
					"Install Squirrel SCSI software to hard disk\n"
					"-------------------------------------------\n"
					"This option will copy the files need for using SCSI devices "
					"to your internal IDE hard disk. In addition the software required "
					"to use CD's will be copied.\n\n"

					"Install CD32/CDTV emulator files to hard disk\n"
					"----------------------------------------\n"
					"This option will copy the files required to use CD32/CDTV titles onto "
					"your hard drive; it also copies all the files associated with the "
					"first option.\n"
					"This option requires that you have plugged the interface "
					"into the computer and that the CD-ROM is connected properly "
					"and switched on - Check Now!\n\n"

					"Create CD/CD32/CDTV boot floppy\n"
					"-------------------------------\n"
					"This option will create a boot disk that you can use to run CD32 or CDTV titles. The disk contains"
					" the minimum files required to use CD32/CDTV titles. This option also requires that"
					" that the CD-ROM you are using is correctly plugged into the interface and is"
					" switched on. To use this boot disk, insert your CD32/CDTV title into the drive and"
					" reboot the machine with the boot disk.\n\n"

					"Create CD only boot floppy\n"
					"--------------------------\n"
					"This option will create a boot disk that you can use to mount CDs. The disk contains"
					" the minimum files required to use CDs. To use the CD only boot disk,"
					" reboot the machine with the boot disk and insert a suitable CD.\n\n"

					"Create SquirrelSCSI hard disk boot floppy\n"
					"-----------------------------------------\n"
					"This option will create a boot disk that you can use to boot from an external"
					" SquirrelSCSI hard disk. The disk contains the minimum files required to pass"
					" control from the boot disk to the SCSI hard disk.\n\n"

					"Setup a SCSI hard disk\n"
					"----------------------\n"
					"This option can be used in conjunction with the "
					"\n\"Create SquirrelSCSI hard disk boot floppy\"\n"
					"This option will simply copy all the necessary Workbench files to "
					"an external SCSI hard disk.\n"
					"NOTE:\nThis option requires all the original Workbench disk supplied"
					" with your computer.\n\n"
					@askoptions-help)
				)
				(choices
					"Squirrel SCSI software to hard disk"
					"Squirrel SCSI & CD32/CDTV emulator to hard disk"
					"Create CD/CD32/CDTV boot floppy"
					"Create CD only boot floppy"
					"Create SquirrelSCSI hard disk boot floppy"
					"Setup a SCSI hard disk to use with a boot disk"
				)
				(default pDEFAULT)
			)
		)
	)
	(USER default-user)
)

(procedure Terminate
	(user 2)
	(if (> @ioerr 0)
		(message ("\n\nA Dos Error %ld has occured" @ioerr)
			"\n\n\n\nPlease consult your Workbench manual"
			(" for further details, or type Fault %ld from a shell." @ioerr)
		)
	)
	(set theItem 0)
	(while
		(set theDrawer
			(select theItem
				"RAM:Morsels"
				"RAM:Boot"
				"RAM:CD32DISK"
				"RAM:HDDISK"
				""
			)
		)
		(	(if (= (exists theDrawer) 2)
				(	(set WALKROOT (cat theDrawer "/"))
					(set WALKACTION 0)
					(set WALKPAT "#?")
					(Walk)
					(delete theDrawer (safe))
				)
			)
			(set theitem (+ theItem 1))
		)
	)
	(delete "T:Edit"
		(optional "force")
		(safe)
	)
	(delete "T:Startup-Sequence"
		(optional "force")
		(safe)
	)
)

;**************************do ya stuff*********************************

(onerror (Terminate))
(set DEFAULT-USER @user-level)

(if (= (getassign "T") "") (
		(makedir "RAM:T")
		(makeassign "T" "RAM:T")
	)
)
(Gestalt)
(user 2)
(PARTS)
(if (IN COMPONENTS kCOMPONENTWBCOPY)
	(PART5)
	(	(if
			(or
				(in COMPONENTS kCOMPONENTSCSI)
				(in COMPONENTS kCOMPONENTCD)
			)
			(SetSCSILocation)
		)
		(if (in COMPONENTS kCOMPONENTCD)
			(SetCD32Location)
		)
		(if (in COMPONENTS kCOMPONENTCD)
			(SetNVLocation)
		)
		(ExtractMorsels)
		(if
			(or
				(in COMPONENTS kCOMPONENTSCSI)
				(in COMPONENTS kCOMPONENTCD)
			)
			(	(StashOldFiles)
				(UpdateSetPatch)
				(UnconditionalSystemUpdates)
				(InstallComponentSCSI)
			)
		)
		(if (in COMPONENTS kCOMPONENTCD)
			(InstallComponentCD32)
		)
		(if
			(or
				(in COMPONENTS kCOMPONENTSCSI)
				(in COMPONENTS kCOMPONENTCD)
			)
			(CopyCD0)
		)
		(if (in COMPONENTS kCOMPONENTCD32DISK)
			(CreateComponentCD32Disk)
		)
		(if (in COMPONENTS kCOMPONENTCDONLYDISK)
			(CreateComponentCDOnly)
		)
		(if (in COMPONENTS kCOMPONENTHDDISK)
			(CreateComponentHDDisk)
		)
	)
)
(CDCONFIG)
(BYE)
(Terminate)
(exit (quiet))
