.KEY dest,help/s
.BRA {
.KET }

; :ts=3
; HDInstall - Install everything onto a hard drive.
;
; Inputs:
;    dest   Directory to install into
;    help   Print instructions
;

;
; Some preliminary setup.
;
ASSIGN SMInstOrig: ""
ASSIGN SMInstPgm: ShowMaker:  ; Hook we can use when disk has been removed

; Make sure he's running WB 1.3 or higher!
; Under 1.3, the "1 gt 2" test fails; we proceed to "FAILAT 10".
; Under 1.2, however, the IF command itself dies, since GT is not defined;
; execution is not suspended, and the ECHO and SKIP are seen.
FAILAT 21
IF >NIL: 1 gt 2
        ECHO "*NVersion 1.3 or higher of the Amiga Workbench software"
        ECHO "*E[;1mmust*E[m be present before this installation can proceed.*N"
   SKIP wrapup
ENDIF
FAILAT 10

; Start with a fresh copy, to avoid any screwups
IF EXISTS RAM:SMInstall
   DELETE RAM:SMInstall/#? quiet
ELSE
   MAKEDIR RAM:SMInstall
ENDIF

CD Ram:SMInstall              ; Search it without adding it to path

COPY SMInstPgm:Misc/DiskMount    RAM:SMInstall
COPY SMInstPgm:Misc/InstUtil     RAM:SMInstall
COPY SMInstPgm:Misc/CombinePic   RAM:SMInstall
COPY SMInstPgm:Misc/#?Install-Proc RAM:SMInstall quiet
COPY SMInstPgm:Misc/Icons/#?.info RAM:SMInstall quiet
COPY SMInstPgm:Misc/showme RAM:SMInstall
COPY SMInstPgm:HELP-Install RAM:SMInstall

; Make sure these start fresh, too.
Assign SMInstData:

;
; Make sure needed system assignments exist.
;
INSTUTIL isdir T:
IF WARN
   INSTUTIL isdir RAM:T
   IF WARN
      MAKEDIR ram:T
   ENDIF
   ASSIGN T: ram:T
ENDIF

INSTUTIL isdir ENV:
IF WARN
   INSTUTIL isdir RAM:ENV
   IF WARN
      MAKEDIR ram:ENV
   ENDIF
   ASSIGN ENV: ram:ENV
ENDIF


;
; HELP processing
;
IF "{help}" eq "HELP"
   SKIP showme
ENDIF

INSTUTIL ask -dy "Do you need instructions [Y/N]? Y"
IF WARN
   SKIP noshow
ENDIF

LAB showme
   RAM:SMInstall/showme RAM:SMInstall/HELP-Install
LAB noshow

;
; Make sure that the destination exists, that its name is
; in a useable form (ie. that it ends with a '/' if it's a directory),
; and that the user in fact wants to install into it.
;
IF NOT EXISTS "{dest$SYS:}"
   ECHO "*N ********** Couldn't find Hard Disk drawer {dest$SYS:} **********"
   SKIP forhelp
ENDIF

INSTUTIL isdir "{dest$SYS:}"
IF WARN
   CD RAM:SMInstall
   ECHO "*N ********** {dest$SYS:} is not a drawer! **********"
LAB forhelp
   ECHO "*N For help, type"
   ECHO "      EXECUTE ShowMaker:SM_Install help"
   ECHO "*N or double-click on the *"Help-Install*" icon in this drawer*N"
   SKIP wrapup
ENDIF
CD RAM:SMInstall

ECHO >ram:SMInstall/DestPath1 "{dest$SYS:}"
INSTUTIL <ram:SMInstall/DestPath1 >ram:SMInstall/DestPath2 fixdir
INSTUTIL >ram:SMInstall/DestPath3 merge ==" ram:SMInstall/DestPath2 =="

ECHO "*N Answering *"No*" to the following question will cancel"
ECHO " the installation of ShowMaker.*N"
INSTUTIL ask -dy "Install ShowMaker onto {dest$SYS:} [Y/N]? Y"
IF warn
   ECHO " Installation aborted!*N"
   SKIP wrapup
ENDIF


ECHO "*N*N ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*N"
ECHO " Begin installation of ShowMaker onto {dest$SYS:}*N"

EXECUTE <ram:SMInstall/DestPath3 >nil: ram:SMInstall/SM_Install-Proc ?

ECHO "*N --------------------------------------------------------------------"
ECHO "*N*N Installation of ShowMaker complete."
ECHO "*N Please remove any ShowMaker disks and close all drawers from"
ECHO " the ShowMaker floppy disks before proceeding."

;
; Clean up after ourselves
; Can't depend on anything but SMInstPgm:,
; since we can come here from right after their definition.
;
LAB wrapup

CD ram:
Assign SMInstPgm:
Assign SMInstData:
DELETE >NIL: RAM:SMInstall all quiet

CD SMInstOrig:
ASSIGN SMInstOrig:
wait 5


