; Envoy Patch Installation script
;
; By Heinz Wrobel for Intangible Assets Manufacturing
;
; $Id: Install 2.13 1995/03/30 18:19:59 heinz Exp $
;


( if (= @language "english")
(
  (set #use20
  (cat "You must be using Kickstart 2.04 or higher to install this Envoy Patch."
  ))
  (set #wherebase_msg
  (cat "On which device or drawer is the Envoy drawer located?"
  ))
  (set #wherebase_help
  (cat "This installation can't locate the Envoy drawer by itself. You need "
       "to specify the device or drawer where the Envoy drawer can be found."
  ))
  (set #whereEFSserver
  (cat "Where should the updated filesystem.service be placed?"
  ))
  (set #whereEFSserverhelp
  (cat "In the Envoy drawer you will find a \"services\" drawer. "
       "filesystem.service should be placed into this drawer."
  ))
  (set #whereenvoylib
  (cat "Where should the updated envoy.library be placed?"
  ))
  (set #whereenvoylibhelp
  (cat "envoy.library should be placed into SYS:LIBS to be available right after "
       "booting."
  ))
  (set #useA2060
  (cat "Do you use Commodore ARCNET-boards?"
  ))
  (set #useA2060help
  (cat "If you use Commodore ARCNET-boards, the a2060.device will be updated."
  ))
  (set #whereA2060
  (cat "Where should the updated a2060.device be placed?"
  ))
  (set #whereA2060help
  (cat "The standard place for the a2060.device is in the \"DEVS:Networks\" drawer."
  ))
  (set #done
  (cat "The Envoy patch is now installed. Please reboot this Amiga before using Envoy again."
  ))
;  (set #
;  (cat
;  ))
))
( if (= @language "deutsch")
(
  (set #use20
  (cat "Sie müssen Kickstart 2.04 oder höher benutzen um diesen Envoy-Patch "
       "installieren zu können."
  ))
  (set #wherebase_msg
  (cat "Auf welchem Gerät oder in welchem Verzeichnis ist die Envoy-Schublade zu finden?"
  ))
  (set #wherebase_help
  (cat "Die Installation kann die Schublade in der sich die Envoy-Schublade befindet "
       "nicht selbständig finden. Bitte geben Sie die entsprechende Schublade an."
  ))
  (set #whereEFSserver
  (cat "Wo soll der erneuerte filesystem.service abgelegt werden?"
  ))
  (set #whereEFSserverhelp
  (cat "In der Envoy-Schublade befindet sich ein Unterverzeichnis \"Services\". "
       "filesystem.service sollte dort abgelegt werden."
  ))
  (set #whereenvoylib
  (cat "Wo soll die erneuerte envoy.library abgelegt werden?"
  ))
  (set #whereenvoylibhelp
  (cat "envoy.library sollte immer in der Schublade \"SYS:LIBS\" abgelegt werden."
  ))
  (set #useA2060
  (cat "Verwenden Sie Commodore ARCNET-Karten?"
  ))
  (set #useA2060help
  (cat "Wenn Sie Commodore ARCNET-Karten verwenden, wird die a2060.device erneuert."
  ))
  (set #whereA2060
  (cat "Wo soll die erneuerte a2060.device abgelegt werden?"
  ))
  (set #whereA2060help
  (cat "Die a2060.device sollte normalerweise in der Schublade \"DEVS:Networks\" abgelegt werden."
  ))
  (set #done
  (cat "Der Envoy-Patch ist jetzt installiert. Bitte starten Sie diesen Amiga neu bevor Sie "
       "Envoy wieder benutzen."
  ))
;  (set #
;  (cat
;  ))
))

;----------------------------------------------------------------------------
; Cleanup any temporary mess we created
(procedure CLEANUP
(
    (if tmp_dir
        (if (exists tmp_dir)
            (run (cat "C:Delete QUIET ALL FORCE \"" tmp_dir "\"") (safe))
        )
    )
    (if tmp_iconfile
        (if (exists tmp_iconfile)
            (delete tmp_iconfile (safe))
        )
    )
))

;----------------------------------------------------------------------------
(procedure INSTALLPATCH
  (
    (if (exists (tackon envoy_source src_file))
      (
        (if (NOT (exists (tackon envoy_dest src_file)))
            (set envoy_dest
                (askdir
                    (prompt where_msg)
                    (help where_help)
                    (default envoy_dest)
                )
            )
        )

        (if dopatch
            (run (cat (tackon tmp_dir "spatch") " \"-o" (tackon tmp_dir src_file) "\" \"-p" (tackon tmp_dir pch_file) "\" \"" (tackon envoy_source src_file) "\""))
        )
        (copylib
            (source (tackon tmp_dir src_file))
            (dest   envoy_dest)
            (optional "oknodelete" "force" "askuser")
        )
      )
    )
  )
)
;----------------------------------------------------------------------------
; *** THIS IS THE ACTUAL START OF THE INSTALLATION ***

(if (< (/ (getversion) 65536) 37)
        (abort #use20)
)

(onerror (CLEANUP))

; create the temporary directory that we need for unpacking some stuff
(set tmp_dir "RAM:EID")
(makedir tmp_dir (safe))

(set envoybase "SYS:Envoy")
(if (NOT (exists envoybase (noreq)))
    (set envoybase "WORK:Envoy")
)

(if (NOT (exists envoybase (noreq)))
    (set envoybase "ENVOY:")
)

(if (NOT (exists envoybase (noreq)))
  (
    (set envoybase
        (tackon
            (askdir
                (prompt #wherebase_msg)
                (help #wherebase_help)
                (default "SYS:")
            )
            "Envoy"
        )
    )
  )
)

(if (NOT @pretend)
    (set @default-dest envoybase)
)

(complete 5)

(copyfiles (source "envoy.pch")
           (dest tmp_dir) (nogauge) (safe))
(copyfiles (source "filesystem.pch")
           (dest tmp_dir) (nogauge) (safe))
(copyfiles (source "a2060.device")
           (dest tmp_dir) (nogauge) (safe))
(copyfiles (source "spatch")
           (dest tmp_dir) (nogauge) (safe))

(complete 10)

(set envoy_source "EnvoyInstall:libs")
(set envoy_dest "SYS:LIBS")
(set pch_file "envoy.pch")
(set src_file "envoy.library")
(set where_msg #whereenvoylib)
(set where_help #whereenvoylibhelp)
(set dopatch 1)
(INSTALLPATCH)

(complete 40)

(set envoy_source "EnvoyInstall:services")
(set envoy_dest (tackon envoybase "Services"))
(set pch_file "filesystem.pch")
(set src_file "filesystem.service")
(set where_msg #whereEFSserver)
(set where_help #whereEFSserverhelp)
(set dopatch 1)
(INSTALLPATCH)

(complete 70)

(set instA2060 0)
(set envoy_source "EnvoyInstall:devs/networks")
(set envoy_dest "SYS:DEVS/Networks")
(set src_file "a2060.device")
(set where_msg #whereA2060)
(set where_help #whereA2060help)
(set dopatch 0)

(if (exists (tackon envoy_dest src_file))
  (
    (set instA2060 1)
  )
  (
    (set instA2060
      (= 1 (askbool
            (prompt #useA2060)
            (help #useA2060help)
           )
      )
    )
  )
)

(if instA2060
  (
    (INSTALLPATCH)
  )
)

(complete 90)

(CLEANUP)

(complete 100)

(message #done)

(exit (quiet))

