(set ELVersion "1.10")
(set ELDate "Apr 1995")

(transcript ("Installing Easylife V" ELVersion " - " ElDate))


(set TempLoc "RAM:ELInstall")

(set ProSys "AMOSPro_System:")
(set ProAcc "AMOSPro_Accessories:")

(set InstToHard 0)



; Procedure To Install Libs on A harddisk




(message (cat "Welcome To The Easylife " ELVersion 
              "\nInstallation Utility\n\nBy Paul Hickman - " ELDate
              "\n\nThis program will copy all neccessary files to "
              "the appropriate places for your system - all you'll then "
              "have to do is run the AMOSPro interpreter configuration "
              "program to install the easylife extension.\n\n\n"
              "Help is available during most phases of this installation -"
              " just press the help button"
))
(message (cat "If things go wrong during this installation, and the "
              "installer crashes, it should be safe to begin again with "
              "the package partially installed.\n\n"
              "Problems may occur if the files that are to be overwritten "
              "are write/delete protected, or if there is no 'C:Relabel' "
              "command available (Floppy Disk Installation Only)."
))
(welcome)




; Now ask where to install to.

(set InstToHard 
    (askchoice
        (prompt "Where do your wish to install EasyLife? A Floppy installation will copy the libraries, and Easylife extension to the appropriate places on your AMOSPro disks. A harddisk installation will copy all files to the appropriate parts of your harddisk.")
        (choices "Floppy Disk"
                 "Hard Disk")
        (help "I know I said help was available on most parts of the installation, but if you need help with this choice, you don't deserve the priviledge of using my software!")
        (default 1)
     )
)

(if (= InstToHard 0)
    
(
    (message "Floppy Disk Installation\n\n\nFor this to work correctly, you must have extracted the easylife archives to the root directories of 2 blank floppy disks. If you haven't abort now, and move them.")

	(if (= (exists TempLoc) 2)
		(delete TempLoc)
	)
    (makedir TempLoc)

    ; Copy libraries / Extensions to RAM: is installing to floppies to save
    ; on disk swaps.

    (foreach "Libs/" "#?"
        (copyfiles
            (help @copyfiles-help)
            (prompt "Copying Libraries To RAM:")
            (source (tackon "Libs/" @each-name))
            (dest TempLoc)
            (noposition)
        )
    )

    (foreach "Lib/" "#?"
        (copyfiles
            (help @copyfiles-help)
            (prompt "Copying Extension Data To RAM:")
            (source (tackon "Lib/" @each-name))
            (dest TempLoc)
            (noposition)
        )
    )
    
    ;Installation of libraries

    (
       (set #destdir 
           (askdir
               (prompt "Please select your AMOS Pro Bootdisk's LIBS: directory.")
               (help @askdir-help)
               (default (tackon ProSys "Libs"))
           )
       )
   
       (foreach TempLoc "#?.Library"
           (copylib
               (help @copylib-help)
               (prompt "Installing Libraries...")
               (source (tackon TempLoc @each-name))
               (dest #destdir)
               (noposition)
            )
        )
    )
              
    ;Now install the Easylife Extensions files...

    (set InstExtHelp (cat
	"The easylife extension file \"AMOSPro_Easylife.Lib\" will be "
	"copied to your APSystem directory. Also, the Default resource "
	"bank will be updated.  This update will not have any effect on "
	"programs which used the old version, but some easylife programs "
	"require the addition images provided by this update. See the "
	"\"DefaultResource.guide\" file for more information."
    ))

    (set #destdir 
        (askdir
            (prompt "Please select your AMOSPro_System disks AP_System directory.")
            (help InstExtHelp)
            (default (tackon ProSys "APSystem"))
        )
    )

    (copyfiles
        (help @copyfiles-help)
        (prompt "Installing Easylife Extension...")
        (source (tackon TempLoc "AMOSPro_EasyLife.Lib"))
        (dest #destdir)
        (noposition)
    )

    (copyfiles
        (help @copyfiles-help)
        (prompt "Installing New Default Resource Bank...")
        (source (tackon TempLoc "AMOSPro_Default_Resource.Abk"))
        (dest #destdir)
        (noposition)
    )


    (set InstIFFHelp (cat
	"This step will overwrite the Default_Resource.IFF file with the "
	"IFF picture from which the improved default resouce bank was "
	"generated."
    ))

    (set #destdir 
        (askdir
            (prompt "Please select your AMOSPro System_IFFs drawer")
            (help InstIFFHelp)
            (default (tackon ProAcc "System_Iffs"))
        )
    )

    (copyfiles
        (help @copyfiles-help)
        (prompt "Installing Easylife Pro...")
        (source (tackon TempLoc "Default_Resource.Iff"))
        (dest #destdir)
        (noposition)
    )


    ;Floppy Installation - Relabel the disk!

    
    (if (patmatch "df?" (getdevice @icon ))
        
         (
         ; If the installer project icon is on a floppy disk ...
         
         (set srcdisk (expandpath (cat (getdevice @icon) ":")))
         (if (<> srcdisk "EasyLife1:")
            (
                (set @execute-dir srcdisk)        
                (run (cat "c:relabel " srcdisk " Easylife1") (prompt (cat "Relabelling the disk \"" srcdisk "\" which contains part 1 of the package to\n\nEasyLife1:")) (help "Which bit didn't you understand????") (confirm))
            )
         )
         )
    )

    ;Test if disk2 is available...
    ;
    (if (= 0 (exists "Readme_P2.Doc"))
        (set src2dir 
            (askdir
                (prompt ( "Please select the directory containing the second part of the extracted easylife archive. (Easylife" ELVersion "_P2.lha)"))
                (help "If you have not extracted it, and have enough memory, start a shell, and extract it now. Otherwise you will have to extract it, then start this installation again.")
                (default ("Easylife2:"))
            )
        )

        ;Else, if both disks are extracted to the same directory...
   
	(abort "You MUST extract the 2 parts of the easylife archive to seperate disks for a floppy disk installation.")
    )

    (if (patmatch "df?" (getdevice src2dir ))
        
         (
         ; If the installer project icon is on a floppy disk ...
         
         (set srcdisk (expandpath (cat (getdevice src2dir) ":")))
         (if (<> srcdisk "EasyLife2:")
            (
                (set @execute-dir srcdisk)        
                (run (cat "c:relabel " srcdisk " Easylife2") (prompt (cat "Relabelling the disk \"" srcdisk "\" which contains part 2 of the package to\n\nEasyLife2:")) (help "Which bit didn't you understand????") (confirm))
            )
         )
         )
    )

    (startup "Easylife" (command "Assign >NIL: HELP: EasyLife2:Docs ADD")
        (prompt (cat 
            "Shall I 'ADD' the EasyLife2:Docs directory to the HELP: assignment "        
            "by adding a line to the current bootdisks S:User-Startup file?\n\n"
            "I strongly suggest you do this, or add the assignment manually. "
            "If the current S: is not the AMOSPro bootdisk, you could reassign "
            "S: from a shell window before proceeding.\n\n"
            "Press the 'Help' button for more info..."
        ))
        (help (cat
            "Some of the accessory programs allow you to load their help "
            "files by pressing the 'Help' key while they are running. "
            "To do this, they need to be able to find the help file, so "
            "they look in 'HELP:'. Therefore you must make sure the "
            "directory containing the help is assigned to HELP: before "
            "these programs are run.\n\n"
            "One way of doing this is to add a line to make the assignment "
            "to your S:User-startup file. An alternative is to write a "
            "script file to load AMOSPro, so the assign is only made when "
            "AMOSPro is loaded.\n"
            "If you have not booted from the AMOSPro disk, open a shell "
            "(Or select 'Execute Command...' from the Workbench Menu) "
            "and type 'Assign S: AMOSPro_System:s' before responding to "
            "this requester with proceed."            
        ))            
    )
   


    (complete 100)
    (set @default-dest "Easylife2:")
    (exit (cat 
               "You should now install the easylife extension into position "
               "16 with the AMOSPro Interpreter Configuration Program.\n\n"
               "The AmigaGuide documentation describes how to install the "
               "accessory programs for use from the AMOSPro editor."
    ))
    
)









;
;Hard disk installation.
;

(
	(message (cat
		"You will find it easier to perform this installation if you "
		"run AMOSPro now, then quit again, so it creates the assigns "
		"for the AMOSPro_System:, AMOSPro_Accessories:, etc. directories. "
		"This is not pre-requisite for the installation - it just makes "
		"it quicker for you to select directories.\n\n"
		"Make sure you have extracted both easylife archives either to "
		"floppy disk or temporary directories in RAM: / on your harddisk "
		"before proceeding any further with this installation."
	))

	;Hard disk library installation

    (set #destdir 
        (askdir
            (prompt "Please select your harddisk's LIBS: directory.")
            (help (cat  "The Powerpacker, Pattern & Easylife libraries "
						"will be added to you libs, unless newer "
						"versions are already there.\n\nEasylife "
						"is the only library that is required to load "
						"the extension, but certain commands & functions "
						"will require these other libraries.\n\nTo use "
						"all easylife functions, you will also require "
						"the xpkmaster library, some XPK compressor "
						"libraries, and the MUI system libraries."
			))
            (default "LIBS:")
        )
    )
 
    (foreach "Libs/" "#?.Library"
        (copylib
            (help @copylib-help)
            (prompt "Installing Libraries...")
            (source (tackon "Libs/" @each-name))
            (dest #destdir)
            (noposition)
        )
    )
    

    ;Now install the Easylife Extensions files...

    (set InstExtHelp (cat
	"The easylife extension file \"AMOSPro_Easylife.Lib\" will be "
	"copied to your APSystem directory. Also, the Default resource "
	"bank will be updated.  This update will not have any effect on "
	"programs which used the old version, but some easylife programs "
	"require the addition images provided by this update. See the "
	"\"DefaultResource.guide\" file for more information."
    ))

    (set #destdir 
        (askdir
            (prompt "Please select your APSystem directory.")
            (help InstExtHelp)
            (default (tackon ProSys "APSystem"))
        )
    )

    (copyfiles
        (help @copyfiles-help)
        (prompt "Installing Easylife Extension...")
        (source "Lib/AMOSPro_EasyLife.Lib")
        (dest #destdir)
        (noposition)
    )

    (copyfiles
        (help @copyfiles-help)
        (prompt "Installing New Default Resource Bank...")
        (source "Lib/AMOSPro_Default_Resource.Abk")
        (dest #destdir)
        (noposition)
    )


    (set InstIFFHelp (cat
	"This step will overwrite the Default_Resource.IFF file with the "
	"IFF picture from which the improved default resouce bank was "
	"generated."
    ))

    (set #destdir 
        (askdir
            (prompt "Please select your AMOSPro System_IFFs drawer")
            (help InstIFFHelp)
            (default (tackon ProAcc "System_Iffs"))
        )
    )

    (copyfiles
        (help @copyfiles-help)
        (prompt "Installing Default Resource Bank IFF Picture")
        (source "Lib/Default_Resource.Iff")
        (dest #destdir)
        (noposition)
    )

    ;Now install the easylife accessory programs.

	(set #destdir 
        (askdir
            (prompt (cat "Where abouts on your harddisk would you like to "
					  "put new accessory programs? I strongly recommend "
					  "your AMOSPro_Accessories: directory. Upto 350K "
					  "of AMOS programs will be copied here."
			))
            (help @askdir-help)
            (default "AMOSPro_Accessories:")          
         )
	)

    (copyfiles
        (help @copyfiles-help) 
        (prompt "Copying Accessory Programs To Harddisk.")
        (source "Accessories")
		(pattern "#?")
        (dest #destdir)
		(confirm)
    )


    ;Now find the second archive...
    ;

    (if (= 0 (exists "Readme_P2.Doc"))
        (set src2dir 
            (askdir
                (prompt ( "Please select the directory containing the second part of the extracted easylife archive. (Easylife" ELVersion "_P2.lha)"))
                (help "If you have not extracted it, and have enough memory, start a shell, and extract it now. Otherwise you will have to extract it, then start this installation again.")
                (default ("Easylife2:"))
            )
        )
    
        ;Else, if both parts are in the same source directory...

        (set src2dir (pathonly @icon))
               
    )
	
	;Now install the documentation files...

	(set #destdir 
        (askdir
            (prompt (cat "Where abouts on your harddisk would you like to "
			  "put the easylife documentation? My suggestions are "
			  "AMOSPro_Tutorial:, or your HELP: directory. 770k"
			  "will be required."
			))
            (help @askdir-help)
            (default "AMOSPro_Tutorial:")          
         )
	)

    (copyfiles
        (help @copyfiles-help) 
        (prompt "Copying Documentation To Harddisk.")
        (source (tackon src2dir "Docs"))
	(pattern "#?")
        (dest #destdir)
        (infos)
    )

    (startup "Easylife" (command (cat "Assign >NIL: HELP: " #destdir " ADD"))
        (prompt (cat 
            "Shall I 'ADD' the directory you just copied the documentation "
            "into to the HELP: assignment.\n\n If the directory you selected "
            "is not already assigned to HELP: I strongly suggest you do this, "
            "or add the assignment manually.\n\nIf you copied the docs into "
            "the HELP: drawer, then skip this part.\n\n"
            "Press the 'Help' button for more info..."
        ))
        (help (cat
            "Some of the accessory programs allow you to load their help "
            "files by pressing the 'Help' key while they are running. "
            "To do this, they need to be able to find the help file, so "
            "they look in 'HELP:'. Therefore you must make sure the "
            "directory containing the help is assigned to HELP: before "
            "these programs are run.\n\n"
            "One way of doing this is to add a line to make the assignment "
            "to your S:User-startup file. An alternative is to write a "
            "script file to load AMOSPro, so the assign is only made when "
            "AMOSPro is loaded."
        ))            
    )
   


    (set #destdir 
        (askdir
            (prompt (cat
                      "Where abouts on your harddisk would you like to "
					  "put the rest of the EasyLife distribution. An "
					  "Easylife sub-directory will be created here."
			))
            (help (cat
                    "An directory "EasyLife" will be created in the "
					"directory you select. Inside that, sub-directories "
					"will be created for Demos, MUI Data and Procedures."
			))
            (default @default-dest)
        )
    )

	(set @default-dest (tackon #destdir "Easylife"))
	(if (= (exists @default-dest) 0)
		(makedir @default-dest)
	)

    (copyfiles
        (help @copyfiles-help) 
        (prompt "Copying Easylife Programs & Data To Harddisk.")
        (source "")
        (pattern "(Demos|MUI|Procedures)")
        (dest @default-dest)
        (infos)
	(confirm)
    )

       
    (complete 100)
    (exit "You should now install the easylife extension into position 16 with the AMOSPro Interpreter Configuration Program.\n\nRead the AmigaGuide documentation on how to install the accessories into the editor.")

)

)
