(set osversion (/ (getversion) 65536))

(message
   "\n\nWelcome to the DiskExpander installation!\n\n"
   "Cracked by SkidRow Supplied By Fireflash"
   "This utility program installs DiskExpander\nand all programs belonging "
   "to the DiskExpander software package on your Workbench disk.\n\n"

)

(message
   "\n\n\n\n\nIt is recommended to hold the DiskExpander disk in the internal "
   "drive and the Workbench disk in the external drive."
)

(askdisk
   (dest "DiskExpander")
   (prompt "\n\n\n\n\nPlease insert your DiskExpander original disk "
           "into internal drive DF0:"
   )
   (help "The install program needs the disk for installing programs and "
         "data on your Workbench disk."
   )
)

(message
   "\n\nIf this is the first installation of DiskExpander, you'll be asked to "
   "enter your personal data when the program is started. These Data will be "
   "stored \non the original Disk.\n\nPlease ensure that you enter your data "
   "correctly! \nThis, together with returning the registration card, "
   "allows you to gain cheap updates to future versions of DiskExpander "
   "containing more and enhanced features."
)

(complete 0)

;(run "DiskExpander:c/DEProtect con:30/50/600/150/Personal_Data_Input")

(set n 0)
(set sourcedir "DiskExpander:c")
(while (set thisfile (select n "assign" "rename" "delete" "join" "DiskExpander" ""))
	(
      (copyfiles
      	(prompt "" )
      	(help "")
         (source (tackon sourcedir thisfile))
         (dest "ram:c")
      )

		(set n (+ n 1))
	)
)

(makedir "ram:l")

(copyfiles
   (prompt "" )
   (help "")
   (source "DiskExpander:l")
   (dest "ram:l")
   (pattern "DE#?-handler")
)

(makedir "ram:libs")
(copyfiles
   (prompt "" )
   (help "")
   (source "DiskExpander:libs")
   (dest "ram:libs")
   (pattern "xpk#?.library")
)


(complete 5)

(run "DiskExpander:c/assign l: ram:l")
(complete 6)
(run "DiskExpander:c/assign libs: ram:libs")
(complete 7)
(run "DiskExpander:c/DiskExpander >NIL: protect")
(complete 8)
(run "DiskExpander:c/DiskExpander >NIL: device DF0: library NUKE ")
(complete 9)
(run "DiskExpander:c/DiskExpander >NIL: device DF1: library NUKE ")



(complete 12)

(message
   "\n\n\n\nYour personal data and the system configuration have been "
   "stored on the diskette.\n\n"
   "The contents of the Workbench disk will now be compressed to "
   "ensure that there's enough space for DiskExpander and the utilities.\n\n"

   "Please write-protect your original DiskExpander program disk now."
)

(run "DiskExpander:InstallData/programdata/DevicePacker >\"con:30/50/600/150/Einen Moment Geduld! DevicePacker arbeitet...\" workbench: all")

(complete 33)
(run "DiskExpander:c/DiskExpander >NIL: device DF0: remove")
(complete 34)
(run "DiskExpander:c/DiskExpander >NIL: device DF1: remove")
(complete 35)

(message
   "\n\n\n\n\nTo speedup the installation process, some data will be "
   "temporarily copied to the RAM disk."
)

(makedir "ram:c")


(makedir "ram:installdata")

(complete 35)


(complete 36)


(complete 37)

(copyfiles
   (prompt "" )
   (help "")
   (source "DiskExpander:libs")
   (dest "ram:libs")
   (pattern "epu#?.library")
)

(complete 38)


(complete 39)

(copyfiles
   (prompt "" )
   (help "")
   (source "DiskExpander:installdata")
   (dest "ram:installdata")
   (all)
)

(complete 40)

(run "ram:c/delete ram:installdata/tracksalve")

(set realdest "workbench:DiskExpander")

(if
   (= (exists realdest) 0)
      (makedir realdest (infos))
)

(complete 41)

(if (= @user-level 2)
   (
      (set libflag
         (askoptions
            (prompt
               "Please select the compression libraries to be installed "
               "on the Workbench disk.:"
            )
            (help
               "To adjust DiskExpander for specific purposes, "
               "the program allows you to choose the compression library "
               "that suits best your personal needs.\n\n"
               "For detailed information on the compression libraries, please "
               "read the manual that comes along with DiskExpander or the "
               "file ReadMe! on the original disk."
            )
            (choices
               "epu0"
               "epu1"
               "NUKE"
               "BLZW"
               "FAST"
               "SHRI"
            )
            (default 65535)
         )
      )

      (if
         (askbool
            (prompt "\n\nDo you want DiskExpander to be installed using the "
                    "graphical appearance of Workbench 2.0?")
            (help
               "When Workbench 2.0 was released, the basic Workbench colors "
               "black and white have been exchanged due to technical reasons. "
               "Therefore, icons especially designed for use with Workbench 1.3 "
               "look unsightly when used with Workbench 2.0.\n\n"
               "To avoid this effect, DiskExpander contains different icons "
               "for both versions of the operating system.\n\n"
               "Please install the type of icons that graphically matches your "
               "Workbench."
            )
         )
         (
            (set kickflag 1)
         )
         (
            (set kickflag 0)
         )
      )
   )
   (
      (set libflag 65535)
      (if (>= osversion 36)
         (
            (set kickflag 1)
         )
      )
      (if (<= osversion 35)
         (
            (set kickflag 0)
         )
      )
   )
)

(onerror
   (abort
      "DiskExpander cannot be installed successfully "
      "because the compression libraries cannot be copied to the "
      "target device!\n\n"
   )
)

(if (IN libflag 0)
   (copylib
      (prompt "" )
      (help "")
      (source "ram:libs/epu0.library")
      (dest "workbench:libs")
   )
)

(complete 43)

(if (IN libflag 1)
   (copylib
      (prompt "" )
      (help "")
      (source "ram:libs/epu1.library")
      (dest "workbench:libs")
   )
)

(complete 45)

(if (IN libflag 2)
   (copylib
      (prompt "" )
      (help "")
      (source "ram:libs/xpkNUKE.library")
      (dest "workbench:libs")
   )
)

(complete 50)

(if (IN libflag 3)
   (copylib
      (prompt "" )
      (help "")
      (source "ram:libs/xpkBLZW.library")
      (dest "workbench:libs")
   )
)

(complete 55)

(if (IN libflag 4)
   (copyfiles
      (prompt "" )
      (help "")
      (source "ram:libs/xpkFAST.library")
      (dest "workbench:libs")
   )
)

(complete 60)

(if (IN libflag 5)
   (copylib
      (prompt "" )
      (help "")
      (source "ram:libs/xpkSHRI.library")
      (dest "workbench:libs")
   )
)

(complete 65)

(onerror
   (abort
      "DiskExpander cannot be installed successfully "
      "because the handler files cannot be copied to the "
      "target device!\n\n"
   )
)

(copyfiles
   (prompt "" )
   (help "")
   (source "ram:l")
   (dest "workbench:l")
   (pattern "DE#?-handler")
)

(complete 70)

(onerror
   (abort
      "DiskExpander cannot be installed successfully "
      "because the main program and the utilites cannot be copied to the "
      "target device!\n\n"
   )
)

(copyfiles
   (prompt "" )
   (help "")
   (source "ram:c/DiskExpander")
   (dest "workbench:c")
)

(complete 73)


(run "ram:c/DiskExpander >NIL: device DF0: library NUKE ")
(complete 74)
(run "ram:c/DiskExpander >NIL: device DF1: library NUKE ")
(complete 75)


(copyfiles
   (prompt "" )
   (help "")
   (source "ram:installdata/ProgramData")
   (dest realdest)
   (pattern "#?")
)

(complete 81)
(run "ram:c/DiskExpander >NIL: device DF0: remove")
(complete 82)
(run "ram:c/DiskExpander >NIL: device DF1: remove")


(complete 85)

(if (= kickflag 0)
   (set sourcedir "ram:InstallData/Icons1.3")
)

(if (= kickflag 1)
   (set sourcedir "ram:InstallData/Icons2.0")
)

(copyfiles
   (prompt "" )
   (help "")
   (source sourcedir)
   (dest realdest)
   (all)
)

(complete 95)

(run "ram:c/assign l: workbench:l")
(complete 96)
(run "ram:c/assign libs: workbench:libs")
(run "ram:c/diskexpander >nil: protect")
(complete 97)

(run "ram:c/rename workbench:s/startup-sequence workbench:s/ss.old")
(complete 98)
(run "ram:c/join ram:InstallData/ss.1 workbench:s/ss.old as workbench:s/startup-sequence")
(complete 99)
(run "ram:c/delete workbench:s/ss.old")

(complete 100)

(exit
   "DiskExpander is now ready to be started from the Workbench. "
   "Necessary changes to the Startup-Sequence have been made. \n\n"
   "The original disk is needed once again when DiskExpander is started from "
   "the Workbench for the first time. "
   "Afterwards, you should keep your original disk in a secure place."
)



