; Installation script for TurboPrint Professional 6
; (C) 1997 IrseeSoft
;
;
; $VER: TurboPrint Professional 6.01 (15.12.97) 
;
;
;   "Install TurboPrint"         operationMode = 0
;   "Update TurboPrint"          operationMode = 1
;   "Remove TurboPrint"          operationMode = 2
;   "Install on Disk"            operationMode = 3
;   "Query TurboPrint Version"   operationMode = 4
;

; String constants section. All messages and strings appear in this section
; for easier translation into foreign languages.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; LANGUAGE SECTION
;
; to support more than only one language, there is a special section for
; each supported language.
;

   (set #language "english")
   (set #graphics-publisher "GraphicsPublisher")
   (set #print-manager "PrintManager")
   (set #read-me "ReadMe")
   (set #extra-personalization "personalization")

   (set #tp-version "TurboPrint Professional 6.01 (15.12.97) " )

   (set #wrongversion
      (cat "Attention: You are using an old version of the 'Installer' software."
           "This installation script needs at least Installer V43.3. "
           "Installer V43.3 is included on this disk.\n\n"
           "If you are using the MCP utility, you must either copy the new Installer"
           "onto your hard drive or switch off MCP."
      )
   )




   (set #introduction
      (cat "\nInstallation of TURBOprint Professional 6\n"
             "    Copyright © 1997 IrseeSoft SPCS\n\n"
           "Please choose:\n\n"
      )
   )

   (set #introduction-help
      (cat "\n"
      )
   )

   (set #need-os2
      (cat "\nTurboPrint Professional 6 needs Kickstart 2.04 or higher\n"
           "To use TurboPrint Professional 6 you need to upgrade your Amiga "
           "(Kickstart ROM + disks). Ask your Amiga dealer for details. "
      )
   )

   (set #install "First installation of TURBOprint")
   (set #update  "Install update")
   (set #remove  "Remove from hard disk")
   (set #instdisk "Install on floppy disk")
   (set #version "Show version number")


   (set #askfordisk (cat "Please insert an empty floppy disk which will be converted "
                         "into your TurboPrint installation disk. After that, click on the "
                         "disk drive where you have inserted the disk.")
   )

   (set #format-disk (cat "The disk will be formatted now. All data on the disk will "
                         "be erased!\n\n"
                         "You might be prompted to reinsert the Workbench disk - "
                         "please insert the Workbench disk into a different disk drive "
                         "or write protect it first. After the message "
                         "\"Disk is write protected\" reinsert "
                         "your blank disk. "
                     )
   )


   (set #path-prompt0 (cat "Please select the location where the TURBOprint drawer "
			  "shall be installed")
   )

   (set #path-prompt1 (cat "Please locate the TURBOprint drawer "
			  "where the update shall be installed")
   )

   (set #path-prompt2 (cat "Please locate the TURBOprint drawer "
			  "to be removed")
   )
   (set #formating-disk (cat "Disk is being formatted...")
   )

   (set #unpacking-files (cat "Unpacking files...")
   )

   (set #disk-ready (cat "The TurboPrint disk has been completed.")
   )

; additional help to the built-in one
   (set #generic-help
      (cat "Please read the ReadMe-file on this disk!\n"
      )
   )

   (set #which-printer
      (cat "Please choose your printer\n"
           "or select 'Help', if your printer is not listed"
      )
   )
   (set #help-printer
      (cat "If your printer is not listed, please read the "
           "printer's user manual to find out which emulations the printer "
           "supports and select the appropriate TurboPrint driver.\n "
           "For Epson ESC/p compatible 9-pin printers choose "
           "'.9-pin', for 24-pin printers choose '.24-pin', for "
           "HP PCL compatible laser printers choose '.laser'\n\n"
      )
   )

   (set #another-printer
      (cat "Do you want to install another printer driver?\n"
           "Installed printer drivers:\n\n"
      )
   )
   (set #ask-pryes
      (cat "Yes")
   )
   (set #ask-prno
      (cat "No")
   )

   (set #remove-drivers
      (cat "\nYou have chosen 'remove from hard disk'.\n"
           "The TURBOprint drawer will be erased completely. "
           "Please make sure that there are no other programs "
           "or files of you in it!\n"
      )
   )

   (set #update-drivers
      (cat "\nUpdating deletes all files in the drawers "
           "'Printers', 'Configs' und 'Turbo' within the TURBOprint "
           "drawer,\n"
           "i.e. old printer drivers and config files.\n" 
           "If you don't want to delete them, choose "
           "'Abort installation'."
      )
   )

   (set #removing-drivers
      (cat "\nTURBOprint is being removed..."
      )
   )
   (set #removing-turboprefs
      (cat "If your startup-sequence/user-startup has been changed "
           "by this installation program, it will be restored now."
      )
   )
   (set #adding-turboprefs
      (cat "The following two lines will be added to the "
	   "file 's:user-startup': \n"
           "'Assign TURBOprint: <pfad>:TURBOprint'\n"
           "'TURBOprint:TURBOprefs -q'"
      )
   )
   (set #removing-startup
      (cat "If you have changed your startup-sequence "
       "for TURBOprint 1.0/2.0: \n"
       "The commands 'assign TURBOprint: ...' and 'TURBOprint:Turboprefs -q' are "
       "no longer necessary and should be removed.\n"
      )
   )

   (set #ask-wbstart20
    (cat "TURBOprint can be loaded automatically on boot-up. "
         "For this purpose the file 'TURBOstart' will be copied "
         "to the WBStart drawer.\n")
   )

   (set #wbstart-help
    (cat "\n"
    )
   )

   (set #ask-wbyes "Install autostart" )

   (set #ask-wbno "No autostart" )

   (set #ask-printmanager 
    (cat "Do you want to install the graphics view and print program "
         "GraphicsPublisher?" 
    )
   )

   (set #ask-pmyes "Install GraphicsPublisher" )

   (set #ask-pmno "Don't install GraphicsPublisher" )



   (set #ask-turbospool
    (cat "Do you want to activate TurboSpool "
         "at boot time?" 
    )
   )

   (set #ask-tsyes "Activate printer spooler" )

   (set #ask-tsno "Don't activate printer spooler" )



   (set #ask-pictures 
    (cat "Do you want to copy the demo pictures to your hard disk?" )
   )

   (set #ask-piyes "Copy pictures" )

   (set #ask-pino "Don't copy pictures" )

   (set #version-info "\nInformation about your system:\n")
   (set #system-version-info "Kickstart %ld.%ld, Workbench %ld.%ld\n")


   (set #installation-done
      (cat "The installation of TURBOprint has been completed. "
           "Please remove your TurboPrint disk and reboot your Amiga now.\n"
      )
   )


; General initialisation of internal states, options and pre-defined
; variables go here.

(delopts askuser)

; Check whether this system is operating with at least Workbench 2.04 (V37).
; This is needed for the WBStartup feature and the Printmanager

(set kickVersion (shiftright (getversion) 16))

(set wbVersion (shiftright (getversion "LIBS:version.library") 16))

; set source directory

(set sourcedir (pathonly @icon))

;
(if (< kickVersion 37)
  (
   (message #need-os2)
   (exit (quiet))
  )
)
;

;Installer-Version prüfen...

(if (< @installer-version 2818051)
 (
  (user 2)
  (message #wrongversion)
  (exit (quiet))
 )
)

(welcome)

; remember current user level

(set old-level @user-level)

; Introduce ourself to the user. Query whether the software shall be
; installed/updated or removed altogether.

(set operationMode
   (askchoice
      (prompt #introduction)
      (choices #install #update #remove #instdisk #version)
      (help #generic-help #introduction-help @askchoice-help)
   )
)

; Install on Disk

(if (= operationMode 3)
   (
     (message #format-disk)

     (set format-command (cat "sys:system/format drive df" diskNumber ": name TurboPrint ffs noicons"))
     (working (#formating-disk))
     (run format-command)

     (set lha-command (cat (tackon sourcedir "LHA") " x Turboprint6.lha TurboPrint:"))
     (working (#unpacking-files))
     (run lha-command)

     ;copy turboprefs from disk to hd

     (copyfiles
	      (help   #generic-help @copyfiles-help)
	      (source (tackon sourcedir "Turboprefs"))
   	      (dest   "TurboPrint:")
     )

   (copyfiles
	      (help   #generic-help @copyfiles-help)
	      (source (tackon sourcedir #read-me))
   	      (dest   "TurboPrint:")
              (infos)
   )
     
     (message #disk-ready)
     (exit (quiet))
   )
)

; Show version number

(if (= operationMode 4)
   (
   ; Find out the version of the Kickstart and Workbench and append it to the
   ; version information string.

   (set #version-info 
     (cat #version-info 
      (#system-version-info 

	(shiftright (getversion) 16)
	(bitand (getversion) 65535)
	(shiftright (getversion "LIBS:version.library") 16)
	(bitand (getversion "LIBS:version.library") 65535)
      )
     )
   )
     

   ; Get the version string from this installer script itself!

   (set #version-info (cat #version-info #tp-version))

   (message #version-info)
   (exit (quiet))
   )
)

; Get path of TurboPrint
; Set the prompt depending on operationMode

(if (= operationMode 0)

   (set #path-prompt #path-prompt0)
)

(if (= operationMode 1)

   (set #path-prompt #path-prompt1)
)

(if (= operationMode 2)

   (set #path-prompt #path-prompt2)
)


; ask for the destination directory

(if (not (exists "Work:"))
   (user 1)
)

(set target
   (askdir (prompt #path-prompt)
   (help #generic-help @askdir-help)
   (default "Work:") )
)

(user old-level)

; Update TurboPrint => remove contents of Printers, Configs and Turbo drawers

(if (= operationMode 1)
 (
   (message #update-drivers)
   
      (delete (tackon target (cat "TurboPrint/" #print-manager)))
      (delete (tackon target (cat "TurboPrint/" #print-manager ".info")))
      (delete (tackon target "TurboPrint/TurboPrefs"))
      (delete (tackon target "TurboPrint/TurboPrefs.info"))
      (delete (tackon target "TurboPrint/NoTurbo"))
      (delete (tackon target "TurboPrint/NoTurbo.info"))

      (delete (tackon target "TurboPrint/Printers") (all))
      (delete (tackon target "TurboPrint/Configs") (all))
      (delete (tackon target "TurboPrint/Turbo") (all))
      (delete (tackon target "TurboPrint/Colors") (all))
      (delete (tackon target "TurboPrint/Drivers") (all))
 )
)

; Remove TurboPrint => remove TurboPrint drawer completely

(if (= operationMode 2)
 (
   (message #remove-drivers)
   (working #removing-drivers)

   (run (cat (tackon target "Turboprint/NoTurbo") " -q"))

   (delete (tackon target "TurboPrint") (all) )

   ;Remove TurboStart in WBStartup

   (delete "sys:WBStartup/TurboStart.info")

   ;Remove TurboSpool in WBStartup

   (delete "sys:WBStartup/TurboSpool.info")

   ;Remove TurboPrefs in Prefs

   (delete "sys:Prefs/TurboPrefs.info")

   ;Inform user

   (startup "TurboPrint"
         (prompt #removing-TurboPrefs)
         (help #generic-help @startup-help)
   )
 )
)

;if install or update

(if (or (= operationMode 0) (= operationMode 1) )
  (

;Make TurboPrint drawer
   (makedir   (tackon target "TurboPrint") (infos))

;expand the whole Turboprint archive to the Turboprint drawer

   (set lha-command (cat (tackon sourcedir "LHA") " x Turboprint6.lha \"" (tackon target "TurboPrint") "/\""))
   (run lha-command)

   (set lha-command (cat (tackon sourcedir "LHA") " x Turboprint6HD.lha \"" (tackon target "TurboPrint") "/\""))
   (run lha-command)

   (run (cat (tackon target "Turboprint/NoTurbo") " -q"))

;Choose default printer(s)

(set printer-copy 1)

(user 1)

(while (= 1 printer-copy)
 (

  (set printer-name
   (askfile (prompt #which-printer)
   (help #help-printer @askfile-help)
   (default (tackon target "TurboPrint/Printers"))
   )
  )

  (if ( = (tackon target "TurboPrint/Printers") (pathonly printer-name) )
(
  (set printer-name (fileonly printer-name))

  (set printer-name (substr printer-name 0 ( - (strlen printer-name) 4) ))

  (copyfiles
   (help   #generic-help @copyfiles-help)
   (source (tackon target "Turboprint/Configs/_Dummy_"))
   (dest   (tackon target "TurboPrint/Configs" ))
   (newname (cat printer-name ".tpc") )
  )

  (set printer-list (cat printer-list printer-name "\n"))

  (set printer-copy (askbool (prompt (cat #another-printer printer-list) )
	     (help @askchoice-help)
))
   )
  )

 )
)

(user old-level)

;user-startup
;the installer creates a user-startup if it doesn't already exist
;dont ask user

 ;Add assign to user-startup

      (startup "TurboPrint"
         (command 
            (cat "Assign TurboPrint: \"" (tackon target "TurboPrint") "\"")
         )
         (prompt #adding-TurboPrefs)
         (help #generic-help @startup-help)
      )

;Execute assign NOW

(makeassign ("TurboPrint") (tackon target "TurboPrint") )


;install one of the two autostart options

   ;OS 2.x/3.0 => wbstartup drawer
   ;ask user if he/she wants to have the autostart option installed

(if (= 0 (askchoice (prompt #ask-wbstart20)
	     (help #wbstart-help @askchoice-help)
	     (choices #ask-wbyes #ask-wbno)
	     (default 0)
       )    )
 (
 ;Copy TurboStart icon to WBStartup-drawer

   (copyfiles
	      (help   #generic-help @copyfiles-help)
	      (source (tackon target "Turboprint/extra/TurboStart.info"))
   	      (dest   "sys:WBStartup" )
   )

   ;Put correct paths into TurboStart icon

   (tooltype
	  (dest "sys:WBStartup/TurboStart")
          (setdefaulttool "TurboPrint:TurboPrefs" )
          (settooltype "QUICK" "")
          (settooltype "DONOTWAIT" "")
	  (noposition)
   )

 )
)

;Put the Turbospool icon into the WBStartup-drawer if desired

(if (= 0 (askchoice (prompt #ask-turbospool)
	     (help #wbstart-help @askchoice-help)
	     (choices #ask-tsyes #ask-tsno)
	     (default 0)
       )    )
 (
 ;Copy TurboStart icon to WBStartup-drawer

   (copyfiles
	      (help   #generic-help @copyfiles-help)
	      (source (tackon target "Turboprint/extra/TurboSpool.info"))
   	      (dest   "sys:WBStartup" )
   )

   ;Put correct paths into TurboSpool icon

   (tooltype
	  (dest "sys:WBStartup/TurboSpool")
          (setdefaulttool "TurboPrint:TurboSpool")
          (settooltype "DONOTWAIT" "")
	  (noposition)
   )

 )
)

;install the necessary libraries

(copylib
      (source (tackon target "Turboprint/libs/multipic.library"))
      (dest   "LIBS:")
)

(copylib
      (source (tackon target "Turboprint/libs/wizard.library"))
      (dest   "LIBS:")
)

;Do the other stuff

 ;Copy TurboPrefs icon to sys:prefs

   (copyfiles
	      (help   #generic-help @copyfiles-help)
	      (source (tackon target "Turboprint/extra/TurboStart.info"))
   	      (dest   "sys:Prefs" )
	      (newname "TurboPrefs.info" )
   )

   ;Put correct paths into TurboStart icon

   (tooltype
	  (dest "sys:Prefs/TurboPrefs")
          (setdefaulttool "TurboPrint:TurboPrefs" )
          (settooltype "(QUICK)" "" )
	  (noposition)
   )

 ;make a copy of the GraphicsPublisher named Printmanager

   (copyfiles
	      (help   #generic-help @copyfiles-help)
	      (source (tackon target (cat "Turboprint/" #graphics-publisher)))
   	      (dest   (tackon target "TurboPrint") )
	      (newname #print-manager)
   )

 ;copy turboprefs from disk to hd

   (copyfiles
	      (help   #generic-help @copyfiles-help)
	      (source (tackon sourcedir "TurboPrefs"))
   	      (dest   (tackon target "TurboPrint"))
   )

   (copyfiles
	      (help   #generic-help @copyfiles-help)
	      (source (tackon sourcedir #read-me))
   	      (dest   (tackon target "TurboPrint"))
              (infos)
   )


;   (if (exists (tackon "locale:catalogs" #language))
;     (copyfiles
;	      (help   #generic-help @copyfiles-help)
;	      (source (tackon target "Turboprint/locale"))
;   	      (dest   (tackon "locale:catalogs" #language) )
;              (all)
;     )
;   )

   (delete (tackon target "TurboPrint/Configs/24-Pin.tpc") )

))
(user 1)
(message #installation-done)
(exit (quiet))

