; Installer script for installing MRBackup Professional

(set @default_dest "SYS:MRBackup")

; Establish an error cleanup routine.

(onerror
	(makeassign "MRBackup" (safe))
)

; See if this is really an update.

(set is_update 0)
(set MRBackup_dest (getassign "MRBackup" "a"))

; If it's an update, be sure user wants to use the same target directory.

(if MRBackup_dest
    ; then
	(if (askbool
	    (prompt "Your current copy of MRBackup Professional appears to be located in the drawer named \""
					MRBackup_dest
					"\". Do you want the update installed in that drawer?"
			)
			(help
"The installer has determined that you may already have a "
"copy of MRBackup installed on your system. If this is wrong or "
"you want the update installed elsewhere, select NO as an "
"answer. Otherwise, select YES."
			)
			(default 1)
		)

		(set is_update 1)		; if user wants in same place

		(set MRBackup_dest			; if user wants in different place
            (askdir
                (prompt "In which disk or drawer should MRBackup Professional be installed?")
                (help @askdir-help)
                (default "SYS:MRBackup")
            )
		)
	)
    ; else
    (
        (set MRBackup_dest
            (askdir
                (prompt "In which disk or drawer should MRBackup Professional be installed?")
                (help @askdir-help)
                (default "SYS:MRBackup")
            )
        )
    )
)

(if (not (exists MRBackup_dest) )
    (makedir MRBackup_dest (infos) (confirm) (help) )
)

(makeassign "MRBackup" MRBackup_dest (safe))

; Now lock on to volume 'MRBackup'.

(askdisk
	(prompt "Please insert the disk labeled \"MRBackup Professional\".")
	(help	"The MRBackup Professional program and support files will be copied "
			"from this disk onto your system.")
	(dest  "MRBackup Professional")
	(newname "MRBackupInstallDisk")
)

; Make MRBackup drawer & icon if not there

(if (not is_update)
    (makedir MRBackup_dest (infos))
)

(makedir (tackon MRBackup_dest "Work"))
(makedir (tackon MRBackup_dest "Catalogs"))
(makedir (tackon MRBackup_Dest "Lists_and_Logs"))

; At this point we have a valid destination, so we tell installer where
; the application will end up so the exit page will be correct -- also,
; the installation log file (if any) will be copied to the destination
(set @default-dest MRBackup_dest)

(set cpu_prompt (cat 
    "If you have an accelerated Amiga with a 68020/68030/68040 CPU, you "
    "can elect to install a special version of the software configured "
    "for your accelerated CPU. DO NOT SELECT \"Accelerated CPU\" if you have "
    "a stock 68000 CPU or your machine will crash when you attempt to run "
    "the accelerated version of the software."
    )
)

(set cpu_type
    (askchoice 
        (prompt cpu_prompt) 
        (choices "Stock CPU" "Accelerated CPU")
        (help 
"This prompt allows you to select a special version of the software "
"which takes advantage of an accelerated CPU, should you have one "
"installed in your Amiga."
        )
        (default 0) 
    )
)

(if (= cpu_type 0)
    (set cpu_type "")
    (set cpu_type "_020")
)

(copyfiles
    (source "MRBackupInstallDisk:")
    (pattern "#?.info")
    (dest MRBackup_dest)
)

(copyfiles
	(source "MRBackupInstallDisk:ARexx_Scripts")
	(dest (tackon MRBackup_dest "ARexx_Scripts") )
    (all)
	(infos)
)

(copyfiles
    (source "MRBackupInstallDisk:Help")
    (dest (tackon MRBackup_dest "Help") )
    (all)
    (infos)
)

(copyfiles
    (source "MRBackupInstallDisk:Help.info")
    (dest MRBackup_dest)
)

( if is_update 
  (set copy_prefs 
        (askbool (prompt "Overwrite preferences files?")
                 (help "If you answer Yes, your existing preferences "
                       "files will be overwritten. "
                 )
        )
  )
  ( set copy_prefs 1 )
)
  

( if copy_prefs
    ( copyfiles
        (source "MRBackupInstallDisk:Prefs")
        (dest (tackon MRBackup_dest "Prefs") )
        (all)
        (infos)
    )
    ( transcript "Preferences files were not copied." )
)

(copyfiles
    (source "MRBackupInstallDisk:Prefs.info")
    (dest MRBackup_dest)
)

(copyfiles
    (source "MRBackupInstallDisk:Docs")
    (dest (tackon MRBackup_dest "Docs") )
    (all)
    (infos)
)

(copyfiles
    (source "MRBackupInstallDisk:Docs.info")
    (dest MRBackup_Dest)
)

; The shareware diskette has a special document at the top level.

(if (exists "MRBackupInstallDisk:ShareWare")
    (copyfiles
        (source "MRBackupInstallDisk:")
        (pattern "(ShareWare|ShareWare.info)")
        (dest MRBackup_dest)
    )
)

(copyfiles
    (source "MRBackupInstallDisk:")
    (pattern    "(MRBackup|MRBackup.info|Compressor.info|FormatDisk|FormatDisk.info)")
    (dest MRBackup_dest)
)

(set compressor_name (cat "Compressor" cpu_type))
(copyfiles
    (source (tackon "MRBackupInstallDisk:" compressor_name) )
    (dest MRBackup_dest)
    (newname (tackon MRBackup_dest "Compressor" ) )
)

(working "Updating MRBackup icon...")
(tooltype
	(dest MRBackup_dest)
	(noposition)
)

; Copy the AmigaGuide library.
(working "Installing AmigaGuide...")
(copylib
    (source "MRBackupInstallDisk:libs/amigaguide.library")
    (dest "LIBS:")
)

(copylib
    (source "MRBackupInstallDisk:s/help.guide")
    (dest "S:")
)

; Copy MRBackup's tape handler to the L: directory.

(working "Copying MRTape-Handler...")
(copylib 
	(source "MRBackupInstallDisk:L/mrtape-handler")
	(dest "L:")
)

(working "")

; modify S:User-Startup

(startup "MRBackup"
	(prompt
		"Some instructions need to be added to the \"S:user-startup\" "
		"so that your system will be properly configured to use MRBackup.")
	(help "Do this or MRBackup won't work!!")
	(command
		"ASSIGN MRBackup: \"" MRBackup_dest "\"\n"
		the_cache
	)
)

; reinitialize assigns

(if (not @pretend)
	(	
        (makeassign "MRBackup" MRBackup_dest)
	)
)


; Force the user-level to 2 so that the following message will appear
; for all user levels.

(user 2)

(message
    "If you are going to be using the included\n"
    "MRTape-Handler, you will need to manually\n"
    "copy the appropriate mountlist entries from\n"
    "the installation diskette to your hard disk.\n"
    "For AmigaDOS version 2.04, do this: \n\n"
    "COPY CLONE df0:Devs/mountlist.mrtape DEVS: \n\n"
    "and for AmigaDOS version 2.1 or higher, do this: \n\n"
    "COPY CLONE df0:Devs/DosDrivers Devs:DosDrivers ALL \n\n"
    "Be sure to edit the mountlists so that they\n"
    "match your requirements. \n"
)

(complete 100)

	; cleanup

(makeassign "MRBackupInstallDisk" (safe))

; this is not strictly necessary, but doesn't hurt -- there is always
; a default (exit) at the end of any script
(exit)
