home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 33 VDrivers / 33-VDrivers.zip / matrox.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1998-04-16  |  9KB  |  302 lines

  1. /********************************************************************/
  2. /*         MGA OS/2 PM drivers installation batch file              */
  3. /********************************************************************/
  4.  
  5. '@ECHO OFF'
  6. say 'Matrox Millennium/Mystique/MGA-G100/MGA-G200 Driver'
  7.  
  8. call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  9. call sysloadfuncs
  10.  
  11.  
  12. CurDir = Directory()
  13. parse SOURCE cmdd
  14. cmdd = word(cmdd,3)
  15. SrcDrv = left(cmdd, length(cmdd) - length('install.cmd'))
  16. Dstdrv = 'C:'           /* default value */
  17. AutoInstall = 0         /* default value */
  18.  
  19. /********************************************************************/
  20. /* Get arguments if any                                             */
  21. /********************************************************************/
  22.  
  23. Parse Arg all
  24.  
  25. ArgCount=words(all)
  26. if ArgCount > 4 then ArgCount = 4
  27. srcset=0
  28. dstset=0
  29. If ArgCount > 0 then do i=1 to ArgCount
  30.     ntmp = translate(word(all,i))
  31.     select /* ntmp */
  32.         when ntmp ='/U' then AutoInstall = 1
  33.  
  34.         otherwise do
  35.             if srcset=0 then do
  36.                 Srcdrv=ntmp
  37.                 srcset=1
  38.             end
  39.             else do
  40.                 Dstdrv=ntmp
  41.                 dstset=1
  42.             end
  43.         end /* otherwise */
  44.     end /* select ntmp */
  45. end /* do i=1 to ArgCount */
  46.  
  47. if srcset=1 then signal FoundSrcDrv
  48.  
  49. SearchRep = 0
  50. SearchAgain:
  51. if stream(Srcdrv'MGAX64.DSC','C','query exists') \= "" then signal FoundSrcDrv
  52. Srcdrv=Srcdrv'\OS2\'
  53. if stream(Srcdrv'MGAX64.DSC','C','query exists') \= "" then signal FoundSrcDrv
  54.  
  55. SearchRep = SearchRep + 1
  56.  
  57. select
  58.    when SearchRep=1 then do
  59.         Srcdrv = CurDir
  60.         signal SearchAgain
  61.         end
  62.    when SearchRep=2 then do
  63.         DrvLetter = 'A'
  64.         Srcdrv = DrvLetter':'
  65.         signal SearchAgain
  66.         end
  67.     otherwise nop
  68. end
  69.  
  70. if DrvLetter \= 'Z' then do
  71.     DrvLetter= D2C(C2D(DrvLetter)+1)
  72.     Srcdrv = DrvLetter':'
  73.     signal SearchAgain
  74. end
  75.  
  76. Srcdrv='A:'
  77. signal NotFoundSrcDrv
  78.  
  79. FoundSrcDrv:
  80. say 'Install from 'Srcdrv
  81.  
  82. /********************************************************************/
  83. /* Search for OS2 system path in PATH environment                   */
  84. /********************************************************************/
  85.  
  86. Path = translate(value('PATH',,'OS2ENVIRONMENT'))
  87. if Path = '' then signal ENDSEARCH
  88.  
  89. ntmp = pos(':\OS2;', Path)
  90. if ntmp = 0 then signal ENDSEARCH
  91.  
  92. BootedDrv = substr(Path, ntmp - 1, 2)
  93. if dstset = 0 then Dstdrv = BootedDrv
  94. if BootedDrv = Dstdrv then DstRunning = 1
  95.  
  96. FoundDstDrv:
  97. say 'Install to   'Dstdrv
  98.  
  99. /*****************************************************************************/
  100. /*                 Checking the default values                               */
  101. /*****************************************************************************/
  102.  
  103.                                                /* checking source      */
  104. lastChar = right(Srcdrv, 1)
  105. if lastChar \= ":" & lastChar \= '\' then Srcdrv = Srcdrv'\'
  106. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') \= "" then signal CheckDst
  107. Srcdrv=Srcdrv'OS2\'
  108. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') = "" then signal RESUME
  109.  
  110. CheckDst:
  111.  
  112. FileName=Dstdrv'\OS2KRNL'                       /* checking target      */
  113. 'attrib -r -s -h 'FileName
  114. if stream(FileName, 'C', 'query exists') = "" then signal RESUME
  115. 'attrib +h +s +r 'FileName
  116.  
  117. signal StartInstall
  118.  
  119. /********************/
  120. /* Ask the User     */
  121. /********************/
  122.  
  123. NotFoundSrcDrv:
  124. RESUME:
  125. cls
  126. say ''
  127. say ''
  128. say 'Source dir will be:' Srcdrv
  129. say 'Destination drive will be:' Dstdrv
  130. say 'Is the above information correct? (Y/N): Y'
  131. pull answer
  132. if answer = 'N' then signal askdrives
  133.  
  134. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') \= "" then signal CheckDst1
  135. FileName = Srcdrv'MGAX64.DSC'
  136. Srcdrv=Srcdrv'\OS2\'
  137. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') = "" then signal usage0
  138.  
  139. CheckDst1:
  140. FileName=Dstdrv'\OS2KRNL'
  141. 'attrib -r -s -h 'FileName
  142. if stream(FileName, 'C', 'query exists') = "" then signal usage0
  143. 'attrib +h +s +r 'FileName
  144.  
  145. say 'Source Directory will be 'Srcdrv
  146. say 'Ready to install? (Y/N): Y'
  147. pull answer
  148. if answer \= 'N' then signal StartInstall
  149.  
  150. say 'INSTALLATION ABORT'
  151. signal end
  152.  
  153. StartInstall:
  154. say 'PLEASE WAIT ...'
  155.  
  156. NewDir=directory(Dstdrv'\')             /* go to root off OS/2 drive */
  157.  
  158. /********************************************/
  159. /* remove any MGA statement from CONFIG.SYS */
  160. /********************************************/
  161.  
  162. InnF=Dstdrv'\CONFIG.MGA'
  163. OutF=Dstdrv'\CONFIG.SYS'
  164. 'copy 'OutF' 'InnF' >nul'
  165. 'del 'OutF
  166.  
  167. do until lines(InnF) = 0
  168.     InStr = linein(InnF)
  169.     select
  170.         when pos('VVGA.SYS', InStr) > 0     then nop
  171.         when pos('VSVGA.SYS', InStr) > 0    then nop
  172.         when pos('MGAKRNL.SYS', InStr) > 0  then nop    /* Terminator       */
  173.         when pos('MGA=', InStr) > 0         then nop    /* Termin / Millen  */
  174.         when pos('MGARES=', InStr) > 0      then nop    /* Terminator < 2.0 */
  175.         when pos('VIO_MGA', InStr) > 0      then nop    /* Termin / Millen  */
  176.         when pos('RAMBIOS.SYS', InStr) > 0  then nop    /* Terminator < 2.0 */
  177.         when pos('VMGA.SYS', InStr) > 0     then nop    /* Terminator       */
  178.         when pos('KMGAX64.SYS', InStr) > 0  then nop    /* Millennium       */
  179.         when pos('VMGAX64.SYS', InStr) > 0  then nop    /* Millennium       */
  180.         otherwise
  181.         do
  182.             if pos('LIBPATH=', InStr) > 0   then        do
  183.                 itmp = pos(':\MGA\OS', InStr)
  184.                 if itmp > 0 then stmp=delstr(InStr, itmp-1, 11)
  185.                 else stmp=InStr
  186.                 call lineout OutF, stmp
  187.             end
  188.             else do
  189.                 itmp = pos(':\MGA\OS2', InStr)
  190.                 if itmp = 0 then  call lineout OutF, InStr
  191.                 end
  192.         end
  193.     end
  194. end
  195.  
  196. call stream OutF, 'c', 'close'
  197. call stream InnF, 'c', 'close'
  198.  
  199. /**********************************/
  200. /* Call OS/2 Installation process */
  201. /**********************************/
  202.  
  203. 'if exist 'Dstdrv'\OS2\svgadata.pmi del 'Dstdrv'\OS2\svgadata.pmi > nul'
  204. 'if exist 'Dstdrv'\OS2\video.cfg del 'Dstdrv'\OS2\video.cfg > nul'
  205.  
  206. NewDir=directory(Dstdrv'\OS2\INSTALL')
  207. 'if exist MGA8.DSC del MGA8.DSC > nul'
  208. 'copy   'Srcdrv'MGAX64.DSC .>nul'
  209.  
  210.  
  211. ver = SysOS2Ver()
  212. option=''
  213.  
  214. if ver > '2.11' then do                             /* Warp 3 = 2.30 */
  215.                                                     /* Merlin = 2.40 */
  216.     if AutoInstall = 1
  217.         then option=' /PD:'Srcdrv'MGAX64.DSC'
  218.     if right(Srcdrv, 1) = '\'
  219.         then Srcdrv = left(Srcdrv, length(Srcdrv) - 1)
  220.     option = option' /S:'Srcdrv' /T:'Dstdrv'\'
  221. end
  222.  
  223. /**************************************************/
  224. /* Call dspinstl to install drivers               */
  225. /**************************************************/
  226.  
  227. 'DSPINSTL'option
  228. IstRetCode = rc
  229.  
  230. /**************************************************************/
  231. /* restore CONFIG.SYS and AUTOEXEC.BAT in case abort or error */
  232. /**************************************************************/
  233. if IstRetCode \= 0 then do
  234.     NewDir=directory(Dstdrv'\')
  235.     'copy config.mga config.sys >nul'
  236.     'copy autoexec.mga autoexec.bat >nul 2>nul'
  237.     'del  *.mga'
  238.     say 'INSTALLATION ABORT'
  239.     end
  240.  
  241. else do
  242.  
  243.     /**********************************************************************/
  244.     /* Save a copy of the Matrox vvga.sys in \mga\os2 to copy to          */
  245.     /* \os2\mdos in case dspinstl is used to reinstall the driver.        */
  246.     /**********************************************************************/
  247.     'copy 'Dstdrv'\os2\mdos\vvga.sys 'Dstdrv'\mga\os2 >nul'
  248.  
  249.     /**********************************************************************/
  250.     /* Delete obsolete files.                                             */
  251.     /* An old level mga.inf is identified by the existence of mgamon.exe. */
  252.     /**********************************************************************/
  253.     'if exist 'Dstdrv'\MGA\OS2\mgamon.exe    del 'Dstdrv'\MGA\OS2\mga.inf     2>nul'
  254.     'if exist 'Dstdrv'\MGA\OS2\MGAMON.EXE    del 'Dstdrv'\MGA\OS2\MGAMON.EXE   >nul'
  255.     'if exist 'Dstdrv'\MGA\OS2\syslevel.mil  del 'Dstdrv'\MGA\OS2\syslevel.mil >nul'
  256.  
  257.     /**********************************************************/
  258.     /* If the installation target drive is the one that's     */
  259.     /* currently booted, create the MGA objects.              */
  260.     /**********************************************************/
  261.     if DstRunning = 1
  262.     then do
  263.         'call' Dstdrv'\mga\os2\fixauto 'Dstdrv' on >nul 2>&1'
  264.         'call' Dstdrv'\mga\os2\mgaobj'
  265.         end
  266.     else do
  267.         say 'To complete installation, boot from 'Dstdrv' and run MGAOBJ'
  268.         say 'and then MGAHK, both from the 'Dstdrv'\MGA\OS2 directory.'
  269.         end
  270.     end
  271.  
  272. signal end
  273.  
  274. ASKDRIVES:
  275. say 'Enter source drive ('Srcdrv')'
  276. pull answer
  277. if   answer = "" then nop
  278. else Srcdrv = answer'\OS2'
  279. say 'Enter destination drive ('Dstdrv')'
  280. pull answer
  281. if   answer = "" then nop
  282. else Dstdrv = answer
  283. signal RESUME
  284.  
  285. USAGE0:
  286. say
  287. say 'File' FileName 'does not exist.'
  288. USAGE:
  289. say ''
  290. say 'Usage:'
  291. say '   install [source path] [/u]'
  292. say
  293. say 'Examples:'
  294. say '   a:install'
  295. say '   b:install b:'
  296. say '   c:\temp\install c:\temp'
  297. say '   e:\os2\install'
  298.  
  299. end:
  300. call directory CurDir
  301. exit x2d('FE00')
  302.