; Install_RayStorm - RayStorm installation script for Installer
;
; Copyright © 1995 Andreas Heumann
;
; $Id: Install_RayStorm,v 1.0 1995/05/07
;
;     Installer and Installer project icon
;     (c) Copyright 1991-93 Commodore-Amiga, Inc.  All Rights Reserved.
;     Reproduced and distributed under license from Commodore.
;
;     INSTALLER SOFTWARE IS PROVIDED "AS-IS" AND SUBJECT TO CHANGE;
;     NO WARRANTIES ARE MADE.  ALL USE IS AT YOUR OWN RISK.  NO LIABILITY
;     OR RESPONSIBILITY IS ASSUMED.
;
;
(welcome "    Welcome to the " @app-name " 1.0 demo version installation.\n")

; What we are?
(set app-name (cat @app-name " 1.0 demo version"))

; "Needs"
(set need-version 37)  ; version of operating system need by RayStorm

; These directories are always present
(set dir-pat (cat "(" "docs" "|" "arexx" "|" "examples" "|" "textures" "|" "brushes" "|" "objects"  ")"))

; The source directory name
(set source-dir
 (if (= 1 (exists @icon))
  (pathonly (expandpath @icon))
  (expandpath @icon)
 )
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 check-system-version
 ;; is your Exec recent enough?
 (set exec-version (/ (getversion) 65536))
 (transcript "Running on exec version " exec-version ".")
 (if (< exec-version need-version)	; check operating system version
  (
   (message "The " @app-name " needs at least Exec version " need-version
	         " to run.\nYou have only version " exec-version ".\n"
	         "You can proceed with the installation, but consider "
	         "installing the " @app-name " with proper version of "
	         "the operating system."
	 (help "    The " @app-name " uses some system functions "
			"that are not present or functional in earlier system "
			"versions. Consider updating your system.\n"
			"    If you have a later version of operating system "
			"and are only now using older version: be sure to use "
			"only release 2.04 or newer with the " @app-name ". "
			"No damage happens if you run the " @app-name " with an "
			"earlier operating system, however. It just "
			"refuses to start.\n"
			"    If you decide to continue, no changes will be made to "
			"system startup files, so you must edit them yourself. "
			"Refer instructions for manual installation."
	 )
	)
   (transcript "User decided to continue installation while running "
		         "on operating system release earlier than 2.04."
	)
  )
 )
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure select-destination-directory
 ;; Select destination directory for the installation. We suggest the user
 ;; to install to the place from where the installer was started. This is
 ;; since normally this software will be unarchived to its proper location
 ;; and the files don't have to be copied any more.
 ;;
 (transcript "Selecting destination directory for the installation.")
 (while
  (
	(set @default-dest
	 (askdir
	  (prompt "Select directory where to install the " app-name ".\n"
	          "You have to create a directory for " app-name " yourself."
     )
	  (help "    Here you can specify location where to install "
			  "the " app-name ".\n"
			  "    Installation can be made on-place. "
			  "This is recommended if you have already unarchived "
			  "the " app-name " archive to its final location. "
			  "In this case "
			  "most of the files are left where they are. "
			  "Only necessary files are copied to different "
			  "positions.\n"
     )
	  (newpath)
	  (default source-dir)
    )
   )
   (if (= 2 (exists @default-dest))
	 0
	 (makedir @default-dest
	  (infos)
	 )
	)
  )
 )
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 copy-files-to-destination ;;; Copy all files if not installing on-place
 ;;
 (if (= source-dir (expandpath @default-dest))
  (message "\nSource and destination directories are the same, "
	        "not copying."
	(help "    The " app-name " files don't have to be copied, "
		   "since the source and the destination directories are "
		   "the same."
	)
  )
  ((transcript "Copying " app-name " files from " source-dir " to "
	            @default-dest "."
	)
   (set dir-information
	 (cat
	  (if (exists "docs")
	      "documentation\n"
	  )
	  (if (exists "arexx")
	     "ARexx examples\n"
	  )
	  (if (exists "examples")
	     "C examples\n"
	  )
	  (if (exists "textures")
	     "Textures\n"
	  )
	  (if (exists "brushes")
	     "Brushes\n"
	  )
	  (if (exists "Objects")
	     "Objects\n"
	  )
	 )
	)
   (if (< 0 (strlen dir-information))
    (foreach source-dir dir-pat
	  (
      (set dest-dir (tackon @default-dest @each-name))
	   (if (NOT (exists dest-dir))
	    (makedir dest-dir)
		)
	   (copyfiles (all)
		 (source (expandpath @each-name))
		 (dest dest-dir)
		 (prompt "Copying files to the selected location.")
		 (optional "askuser")
		)
	  )
	 )
	)
   (copyfiles (source source-dir)
	 (dest @default-dest)
	 (prompt "Copying files to the selected location.")
	 (pattern "#?")
	 (files)
	 (infos)
	 (optional "askuser")
   )
  )
 )
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Installatation sequence
;;;
(message "Please remember during this installation:\n\n"
	 "    Read the instructions provided behind the \"Help\" "
	 "buttons, if you are not absolutely sure what you are doing.\n"
)

(complete 00) (transcript "On making " app-name ".")
(complete 01) (check-system-version)
(complete 02) (select-destination-directory)
(complete 100) (copy-files-to-destination)

;;; All done!

; EOF

