| >!Install.!Run
| Copyright  2008, 7th software
| All rights reserved.

Set Alias$Canonical2 "<Obey$Dir>.Bin.Canonical2 "
Set Alias$UpCall6    "<Obey$Dir>.Bin.UpCall6 "
Set Alias$MDBackup   "<Obey$Dir>.Bin.MDBackup "
Canonical2 MoreDesk$Installer <Obey$Dir>
Set MoreDesk$InstDir <MoreDesk$Installer>.ToInstall

Echo
Echo MoreDesk installer started on <Sys$Date> <Sys$Year> at <Sys$Time>
Echo -----------------------------------------------------------------------------
Echo

Echo Checking for any problems with your system...

| Check the system
RMEnsure UtilityModule 4.00 Error MoreDesk requires RISC OS 4.00 or later
RMEnsure WindowManager 3.80 Error MoreDesk requires WindowManager 3.80 or later
If "<System$Dir>"         = "" Then Error !System resources could not be found
If "<Wimp$ScrapDir>"      = "" Then Error !Scrap directory could not be found
If "<BootResources$Path>" = "" Then Error MoreDesk requires the Universal Boot Structure
If "<Boot$ToBeTasks>"     = "" Then Error MoreDesk requires the Universal Boot Structure
If "<Choices$Write>"      = "" Then Error MoreDesk requires the Universal Boot Structure
Echo Check is complete.
Echo

| Get some paths to key components (if there)
Unset MoreDesk$Confix
Unset MoreDesk$eXML
Unset MoreDesk$Routines
Unset MoreDesk$MoreDesk
If "<ConfiX$Dir>" <> ""   Then Canonical2 MoreDesk$Confix <ConfiX$Dir>
If "<eXML$Dir>" <> ""     Then Canonical2 MoreDesk$eXML <eXML$Dir>
If "<Routines$Dir>" <> "" Then Canonical2 MoreDesk$Routines <Routines$Dir>
If "<MoreDesk$Dir>" <> "" Then Canonical2 MoreDesk$MoreDesk <MoreDesk$Dir>
SetEval MoreDesk$Len LEN "<MoreDesk$InstDir>"
| Don't attempt to install over the versions in our own installer!
If ("<MoreDesk$Confix>"   LEFT <MoreDesk$Len>) = "<MoreDesk$InstDir>" Then Unset MoreDesk$Confix
If ("<MoreDesk$eXML>"     LEFT <MoreDesk$Len>) = "<MoreDesk$InstDir>" Then Unset MoreDesk$eXML
If ("<MoreDesk$Routines>" LEFT <MoreDesk$Len>) = "<MoreDesk$InstDir>" Then Unset MoreDesk$Routines
If ("<MoreDesk$MoreDesk>" LEFT <MoreDesk$Len>) = "<MoreDesk$InstDir>" Then Unset MoreDesk$MoreDesk

| Build the installation schedule
Echo Building installation schedule...
SetEval MoreDesk$DoConfiX   0
SetEval MoreDesk$DoRoutines 0
SetEval MoreDesk$DoMoreDesk 0
SetEval MoreDesk$DoSystem   0
WimpSlot -min 400K -max 400K
Run <MoreDesk$Installer>.!RunImage
Set MoreDesk$BackupDir $.MD_Backup.<MoreDesk$Leaf>
CDir $.MD_Backup
CDir <MoreDesk$BackupDir>
Echo Schedule is complete.
Echo

| Back-up Choices directory
IfThere <Choices$Write>.MoreDesk Then Echo Backing up your MoreDesk choices
IfThere <Choices$Write>.MoreDesk Then Copy <Choices$Write>.MoreDesk <MoreDesk$BackupDir>.MoreDesk ~cfr~v

| Do the SharedCLibrary installation
If MoreDesk$DoSystem Then Obey <MoreDesk$InstDir>.System.!Install

| Do the ConfiX installation
If MoreDesk$DoConfiX Then Obey <MoreDesk$InstDir>.ConfiX.!Install

| Do the Routines installation
If MoreDesk$DoRoutines Then Obey <MoreDesk$InstDir>.Routines.!Install

| Do the MoreDesk installation
If MoreDesk$DoMoreDesk Then Obey <MoreDesk$InstDir>.MoreDesk.!Install

| Tell the user what happened
Echo
If MoreDesk$DoConfiX   = 0 Then Echo !ConfiX was not installed - your version is new enough
If MoreDesk$DoRoutines = 0 Then Echo !Routines was not installed - your version is new enough
If MoreDesk$DoMoreDesk = 0 Then Echo !MoreDesk was not installed - your version is new enough
If MoreDesk$DoSystem   = 0 Then Echo SharedCLibrary was not installed - your system does not require it
Echo

| Ensure that the filer has 'seen' the installed applications
Echo Making sure filer has 'seen' installed applications...
Filer_Run <MoreDesk$Confix>.!Boot
UpCall6
Run <MoreDesk$Routines>.!Boot
UpCall6
Run <MoreDesk$MoreDesk>.!Boot
UpCall6

| Ensure that various of the user's choices files are in the latest formats
| (needs to happen _after_ we've installed !Routines!)
Echo Merging new Choices:MoreDesk bits
WimpSlot -min 400K -max 400K
IfThere Choices:MoreDesk.Choices Then Run <MoreDesk$Installer>.Bin.ConfigMunge
Run <MoreDesk$Installer>.Bin.MsgMunge

Echo Completed.
UpCall6

| Open the directory containing !MoreDesk
Canonical2 MoreDesk$Open <MoreDesk$MoreDesk>.^
Do Filer_OpenDir <MoreDesk$Open>

| Unset the installer's variables
Unset MoreDesk$Backup
Unset MoreDesk$BackupDir
|
Unset MoreDesk$Leaf
Unset MoreDesk$Len
|
Unset MoreDesk$DoConfiX
Unset MoreDesk$DoRoutines
Unset MoreDesk$DoMoreDesk
Unset MoreDesk$DoSystem
Unset MoreDesk$MoreDesk
Unset MoreDesk$Routines
Unset MoreDesk$eXML
Unset MoreDesk$ConfiX
|
Unset MoreDesk$InstDir
Unset MoreDesk$Installer
|
Unset Alias$Canonical2
Unset Alias$UpCall6
Unset Alias$MDBackup

Echo
Echo -----------------------------------------------------------------------------
Echo
Echo MoreDesk installer completed on <Sys$Date> <Sys$Year> at <Sys$Time>
