;**************************************************
;
;$VER: PalomaFE V2.0 (Sept.1998)
;
; Title:
;    PalomaFE Installer
; 
; Description:
;    The Commodore Installer Script for PalomaFE
;
; Installer script by Pete Sullivan
;
;**************************************************

(set true 1)
(set false 0)
(set quote "\"")
(set nothing "")
(set WB2 (< 2293760 (getversion "exec.library" (resident)))) ; true if under 2.0

(set PalomaFE_dir (getassign "PalomaFE"))
(set c_dir (getassign "C"))
(set libs_dir (getassign "LIBS"))
(set fonts_dir (getassign "FONTS"))
(set devs_dir (getassign "DEVS"))
(set s_dir (getassign "S"))
(set wbstartup_dir (getassign "SYS:WBSTARTUP"))

(set Src_root "")
(set Src_c "c/")
(set Src_s "s/")
(set Src_libs "libs/")
(set Src_devs "devs/")
(set Src_rexx "rexx/")
(set Src_DATA "DATA/")
(set Src_Sullitech "/")
(set Src_docs "Docs/")
(set Src_fonts "Fonts/")
(set Src_WBStartup "WBStartup/")
(set Src_AmiFTP "AmiFTP/")
(set Temp_dir "ram:t/")

(set MSG_CopyDevs1 "\n\nCopying needed device ")
(set MSG_CopyDevs2 " to DEVS:")

; start with not updated software!

(set is_update false)

(if  (<> PalomaFE_dir nothing)
     (if  (askbool
               (prompt "\n\n\nAn earlier version of PalomaFE already exists in"
               " your drawer named: \n\n"
               quote PalomaFE_dir quote
               "\n\nDo you want the update installed over it?")
               (help
               "\n\n\nThe installer has determined that you already have a "
               "some version of the PalomaFE software installed "
               "on your system.  If this is wrong or you want the update "
               "installed elsewhere, select 'NO', otherwise select 'YES'."
               )
               (default 1)
          )
               (set is_update true) 

;else ask where to put software

               (
               (set PalomaFE_dir
               (askdir
                    (prompt "Where would you like the updated software "
                    "installed?\n"
                    "The directory 'PalomaFE' will be created automatically.\n")
                    (help @askdir-help)
                    (default @default-dest)
               )
               )

               (set PalomaFE_dir
               (tackon PalomaFE_dir "PalomaFE")
               )

               (makedir PalomaFE_dir
               (infos)
               )
          )
     )
)

; PalomaFE: was not previously assigned, so ask where to make it
(if  (= PalomaFE_dir nothing)
          (
          (set PalomaFE_dir
               (askdir
                    (prompt "Where would you like the software installed?\n"
                    "The directory 'PalomaFE' will be created automatically.\n")
                    (help @askdir-help)
                    (default @default-dest)
               )
          )

          (set PalomaFE_dir
          (tackon PalomaFE_dir "PalomaFE")
          )


          (makedir PalomaFE_dir
          (infos)
          )
     )
)

(set @default-dest PalomaFE_dir)















   
(complete 10)

(working omp "...Please Wait...")

(copyfiles
     (prompt "Select file(s) to be copied into your WBStartup: directory:")
     (help "\n\n\n\n\nThis will copy the Paloma TV Control Center facility to your WBStartup: "
     "directory.\n\n\n\n\n\n\n\n"
     @copyfiles-help)
     (source Src_root)
     (dest "SYS:WBStartup")
     (pattern "(FED|FED.info)")
     (confirm)
)
   
(complete 20)

(working omp "...Please Wait...")

;copy Cando.library

(copylib
   (source (tackon Src_libs "cando.library"))
   (dest "LIBS:")
   (prompt "Copying needed 'Cando.library' to LIBS:")
   (help @copylib-help)
   (confirm)
)

(complete 30)



; Copy SulliTech

(working omp "...Please Wait...")
   
(set PalomaFE_dir
     (copyfiles
          (prompt "These files will be copied to the PalomaFE: directory:")
          (help "\n\n\n\n\n\nThis will copy Paloma's main "
          "programs.\n\n\n\n\n\n\n"
          @copyfiles-help)
          (source Src_root)
          (dest PalomaFE_dir)
          (pattern "(#?FED|FED.info|OPT|AnimOpt|InfoWin|OPT2|Sullot|ReadMe|PalomaTV|PalomaTV.info|PalomaTV.config|QuickStart|QuickStart.info#?)")
          (confirm)
)


)


(complete 40)

;create Documentation directory

(set Docs_dir
(cat PalomaFE_dir)
)
(set Docs_dir
(tackon Docs_dir "Docs")
)

(makedir Docs_dir
(infos)
)

(working omp "...Please Wait...")

(copyfiles
     (prompt "Select file(s) to be copied to the PalomaFE:Docs directory:")
     (help "\n\n\n\n\nThis will copy the documentation for "
     "PalomaFE.  This documentation should reside in your "
     "'PalomaFE:Docs' directory.\n\n\n\n\n\n"
     @copyfiles-help)
     (source Src_Docs)
     (dest Docs_dir)
     (pattern "#?.docs#?")
     (confirm)

)

(complete 50)

;create Rexx directory

(set Rexx_dir
(cat PalomaFE_dir)
)
(set Rexx_dir
(tackon Rexx_dir "Rexx")
)

(makedir Rexx_dir
(infos)
)

(working omp "...Please Wait...")

(copyfiles
     (prompt "These file(s) must be copied into the Rexx directory:")
     (help "\n\n\n\nRexxMast MUST be running on your system for "
     "PalomaFE to use.  These AREXX scripts should reside in your "
     "'PalomaFE:Rexx' directory.\n\n\n\n\n\n"
     @copyfiles-help)
     (source Src_Rexx)
     (dest Rexx_dir)
     (pattern "#?.rexx#?")
     (confirm)
)

(complete 60)

; add assigns to User-Startup if this is not an update

(if  (= is_update false)
     (if  (askbool
               (prompt "\nIn order for PalomaFE to work correctly, "
               "Somewhere in the USER-STARTUP must be an assigment"
               " for 'PalomaFE:'\n\n"
               "These lines can be added for you automatically by this "
               "installer.  Would you like these lines added?\n\n")
               (help @askbool-help)
               )

               (
                    (if (= @pretend 0)
                    (
                        (
                        (if  (not  (exists "s:user-startup"))
                             (textfile
                             (dest "s:user-startup")
                             (append ";user-startup \n\n")
                         )
                    )
                    (textfile
                    (dest "ram:user-startup")
                    (include "s:user-startup")
                    (append ";BEGIN PalomaFE assignment\n")
                    (append "assign PalomaFE: " PalomaFE_dir)
                    (append "\n;END PalomaFE assignment\n")
                    )
                    (rename "s:user-startup" "s:user-startup.old")
                    (copyfiles
                    (help @copyfiles-help)
                    (source "ram:user-startup")
                    (dest "s:")
                    )
                    (delete "ram:user-startup")
               )
          )
          )
     )
     )
)

(complete 70)

(exit)
