home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 4 Drivers / 04-Drivers.zip / os2_221.exe / install.cmd < prev    next >
OS/2 REXX Batch file  |  1998-09-16  |  10KB  |  312 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. say 'INSTALLATION ABORT'
  150. signal end
  151.  
  152. ENDSEARCH:
  153. say 'Unable to determine OS2 Environment Path'
  154. say 'INSTALLATION ABORTED'
  155. signal end
  156.  
  157. StartInstall:
  158. say 'PLEASE WAIT ...'
  159.  
  160. NewDir=directory(Dstdrv'\')             /* go to root off OS/2 drive */
  161.  
  162. /********************************************/
  163. /* remove any MGA statement from CONFIG.SYS */
  164. /********************************************/
  165.  
  166. InnF=Dstdrv'\CONFIG.MGA'
  167. OutF=Dstdrv'\CONFIG.SYS'
  168. 'copy 'OutF' 'InnF' >nul'
  169. 'del 'OutF
  170.  
  171. do until lines(InnF) = 0
  172.     InStr = linein(InnF)
  173.     select
  174.         when pos('VVGA.SYS', InStr) > 0     then nop
  175.         when pos('VSVGA.SYS', InStr) > 0    then nop
  176.         when pos('MGAKRNL.SYS', InStr) > 0  then nop    /* Terminator       */
  177.         when pos('MGA=', InStr) > 0         then nop    /* Termin / Millen  */
  178.         when pos('MGARES=', InStr) > 0      then nop    /* Terminator < 2.0 */
  179.         when pos('VIO_MGA', InStr) > 0      then nop    /* Termin / Millen  */
  180.         when pos('RAMBIOS.SYS', InStr) > 0  then nop    /* Terminator < 2.0 */
  181.         when pos('VMGA.SYS', InStr) > 0     then nop    /* Terminator       */
  182.         when pos('KMGAX64.SYS', InStr) > 0  then nop    /* Millennium       */
  183.         when pos('VMGAX64.SYS', InStr) > 0  then nop    /* Millennium       */
  184.         otherwise
  185.         do
  186.             if pos('LIBPATH=', InStr) > 0   then        do
  187.                 itmp = pos(':\MGA\OS', InStr)
  188.                 if itmp > 0 then stmp=delstr(InStr, itmp-1, 11)
  189.                 else stmp=InStr
  190.                 call lineout OutF, stmp
  191.             end
  192.             else do
  193.                 itmp = pos(':\MGA\OS2', InStr)
  194.                 if itmp = 0 then  call lineout OutF, InStr
  195.                 end
  196.         end
  197.     end
  198. end
  199.  
  200. call stream OutF, 'c', 'close'
  201. call stream InnF, 'c', 'close'
  202.  
  203. /**********************************/
  204. /* Call OS/2 Installation process */
  205. /**********************************/
  206.  
  207. 'if exist 'Dstdrv'\OS2\svgadata.pmi del 'Dstdrv'\OS2\svgadata.pmi > nul'
  208. 'if exist 'Dstdrv'\OS2\video.cfg del 'Dstdrv'\OS2\video.cfg > nul'
  209.  
  210. NewDir=directory(Dstdrv'\OS2\INSTALL')
  211. 'if exist MGA8.DSC del MGA8.DSC > nul'
  212. 'copy   'Srcdrv'MGAX64.DSC .>nul'
  213.  
  214.  
  215. ver = SysOS2Ver()
  216. option=''
  217.  
  218. if ver > '2.11' then do                             /* Warp 3 = 2.30 */
  219.                                                     /* Merlin = 2.40 */
  220.     if AutoInstall = 1
  221.         then option=' /PD:'Srcdrv'MGAX64.DSC'
  222.     if right(Srcdrv, 1) = '\'
  223.         then Srcdrv = left(Srcdrv, length(Srcdrv) - 1)
  224.     option = option' /S:'Srcdrv' /T:'Dstdrv'\'
  225. end
  226.  
  227. /**************************************************/
  228. /* Call dspinstl to install drivers               */
  229. /**************************************************/
  230.  
  231. 'DSPINSTL'option
  232. IstRetCode = rc
  233.  
  234. /**************************************************************/
  235. /* restore CONFIG.SYS and AUTOEXEC.BAT in case abort or error */
  236. /**************************************************************/
  237. if IstRetCode \= 0 then do
  238.     NewDir=directory(Dstdrv'\')
  239.     'copy config.mga config.sys >nul'
  240.     'copy autoexec.mga autoexec.bat >nul 2>nul'
  241.     'del  *.mga'
  242.     say 'INSTALLATION ABORT'
  243.     end
  244.  
  245. else do
  246.  
  247.     /**********************************************************************/
  248.     /* Save a copy of the Matrox vvga.sys in \mga\os2 to copy to          */
  249.     /* \os2\mdos in case dspinstl is used to reinstall the driver.        */
  250.     /**********************************************************************/
  251.     'copy 'Dstdrv'\os2\mdos\vvga.sys 'Dstdrv'\mga\os2 >nul'
  252.  
  253.     /**********************************************************************/
  254.     /* Save a copy of the Matrox screen01.sys in \mga\os2 to copy to      */
  255.     /* \os2\ in case dspinstl is used to reinstall the driver.            */
  256.     /**********************************************************************/
  257.     'copy 'Dstdrv'\os2\screen01.sys 'Dstdrv'\mga\os2 >nul'
  258.  
  259.     /**********************************************************************/
  260.     /* Delete obsolete files.                                             */
  261.     /* An old level mga.inf is identified by the existence of mgamon.exe. */
  262.     /**********************************************************************/
  263.     'if exist 'Dstdrv'\MGA\OS2\mgamon.exe    del 'Dstdrv'\MGA\OS2\mga.inf     2>nul'
  264.     'if exist 'Dstdrv'\MGA\OS2\MGAMON.EXE    del 'Dstdrv'\MGA\OS2\MGAMON.EXE   >nul'
  265.     'if exist 'Dstdrv'\MGA\OS2\syslevel.mil  del 'Dstdrv'\MGA\OS2\syslevel.mil >nul'
  266.  
  267.     /**********************************************************/
  268.     /* If the installation target drive is the one that's     */
  269.     /* currently booted, create the MGA objects.              */
  270.     /**********************************************************/
  271.     if DstRunning = 1
  272.     then do
  273.         'call' Dstdrv'\mga\os2\fixauto 'Dstdrv' on >nul 2>&1'
  274.         'call' Dstdrv'\mga\os2\mgaobj'
  275.         end
  276.     else do
  277.         say 'To complete installation, boot from 'Dstdrv' and run MGAOBJ'
  278.         say 'and then MGAHK, both from the 'Dstdrv'\MGA\OS2 directory.'
  279.         end
  280.     end
  281.  
  282. signal end
  283.  
  284. ASKDRIVES:
  285. say 'Enter source drive ('Srcdrv')'
  286. pull answer
  287. if   answer = "" then nop
  288. else Srcdrv = answer'\OS2'
  289. say 'Enter destination drive ('Dstdrv')'
  290. pull answer
  291. if   answer = "" then nop
  292. else Dstdrv = answer
  293. signal RESUME
  294.  
  295. USAGE0:
  296. say
  297. say 'File' FileName 'does not exist.'
  298. USAGE:
  299. say ''
  300. say 'Usage:'
  301. say '   install [source path] [/u]'
  302. say
  303. say 'Examples:'
  304. say '   a:install'
  305. say '   b:install b:'
  306. say '   c:\temp\install c:\temp'
  307. say '   e:\os2\install'
  308.  
  309. end:
  310. call directory CurDir
  311. exit x2d('FE00')
  312.