; Opus_Patch580-581
; Installer Script to update Directory Opus Magellan version 5.80 to 5.81 
;
; Directory Opus Update Version $VER: Update-Opus 80-81C  (12.06.99)
; COPYRIGHT ©1999 GP SOFTWARE, AUSTRALIA


(complete 0)

(procedure clear_assigns

	(makeassign "DOPNEW")
	(makeassign "PCH")
	(makeassign "DOPOLD")
)

(procedure signal_opus

	(set #Sigs (tackon #SRC "dopusmsg"))
	(if (exists #Sigs (noreq))
		(run (cat #Sigs " DOPUS.1 \"command set notify off\""))
	)
)

(procedure make_newfiles ; (#EXT) requires #EXT to be set before call

	(working "Updating modules/icon.module")
	(run (cat (tackon #SRC "spatch") " -oDOPNEW:modules/icon.module -pPCH:icon.module."#EXT" DOPOLD:modules/icon.module"))

	(working "Updating modules/diskinfo.module")
	(run (cat (tackon #SRC "spatch") " -oDOPNEW:modules/diskinfo.module -pPCH:diskinfo.module."#EXT" DOPOLD:modules/diskinfo.module"))

	(working "Updating modules/configopus.module")
	(run (cat (tackon #SRC "spatch") " -oDOPNEW:modules/configopus.module -pPCH:configopus.module."#EXT" DOPOLD:modules/configopus.module"))

	(working "Updating modules/ftp.module")
	(run (cat (tackon #SRC "spatch") " -oDOPNEW:modules/ftp.module -pPCH:ftp.module."#EXT" DOPOLD:modules/ftp.module"))

	(working "Updating modules/read.module")
	(run (cat (tackon #SRC "spatch") " -oDOPNEW:modules/read.module -pPCH:read.module."#EXT" DOPOLD:modules/read.module"))

	(working "Updating modules/themes.module")
	(run (cat (tackon #SRC "spatch") " -oDOPNEW:modules/themes.module -pPCH:themes.module."#EXT" DOPOLD:modules/themes.module"))

	(working "Updating modules/about.module")
	(run (cat (tackon #SRC "spatch") " -oDOPNEW:modules/about.module -pPCH:about.module."#EXT" DOPOLD:modules/about.module"))

	(working "Updating libs/dopus5.library")
	(run (cat (tackon #SRC "spatch") " -oDOPNEW:libs/dopus5.library -pPCH:dopus5.library."#EXT" DOPOLD:libs/dopus5.library"))

	(working "Updating DirectoryOpus")
	(run (cat (tackon #SRC "spatch") " -oDOPNEW:DirectoryOpus -pPCH:DirectoryOpus."#EXT" DOPOLD:DirectoryOpus"))


)


(procedure wrong_version

	(message #Title_msg
		"Sorry, you have the wrong version of DirectoryOpus.\n\n"
		"This upgrade will NOT WORK for your version.\n"

		#README

		"Your Opus version is "#dop_ver"."#dop_rev".\n"
		"and the library is "#lib_ver"."#lib_rev"\n")

	(exit "Installation terminated!")

)

(procedure anyone_home

	(message #Title_msg
		"Sorry, cannot find DirectoryOpus on you system!\n\n"
		#README)
		
	(exit "Installation terminated!")

)

(procedure wrong_dopus

		
	(message #Title_msg
		"Sorry, you have the wrong version of DirectoryOpus.\n\n"
		"This upgrade will NOT WORK for your version.\n\n"

		#README

		"Your Opus version is "#dop_ver"."#dop_rev".\n")

	(exit "Instalation terminated!")
)

;
; start
;

(
(onerror clear_assigns)


(set #OLD_OPUS "DOpus5:")
(set #FINAL "DOpus5:")
(set @default-dest #FINAL)

(set #NEW_OPUS "ram:OP581")
(set #PCH_TMP "ram:OPPCHTMP")
(set #SRC "ram:PCH581")

(set #WANT_PRGREV 8)
(set #WANT_LIBVER 68)

(set #EXT "pch81")
(set #PATCHNAME "Opus8081CPatch.lha")

(set #DOPUSPROG (tackon #OLD_OPUS "DirectoryOpus"))

(set #README "Please read the ReadMe acompanying this archive or contact GPSoftware for details of upgrades\n\n")

(clear_assigns)
(signal_opus)


(makeassign "DOPOLD" #OLD_OPUS)

(makedir #NEW_OPUS)
(makeassign "DOPNEW"  #NEW_OPUS)

(makedir "DOPNEW:modules")
(makedir "DOPNEW:help")
(makedir "DOPNEW:libs")

(makedir #PCH_TMP)
(makeassign "PCH" #PCH_TMP)


; main procedure


	(set #Title_msg "Directory Opus Magellan 5.81C Update Patch.\n\n")

	(message #Title_msg
		"This procedure will update your existing version of"
		" Directory Opus Magellan 5.80 to version  5.81.\n\n"
		"When finished, you will need to reboot your Amiga.\n\n"
		"The procedure will create a number of temporary "
		"directories in RAM:, update your current DOpus5: "
		"files then copy the new files back over your old "
		"DOpus5: directory. When the process is complete, "
		"reboot your Amiga and read the ReadMe_Magellan581 "
		" file for details of the changes and new features."
		)

	(if (exists #DOPUSPROG (noreq))
		(
		(set #Vernum (getversion #DOPUSPROG))
		(set #Dop_ver (/ #Vernum 65536))
		(set #Dop_rev (- #Vernum (* #Dop_ver 65536) ) )
		);else
		(anyone_home)
	)


	(if	(AND (= #dop_ver 5 ) (= #dop_rev #WANT_PRGREV ))
		( 
		(if (exists (tackon #SRC #PATCHNAME))
			(
			(working "Unarchiving patch files...")
			(run (cat (tackon #SRC "lhex") " >NIL: <NIL: -qfw=PCH: x " (tackon #SRC #PATCHNAME)))

			(make_newfiles)
	
			(copyfiles (source "DOPNEW:") (dest #FINAL) (all) (optional force))
			(copyfiles (source (tackon #SRC "ReadMe_Magellan581")) (dest #FINAL) (infos))


			(message #Title_msg
				"Your DirectoryOpus Magellan should now have been updated to "
				"version 5.81. To complete the installation please reboot "
				"your Amiga and then read the ReadMe_Magellan5.81 in the "
				"DOpus5: directory")
			
			); else
			(message #Title_msg
				"Woops! Cannot find the patch archive\n"
				 "Required archive: "#PATCHNAME".\n\n"
			)
		)
		)
		(wrong_dopus) ;else
	)

	;
	; tidyup
	;

	(clear_assigns)
	(run (cat "C:Delete " #PCH_TMP " all"))
	(run (cat "C:Delete " #NEW_OPUS " all"))

		
(clear_assigns)
)
