home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / applycsd.zip / applycsd.cmd next >
OS/2 REXX Batch file  |  1997-09-29  |  3KB  |  127 lines

  1. /* A program to apply all Visual Age C++ CSDs to the installed base. */
  2.  
  3. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  4. call SysLoadFuncs
  5. call SysFileTree "ct*.zip", "zip", "FO"
  6. if zip.0 = 0 then
  7.   do
  8.     say "No ct*.zip files present"
  9.     return
  10.   end
  11. else
  12.   say "Patch files to apply:" zip.0
  13.  
  14. /* Find the drive with the most free space */
  15.  
  16. drives = SysDriveMap("c:", "local")
  17. maxDrive = ""
  18. MaxSpace = 0
  19. do while drives <> ""
  20.   parse var drives drive drives
  21.   info = SysDriveInfo(drive)
  22.   parse var info . freeSpace .
  23.   if freeSpace > maxSpace then
  24.     do
  25.       maxDrive = drive
  26.       maxSpace = freeSpace
  27.     end
  28. end
  29.  
  30. here = directory()
  31. call directory maxDrive"\"
  32. call SysMkDir "vacsd.tmp"
  33. call directory "vacsd.tmp"
  34.  
  35. /*
  36.    The order in which to apply these patches is documented by IBM as
  37.    follows:-
  38.      1. reboot
  39.      2. CTC308 *
  40.      3. CTO308
  41.      4. CTW308
  42.      5. reboot
  43.      6. CTV308
  44.      7. CTD308 *
  45.      8. CTU308
  46.      9. reboot
  47.     10. If you have the OpenClass source code, apply CTS308 at any time.
  48.    Now the first reboot is probably spurious but the ordering itself causes
  49.    some difficulty for this program.
  50. */
  51.  
  52. sequence.0 = 9
  53. sequence.1 = "ctc"
  54. sequence.2 = "cto"
  55. sequence.3 = "cts"
  56. sequence.4 = "ctw"
  57. sequence.5 = "reboot"
  58. sequence.6 = "ctv"
  59. sequence.7 = "ctd"
  60. sequence.8 = "ctu"
  61. sequence.9 = "reboot"
  62.  
  63. /*
  64.    Scan the list of files actually present and construct a list of patches
  65.    ordered according to the foregoing sequence.
  66. */
  67.  
  68. y = 0
  69. csd.y = 0
  70. do x = 1 to sequence.0
  71.   if sequence.x = "reboot" then
  72.     do
  73.       y = y + 1
  74.       csd.y = sequence.x
  75.       csd.0 = y
  76.     end
  77.   else
  78.     do z = 1 to zip.0
  79.       fnpos = lastpos("\", zip.z) + 1
  80.       fnseg = translate(substr(zip.z, fnpos, 3))
  81.       if fnseg = translate(sequence.x) then
  82.         do
  83.           y = y + 1
  84.           csd.y = zip.z
  85.           csd.0 = y
  86.         end
  87.     end
  88. end
  89.  
  90. /*
  91.    Now we have the list of files built.  It may be that we have reentered
  92.    this program on a reboot.
  93. */
  94.  
  95. if stream("csdone", 'C', "query exists") <> "" then
  96.   do
  97.     lyne = linein("csdone", 1, 1)
  98.     call lineout "csdone"
  99.   end
  100. else
  101.   lyne = 1
  102.  
  103. do x = lyne to csd.0
  104.   if csd.x = "reboot" then
  105.     do
  106.       call charout ,"A reboot is now in order.  Press 'Y' to do it now. "
  107.       answer = SysGetKey("echo")
  108.       call lineout "csdone", x+1, 1
  109.       call lineout "csdone"
  110.       if translate(answer) = "Y" then
  111.         "setboot /b"
  112.       exit
  113.     end
  114.   else
  115.     do
  116.       "unzip" csd.x
  117.       "service"
  118.       "rm -r *"
  119.       call lineout "csdone", x, 1
  120.       call lineout "csdone"
  121.     end
  122. end
  123. "rm -r *"
  124. call directory "\"
  125. call SysRmDir "vacsd.tmp"
  126. call directory here
  127.