; $VER: RTracker_Install 1.0 (Tuesday 15-Sep-92)
; RTracker System Installation Script

(complete 0)

;==================================================================
;Constants
;==================================================================

(set #AskForDir
   (cat
      "Where should I install RTracker and it's support files??"  
   )
)

(set #AskForDir_help
   (cat
      "Enter the directory where RTracker and it's support files"
      " should be installed.  If the directory doesn't exist,"
      " specify it anyway, and use the create directory gadget.\n\n"
   )
)

(set #CopyRTracker
   (cat
      "The following files will be copied into the directory"
      " you specified."
   )
)

(set #CopyRTracker_help
   (cat
      "This will copy RTracker, RTInterface, and all support"
      " files into the drawer you specified.\n\n"
   )
)

(set #CopyLibs
   (cat
      "The following library needs to be installed for RTracker to work.\n"
   )
)

(set #CopyLibs_help
   (cat
      "You do not have the proper libraries to run RTracker.  This will"
      " install them for you.\n\n"
   )
)
;==================================================================
;Main
;==================================================================


(set @default-dest 
   (tackon @default-dest "RTracker")
)

(complete 3)

(set myans 
	(askbool
		(prompt "Would you like to install RTracker in "
                 @default-dest
		 "?"
		)
		(help "If you would like to install RTracker in "
		      @default-dest
		      ", answer YES.  If you would like to choose your"
                      " own directory, select NO\n\n"
                      @askbool-help
              	)
		(choices "Yes" "No")
		(default "Yes");
	)
)

(if (NOT myans) 
(
(set RTracker_dest
      (askdir (prompt #AskForDir) 
              (help #AskForDir_help
                    @askdir-help
              )
              (default @default-dest)
      )
)
)
)

(if myans
	(
		(run (cat "makedir " @default-dest))
		(set RTracker_dest @default-dest) 
	)
)

(set @default-dest RTracker_dest)

(complete 6)

(set #notice
   (cat
      "Installed RTracker into "
      @default-dest
      "."
   )
)


; Okay, we got a directory to dump everything into, so we make it the 
; default directory

;(set @default-dest RTracker_dest)

; First, we copy RTracker and stuff to that directory.

(copyfiles
   (prompt #CopyRTracker)
   (source "")
   (dest RTracker_dest)
   (pattern "(RT#?|De#?|mm)")
   (infos)
   (confirm)
   (help
      #CopyRTracker_help
      @copyfiles-help
   )
)

(complete 9)

; Modify User-Startup

(set #RTAssigns
   (cat
      "Assign Prefs: "
      RTracker_dest
   )
)

(startup
   "RTracker"
   (prompt "One command needs to be added to your s:User-Startup file"
           " in order to use RTracker.\n"
           "The command is:\n\n"
           #RTAssigns
           "\n\nDo you want it to be added?"
   )

   (help (cat
          "The assign:\n\n"
          #RTAssigns
          "\nneeds to be made before running the software.  This will"
          " do it for you.\n\n\n"
         )
         @startup-help
   )
   (command #RTAssigns)   
)

(complete 12)

(run #RTAssigns)

(complete 15)

(if (NOT(exists "Libs:DesTracker.Library"))
   (copyfiles
      (prompt #CopyLibs)
      (help #CopyLibs_help @copyfile-help)
      (source "libs/")
      (dest "Libs:")
      (pattern "Des#?.library")  
      (confirm)     
   )
)

(complete 18)

(if (NOT(exists "Libs:RexxHost.Library"))
   (copyfiles
      (prompt #CopyLibs)
      (help #CopyLibs_help @copyfile-help)
      (source "libs/")
      (dest "Libs:")
      (pattern "RexxHost.library")  
      (confirm)     
   )
)

(complete 21)

;Okay, now we set up Decompress

;Make a directory for it
(set Decompress_dest
      (askdir (prompt "Please create a directory that will be used to"
                      " decompress files.  WARNING:  This must be a"
                      " PERMANENT, and EMPTY directory.  It must STAY"
                      " empty!  RTracker will delete the contents of this"
                      " directory often.") 
              (help "In able to decompress files, RTracker must have a free"
                   " directory to use.  This gives you the chance to make one."
                   "  After decompression, the decompressed file will reside"
                   " here until the next time you decompress something.\n\n"
                    @askdir-help
              )
              (default @default-dest)
      )
)

(complete 24)

(set decompress 0)

(complete 27)

;LHA
(set LHA_start "#?.LHA|")
(set LHA_end "lha >con:0/0/500/100/Decompressing e \"%\" ")


;PP Decrunch
(set PP_start "#?.pp|")
(set PP_end "decrunch >con:0/0/500/100/Decompressing \"%\" ")


(if (exists "c:Lha")
   (
   (working "Setting up LHA decompression.")
   
   (textfile 
      (dest "t:LHA.temp")
      (append 
         (cat
            LHA_start
            "c:"
            LHA_end
            (tackon
               Decompress_dest
               "|"
            )
            Decompress_dest
            "|"
         )
      )
      (prompt "Finished setting up LHA decompression")
   )   
   
   (set decompress 1)
   )
)

(complete 30)

(if (exists "c:decrunch")
   (
   (working "Setting up Decrunch (PowerPacker) decompression.")

   (textfile 
      (dest "t:PP.temp")
      (append 
         (cat
            PP_start
            "c:"
            PP_end
            Decompress_dest
            "|"
            Decompress_dest
            "|"
         )
      )
      (prompt "Finished setting up Decrunch (PowerPacker) decompression.")
   )
   
   (set decompress 1)
   )
)

(complete 33)

(set LHADecompress_dest 0)
(set PPDecompress_dest 0)





(if (NOT(exists "c:lha"))
   (
   
   
      (if
      
      
        (askbool
           (prompt "LHA was not found in your c: directory.  Would you like to"
                   " read it from another place?"
           )
           (help "RTracker needs to be able to load and run LHA from the directory"
                 " you will specify, so it is important that the location of LHA"
                 " is readily available.  If you don't want to use LHA as a"
                 " decompressor, or don't have LHA, answer NO.\n\n "
                 @askbool-help
           )
           (default "Yes")
           (choices "Yes" "No")
        )
      
      (
      
         (set LHADecompress_dest
            (askdir (prompt "Please enter directory where LHA exists.") 
                  (help "In able to decompress LHA files, RTracker must have"
                        "  access"
                        " to LHA.  This gives you the chance to specify where it"
                        " is.\n\n"
                        @askdir-help
                  )
                  (default @default-dest)
            )
         );set
         (working "Setting up LHA decompression.")
         (textfile 
            (dest "t:LHA.temp")
            (append 
               (cat
                  LHA_start
                  (tackon
                        LHADecompress_dest
                        LHA_end
                  )
                  (tackon 
                     Decompress_dest
                      "|"
                  )
                  Decompress_dest
                  "|"
               )
            )
            (prompt "Finished LHA Decompression")
         )   
         (set decompress 1)      
      
      
      );if askbool container
      
      
      );if askbool  
      
      
   ) ;if exists container     
);if exists




(complete 36)


(if (NOT(exists "c:decrunch"))
   (
   
   
      (if
      
      
        (askbool
           (prompt "Decrunch was not found in your c: directory."
                   " Would you like to read it from another place?"
           )
           (help "RTracker needs to be able to load and run Decrunch from"
                 " the directory you will specify, so it is important that"
                 " the location of Decrunch is readily available.  If you"
                 " don't want to use Decrunch as a decompressor, or don't"
                 " have the program, answer NO.\n\n"
                 @askbool-help
           )
           (default "Yes")
           (choices "Yes" "No")
        )
      
      (
      
         (set PPDecompress_dest
            (askdir (prompt "Please enter the directory where PP Decrunch exists.")
                  (help "In able to decompress PowerPacker files, RTracker"
                        " must have access to PowerPacker's Decrunch utility."
                        "  This gives you the chance to specify where it"
                        " is.\n\n"
                        @askdir-help
                  )
                  (default @default-dest)
            )
         );set
         (working "Setting up PowerPacker decompression.")
         (textfile 
            (dest "t:PP.temp")
            (append 
               (cat
                  PP_start
                  (tackon
                        PPDecompress_dest
                        PP_end
                  )
                  Decompress_dest
                  "|"
                  Decompress_dest
                  "|"
               )
            )
            (prompt "Still creating Finished PowerPacker prefs")
         )   
         (set decompress 1)      
      
      
      );if askbool container
      
      
      );if askbool  
      
      
   ) ;if exists container     
);if exists

(complete 39)

(if (exists "t:LHA.temp")
 (
   (run "type >>t:Decompress.RTPrefs t:LHA.temp")
   (run "delete t:LHA.temp")
 )
)


(complete 42)

(if (exists "t:PP.temp")
  (
   (run "type >>t:Decompress.RTPrefs t:PP.temp")
   (run "delete t:PP.temp")
  )
)


(complete 45)

(run "type >>t:Decompress.RTPrefs AtSign.cp")
(complete 48)
(run (cat "c:copy t:Decompress.RTPrefs " RTracker_dest))
(complete 51)
(run "c:delete t:Decompress.RTPrefs")
(complete 54)

;Okay, we do prefs.
(working "Creating Prefs")

(run 
   (
      cat "copy RTPrefs.cp " (tackon RTracker_dest "RTPrefs")
   )
)

(complete 57)

(textfile 
   (dest "t:RTDEST")
   (append (cat RTracker_dest "\n"))
   (prompt "Creating RTPrefs")
)

(complete 60)

(set Mods_dest
   (askdir
      (prompt "Please select the directory where you usually keep your"
              " MODs"
      )
      (help (cat "This will set RTracker's default directory.\n\n")
            @askdir-help
      )
      (default @default-dest)
   )
)

(complete 63)

(textfile 
   (dest "t:MODDEST")
   (append (cat Mods_dest "\n"))
   (prompt "Still creating RTPrefs")
)

(complete 66)

(textfile 
   (dest "t:UNDEST")
   (append "Unused\n")
   (prompt "Still creating RTPrefs")
)

(complete 69)

(working "Finishing off RTPrefs.")

(run 
   (cat "Type >>" (tackon RTracker_dest "RTPrefs") " t:RTDEST")
)

(complete 72)

(run 
   (cat "Type >>" (tackon RTracker_dest "RTPrefs") " t:MODDEST")
)

(complete 75)

(run 
   (cat "Type >>" (tackon RTracker_dest "RTPrefs") " t:UNDEST")
)

(complete 78)

(working "Cleaning up...")
(run "delete t:RTDEST")
(complete 81)
(run "delete t:MODDEST")
(complete 84)
(run "delete t:UNDEST")
(complete 87)
(run 
   (cat
      "delete "
      (tackon
         RTracker_dest
         "RTPrefs.cp"
      )
   )
)

(complete 100)
(exit)
