;;
;;  $Filename: HDInstall $
;;  $Id: HDInstall,v 3.12 1993/09/17 16:38:10 $
;;  $Date: 1993/09/17 16:38:10 $
;;  $Revision: 3.12 $
;;

(set is_update 0)
(set @user-level 1)	; force to use average mode
(complete 0)

(set FW_dest
	(askdir
		(prompt "In welcher Disk/Schublade soll Final Writer erstellt werden?")
		(help "Das Installationsprogramm erstellt die Schublade "
			"\"FinalWriter_D\" in diesem Verzeichnis. Alle Dateien von "
			"\"Final Writer\" werden in dieses Verzeichnis gestellt. \n\n"
			"Tip für erfahrene Benutzer:\n"
			"\"Final Writer\" kann auch in ein anderes Verzeichnis "
			"verschoben werden, wenn die Unterverzeichnisse:\n"
			"FWFiles, FWFonts, FWLibs, FWThes und FWSpell\n"
			"ebenfalls an die neue Position des Programms verschoben "
			"werden.")
		(default @default-dest)
	)
)

; Check if this is an update
; the FWLibs directory is a tell-tale sign
; that FW is already installed here
(if (exists (tackon FW_dest "FWLibs"))
	(set is_update 1)
	(	(if (exists (tackon FW_dest "FinalWriter_D"))
			(set is_update 1)
			(makedir (tackon FW_dest "FinalWriter_D") (infos))
		)
		(set FW_dest (tackon FW_dest "FinalWriter_D"))
	)
)

(set @default-dest FW_dest)
(set disk_space (getdiskspace FW_dest))


; If first time install ask user if he wants a complete
; or a minimal installation. The minimal installation
; will not install the eps clip art or the extra fonts.
(if (NOT is_update)
	(
		(set install_all
			(askbool
				(prompt "Wünschen Sie eine \"Vollständige\" oder "
					"\"minimale\"  Installation von Final Writer? Die "
					"vollständige Installation erfordert ca. 9,5 MByte "
					"freien Speicherplatz auf der Disk, die Minimal- "
					"Installation ca. 2,5 MByte.")

				(help "Bei Auswahl von \"Vollständig\" werden alle "
						"Dateien des Diskettensatzes von Final Writer "
						"installiert. Dafür sind ca. 9,5 MByte freier "
						"Speicherplatz auf der Disk erforderlich. Bei "
						"Auswahl von \"Minimal\" werden die ARexx-"
						"Makros, EPS Clip Art und zusätzliche Schriftarten "
						"nicht installiert. Die Minimalinstallation erfordert "
						"ca. 2,5 MByte freien Speicherplatz auf der Disk.")

				(choices "Vollständig" "Minimal")

				(default 1)
			)
		)

		(if install_all
			(set disk_space_needed 9794048)	; 9.34 Megs
			(set disk_space_needed 2810183)	; 2.68 Megs
		)
	)
)


(if (AND (< disk_space disk_space_needed) (NOT is_update))
	(
		(set answer1
			(askbool
				(prompt "Auf dem Laufwerk ist möglicherweise nicht "
					"genügend Platz für die Installation von "
					"\"Final Writer\".  Dennoch fortsetzen?")
				(help "Final Writer benötigt für die vollständige "
					"Installation ca. 9,5 MByte freien Speicherplatz auf "
					"der Disk, für die Minimalinstallation ca. 2,5 "
					"MByte. Wenn Final Writer auf dieser Partition "
					"bereits installiert ist, können Sie die Installation "
					"fortsetzen. Andernfalls drücken Sie ABBRUCH "
					"oder NEIN und schaffen danach entweder Platz "
					"auf dieser Partition oder wählen eine andere "
					"Partition für die Installation aus.")
			)
		)
		(if (NOT answer1)
			(abort "Installation von Final Writer abgebrochen. Zu wenig "
				"Speicherplatz auf dem Datenträger \""
					(getdevice @default-dest)
					"\"."
			)
		)
	)
)

; Allow updating user to select what they want updated
(if is_update
	(set install_options
		(askoptions
			(prompt "Welche Komponenten sollen aktualisiert werden?")
			(help @askoptions-help)
			(choices
				"Final Writer - Programm"
				"ARexx-Makros"
				"Systemdatendateien"
				"Systembibliotheken"
				"Systemschriftarten"
				"Rechtschreibprüfung & Silbentrennung"
				"Thesaurus"
				"EPS Clip Art"
				"Zusätzliche Schriftarten")
			(default 9)
		)
	)
	
	; First time install
	(if install_all
		(set install_options 511)  ; hex 1FF - all nine options on
		(set install_options 125)	; hex 07D - Macros, EPS, and Extra fonts off
	)
)

; Copy the extraction utility over and remember where it is
(copyfiles
	(source "Disk 1:lhex")
	(dest FW_dest)
)
(set DeArcher (tackon FW_dest "lhex"))
(set error 0)

; Installing Files on Disk 1?
(if (IN install_options 0 1 2 3)
	(
		; Get Disk 1
		(askdisk
			(prompt "Bitte \"Diskette 1\" einlegen." )
			(help	"Diskette 1 enthält das Programm Final Writer, Makros, "
 					"Bibliotheken und die auf dem System zu installierenden "
					"Datendateien.")
			(dest "Disk 1" )
		)

		; Copy the More program to the hard drive
		; so everyone is guaranteed to have it.
		(if (NOT is_update)
			(copyfiles
				(source "Disk 1:More")
				(dest FW_dest)
			)
		)

		; If installing/updating the program
		(if (IN install_options 0)
			(
				; Make installer cd into FW_dest when it executes the run statement
				(set @execute-dir FW_dest)

				; copy the Final Writer program over if the program
				; icon doesn't exists copy it over too.
				( if (exists (tackon FW_dest "FinalWriter.info"))
					; This DOES NOT copy the icon, in case the user
					; has modified the tool-types
					(
						(working "Programm Final Writer wird von "
									"Diskette 1 installiert.")
						(set error
							(run
								("\"%s\" -f x \"Disk 1:FinalWriter.lha\" FinalWriter >NIL:" DeArcher)
							)
						)
					)
					; This DOES copy the icon
					(
						(working "Programm und Piktogramm Final "
									"Writer werden von Diskette 1 installiert." )
						(set error
							(run
								("\"%s\" -f x \"Disk 1:FinalWriter.lha\" >NIL:" DeArcher)
							)
						)
					)
				)
			)
		)

		(if error
			(abort ("Fehler bei Installation des Programms FinalWriter."))
		)

		(complete 4)

		; Installing FWMacros
		(if (IN install_options 1)
			(
				; If FWMacros doesn't exist, create it.
				(if (NOT (exists (tackon FW_dest "FWMacros")))
					(
					(makedir (tackon FW_dest "FWMacros") (infos))
					)
				)

				; Make installer cd into FWMacros when it executes the run statement
				(set @execute-dir (tackon FW_dest "FWMacros"))

				; Extract the macro files
				(working "ARexx-Makros werden von Diskette 1 installiert.")
				(set error
					(run
						("\"%s\" -f x \"Disk 1:FWMacros.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der ARexx-Makros."))
				)
			)
		)

		(complete 7)

		; Installing FWFiles
		(if (IN install_options 2)
			(
				; If FWFiles doesn't exist, create it.
				(if (NOT (exists (tackon FW_dest "FWFiles")))
					(
					(makedir (tackon FW_dest "FWFiles") (infos))
					)
				)

				; Make installer cd into FWFiles when it executes the run statement
				(set @execute-dir (tackon FW_dest "FWFiles"))

				; Extract the files
				(working "Datendateien werden von Diskette 1 installiert.")
				(set error
					(run
						("\"%s\" -f x \"Disk 1:FWFiles.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der Datendateien."))
				)
			)
		)

		(complete 11)

		; Installing FWLibs
		(if (IN install_options 3)
			(
				; If FWLibs doesn't exist, create it.
				(if (NOT (exists (tackon FW_dest "FWLibs")))
					(
					(makedir (tackon FW_dest "FWLibs"))
					)
				)

				; Make installer cd into FWLibs when it executes the run statement
				(set @execute-dir (tackon FW_dest "FWLibs"))

				(working "Bibliotheken werden von Diskette 1 installiert.")
				(set error
					(run
						("\"%s\" -f x \"Disk 1:FWLibs.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der Bibliotheken."))
				)
			)
		)
	)
)

(complete 14)

; Installing System Data Files/Libraries/Fonts
(if (IN install_options 4 5)
	(
		; Get Disk 2
		(askdisk
			(prompt "Bitte \"Diskette 2\" einlegen.")
			(help	"Diskette 2 enthält die auf dem System zu installierenden "
					"Systemschriftarten sowie die Dateien für Rechtschreibprüfung und "
  					"Silbentrennung von Final Writer." )
			(dest "Disk 2")
		)

		; Installing FWFonts
		(if (IN install_options 4)
			(
				; If FWFonts doesn't exist, create it.
				(if (NOT (exists (tackon FW_dest "FWFonts")))
					(
					(makedir (tackon FW_dest "FWFonts") (infos))
					)
				)

				; Make installer cd into FWFonts when it executes the run statement
				(set @execute-dir (tackon FW_dest "FWFonts"))

				(working "Systemschriftarten werden von Diskette 2 installiert.")
				(set error
					(run
						("\"%s\" -f x \"Disk 2:FWFonts.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der Systemschriftarten."))
				)
			)
		)

		(complete 19)

		; Instaling FWSpell
		(if (IN install_options 5)
			(
				; If FWSpell doesn't exist, create it.
				(if (NOT (exists (tackon FW_dest "FWSpell")))
					(
					(makedir (tackon FW_dest "FWSpell"))
					)
				)

				; Preserve the user dictionary as userdict.grm.save
				(if (exists (tackon FW_dest "FWSpell/userdict.grm"))
					(
						(set restore_UD 1)
						(copyfiles
							(source (tackon FW_dest "FWSpell/userdict.grm"))
							(dest (tackon FW_dest "FWSpell"))
							(newname "userdict.grm.save")
						)
					)
					(set restore_UD 0)
				)

				; Make installer cd into FWSpell when it executes the run statement
				(set @execute-dir (tackon FW_dest "FWSpell"))

				(working "Dateien für Rechtschreibprüfung & Silbentrennung werden "
							"von Diskette 2 installiert.")
				(set error
					(run
						("\"%s\" -f x \"Disk 2:FWSpell.lha\" >NIL:" DeArcher)
					)
				)

				(if restore_UD
					(
						(copyfiles
							(source (tackon FW_dest "FWSpell/userdict.grm.save"))
							(dest (tackon FW_dest "FWSpell"))
							(newname "userdict.grm")
						)
						(delete (tackon FW_dest "FWSpell/userdict.grm.save"))
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der Dateien für die "
						"Rechtschreibprüfung."))
				)
			)
		)
	)
)

(complete 29)

(if (IN install_options 6 7)
	(
		; Get Disk 3
		(askdisk
			(prompt "Bitte \"Diskette 3\" einlegen.")
			(help	"Diskette 3 enthält die auf dem System zu installierenden "
					"Thesaurusdateien von Final Writer und die EPS Clip Art.")
			(dest "Disk 3")
		)

		; Instaling FWThes
		(if (IN install_options 6)
			(
				; If FWThes doesn't exist, create it.
				(if (NOT (exists (tackon FW_dest "FWThes")))
					(
					(makedir (tackon FW_dest "FWThes"))
					)
				)

				; Make installer cd into FWThes when it executes the run statement
				(set @execute-dir (tackon FW_dest "FWThes"))

				(working "Thesaurusdateien werden von Diskette 3 installiert.")
				(set error
					(run
						("\"%s\" -f x \"Disk 3:FWThes.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der Thesaurusdateien."))
				)
			)
		)

		(complete 32)

		; Installing EPS Clip Art <cc> <fed> <maps> <metro1>
		(if (IN install_options 7)
			(
				; If FWClipArt doesn't exist, create it.
				(if (NOT (exists (tackon FW_dest "FWClipArt")))
					(
					(makedir (tackon FW_dest "FWClipArt"))
					)
				)

				; Make installer cd into FWClipArt when it executes the run statement
				(set @execute-dir (tackon FW_dest "FWClipArt"))

				(working "EPS Clip Art wird von Diskette 3 installiert.")

				(set error
					(run
						("\"%s\" -f x \"Disk 3:cc.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der EPS Clip Art."))
				)

				(complete 35)

				(set error
					(run
						("\"%s\" -f x \"Disk 3:fed.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der EPS Clip Art."))
				)

				(complete 37)

				(set error
					(run
						("\"%s\" -f x \"Disk 3:maps.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der EPS Clip Art."))
				)

				(complete 40)

				(set error
					(run
						("\"%s\" -f x \"Disk 3:metro1.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der EPS Clip Art."))
				)
			)
		)
	)
)

(complete 43)

(if (IN install_options 7)
	(
		; ----------
		; Get Disk 4
		;
		(askdisk
			(prompt "Bitte \"Diskette 4\" einlegen.")
			(help	"Diskette 4 enthält die auf dem System zu installierende EPS Clip Art.")
			(dest "Disk 4")
		)

		; Installing EPS Clip Art <dms> <totem>

		; If FWClipArt doesn't exist, create it.
		(if (NOT (exists (tackon FW_dest "FWClipArt")))
			(
			(makedir (tackon FW_dest "FWClipArt"))
			)
		)

		; Make installer cd into FWClipArt when it executes the run statement
		(set @execute-dir (tackon FW_dest "FWClipArt"))

		(working "EPS Clip Art wird von Diskette 4 installiert.")
		(set error
			(run
				("\"%s\" -f x \"Disk 4:dms.lha\" >NIL:" DeArcher)
			)
		)

		; Abort if any errors
		(if error
			(abort ("Fehler bei Installation der EPS Clip Art."))
		)

		(complete 50)

		(set error
			(run
				("\"%s\" -f x \"Disk 4:totem.lha\" >NIL:" DeArcher)
			)
		)

		; Abort if any errors
		(if error
			(abort ("Fehler bei Installation der EPS Clip Art."))
		)
	)
)

(complete 57)

(if (IN install_options 7 8)
	(
		; ----------
		; Get Disk 5
		;
		(askdisk
			(prompt "Bitte \"Diskette 5\" einlegen.")
			(help	"Diskette 5 enthält die auf dem System zu installierende EPS Clip Art "
 					"sowie zusätzliche dekorative und Serif-Schriftarten.")
			(dest "Disk 5")
		)

		; Instaling EPS Clip Art
		(if (IN install_options 7)
			(
				; Make installer cd into FWClipArt/Metro when it executes the run statement
				(set @execute-dir (tackon FW_dest "FWClipArt/Metro"))

				(working "EPS Clip Art wird von Diskette 5 installiert.")
				(set error
					(run
						("\"%s\" -f x \"Disk 5:Metro2.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der Dekorativen "
							"Schriftarten."))
				)
			)
		)

		(complete 62)

		; Instaling Decorative fonts
		(if (IN install_options 8)
			(
				; If FWFonts/SWOLFonts/Deco doesn't exist, create it.
				(if (NOT (exists (tackon FW_dest "FWFonts/SWOLFonts/Deco")))
					(
					(makedir (tackon FW_dest "FWFonts/SWOLFonts/Deco") (infos))
					)
				)

				; Make installer cd into Deco when it executes the run statement
				(set @execute-dir (tackon FW_dest "FWFonts/SWOLFonts/Deco"))

				(working "Dekorative Schriftarten werden von Diskette 5 installiert.")
				(set error
					(run
						("\"%s\" -f x \"Disk 5:Deco.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der Dekorativen "
 							"Schriftarten."))
				)
			)
		)

		(complete 66)

		; Instaling Serif1 fonts
		(if (IN install_options 8)
			(
				; If FWFonts/SWOLFonts/Serif doesn't exist, create it.
				(if (NOT (exists (tackon FW_dest "FWFonts/SWOLFonts/Serif")))
					(
					(makedir (tackon FW_dest "FWFonts/SWOLFonts/Serif") (infos))
					)
				)

				; Make installer cd into Serif when it executes the run statement
				(set @execute-dir (tackon FW_dest "FWFonts/SWOLFonts/Serif"))

				(working "Serif-Schriftarten werden von Diskette 5 installiert.")
				(set error
					(run
						("\"%s\" -f x \"Disk 5:Serif1.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der Serif1-Schriftarten."))
				)
			)
		)
	)
)

(complete 71)

(if (IN install_options 8)
	(
		; ----------
		; Get Disk 6
		;
		(askdisk
			(prompt "Bitte \"Diskette 6\" einlegen.")
			(help	"Diskette 6 enthält auf dem System zu installierende, zusätzliche "
					"Serif-Schriftarten.")
			(dest "Disk 6")
		)

		; Instaling Serif2 fonts
		(if (IN install_options 8)
			(
				; If FWFonts/SWOLFonts/Serif doesn't exist, create it.
				(if (NOT (exists (tackon FW_dest "FWFonts/SWOLFonts/Serif")))
					(
					(makedir (tackon FW_dest "FWFonts/SWOLFonts/Serif") (infos))
					)
				)

				; Make installer cd into Serif when it executes the run statement
				(set @execute-dir (tackon FW_dest "FWFonts/SWOLFonts/Serif"))

				(working "Serif-Schriftarten werden von Diskette 6 installiert.")
				(set error
					(run
						("\"%s\" -f x \"Disk 6:Serif2.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der Serif2-Schriftarten."))
				)
			)
		)
	)
)

(complete 86)

(if (IN install_options 8)
	(
		; ----------
		; Get Disk 7
		;
		(askdisk
			(prompt "Bitte \"Diskette 7\" einlegen.")
			(help	"Diskette 7 enthält auf dem System zu installierende, zusätzliche "
					"serifenlose Schriftarten.")
			(dest "Disk 7")
		)

		; Instaling Sans serif fonts
		(if (IN install_options 8)
			(
				; If FWFonts/SWOLFonts/Sans doesn't exist, create it.
				(if (NOT (exists (tackon FW_dest "FWFonts/SWOLFonts/Sans")))
					(
					(makedir (tackon FW_dest "FWFonts/SWOLFonts/Sans") (infos))
					)
				)

				; Make installer cd into Sans when it executes the run statement
				(set @execute-dir (tackon FW_dest "FWFonts/SWOLFonts/Sans"))

				(working "Serifenlose Schriftarten werden von Diskette 7 installiert.")
				(set error
					(run
						("\"%s\" -f x \"Disk 7:Sans.lha\" >NIL:" DeArcher)
					)
				)

				; Abort if any errors
				(if error
					(abort ("Fehler bei Installation der Serifenlosen "
 							"Schriftarten."))
				)
			)
		)
	)
)

; If FWDocs doesn't exist, create it.
(if (NOT (exists (tackon FW_dest "FWDocs")))
	(
	(makedir (tackon FW_dest "FWDocs") (infos))
	)
)

; If FWTextClips doesn't exist, create it.
(if (NOT (exists (tackon FW_dest "FWTextClips")))
	(
	(makedir (tackon FW_dest "FWTextClips") (infos))
	)
)

(delete DeArcher)

(complete 100)

(exit)


