home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / fixcheck.zip / fixcheck.cmd < prev    next >
OS/2 REXX Batch file  |  1999-07-03  |  16KB  |  481 lines

  1. /*
  2.   Check fixpack for regression and missing fixes.
  3.   Copyright 1996, 1999 Charles H. McKinnis, all rights reserved.
  4.   An unrestricted license is hereby granted to all who
  5.   wish to use this program on an AS IS basis.
  6. */
  7. Trace 'N'
  8. os2_mrm = 'SYSLEVEL.OS2'
  9. mmpm_dir = 'MMOS2'
  10. speech_dir = 'VT'
  11. font_dir = 'PSFONTS'
  12. lang_dir = 'LANGUAGE'
  13. open_dir = 'OPENDOC'
  14. user_dir = 'OS2\INSTALL\USERDIRS.OS2'
  15. user_dir. = ''
  16. user_dir.0 = 0
  17. lvl_list. = ''
  18. lvl_list.1 = '3000 - Warp for Windows'
  19. lvl_list.2 = '3001 - Warp with WIN-OS/2'
  20. lvl_list.3 = '3002 - Warp for Windows Manufacturing Refresh'
  21. lvl_list.4 = '3003 - Warp with WIN-OS/2 Connect'
  22. lvl_list.5 = '3004 - Warp for Windows Manufacturing Refresh Connect'
  23. lvl_list.6 = '3005 - Warp Preload/Warp Server'
  24. lvl_list.7 = '3006 - Warp Server SMP'
  25. lvl_list.8 = '4000 - Warp 4'
  26. lvl_list.9 = '4010 - Workspace On Demand'
  27. lvl_list.0 = 9
  28. crexx_list = 'REXX.DLL REXXUTIL.DLL NONE       NONE        NONE        REX.MSG REXH.MSG REXX.INF' 
  29. orexx_list = 'REXX.DLL REXXUTIL.DLL REXXSC.DLL REXXSOM.DLL REXXWPS.DLL REX.MSG REXH.MSG REXX.INF'
  30. update_detail = 0
  31.  
  32. Parse Upper Arg mods
  33.  
  34. Call Initialize
  35.  
  36. If Wordpos('-UD', mods) <> 0 Then update_detail = 1
  37.  
  38. Say 'Enter the fully qualified name of the fixpack data file to be checked'
  39. Parse Upper Pull fix_name
  40. If Substr(fix_name,2,1) <> ':' Then Do
  41.    Say 'Use the fully qualified name of the fixpack data file to be checked'
  42.    Call Clean_up
  43.    End
  44. If \ Filefind(fix_name) Then Do
  45.    Say fix_name 'not found'
  46.    Call Clean_up
  47.    End
  48.  
  49. Say ''
  50. Do i = 1 To lvl_list.0
  51.    Say i lvl_list.i
  52.    End
  53. Say 'Select the level of your OS/2 system'
  54. Parse Upper Pull fix_level
  55. If fix_level >= 1 & fix_level <= lvl_list.0 Then Do
  56.    fix_level = Word(lvl_list.fix_level, 1)
  57.    End
  58. Else Do
  59.    Say 'Selection' fix_level 'is not valid'
  60.    Call Clean_up
  61.    End
  62.  
  63.  
  64. fix_level = 'XR_' || fix_level
  65.  
  66. return_code = SysFileSearch(fix_level, fix_name, 'fixfiles.')
  67. return_code = Stream(fix_name, 'C', 'CLOSE')
  68. If fixfiles.0 = 0 Then Do
  69.    Say fix_name 'does not contain any files for OS/2 level' fix_level
  70.    Call Clean_up
  71.    End
  72.  
  73. os2_install = Findmrm(os2_mrm)
  74. If os2_install = '' Then Call Clean_up
  75. root_drive = Findroot(os2_install, fix_level)
  76. os2_base = Findbase(os2_install, fix_level)
  77. mmpm_base = Findaux(root_drive, mmpm_dir, fix_level, 'MMPM/2')
  78. speech_base = Findaux(root_drive, speech_dir, fix_level, 'Voice Type')
  79. font_base = Findaux(root_drive, font_dir, fix_level, 'System Fonts')
  80. lang_base = Findaux(root_drive, lang_dir, fix_level, 'Languages')
  81. open_base = Findaux(root_drive, open_dir, fix_level, 'Open Doc')
  82. user_base = Finduser(root_drive, user_dir, fix_level, 'Relocated Components')
  83.  
  84. If root_drive = '' os2_base = '' & mmpm_base = '' & ,
  85.    speech_base = '' & font_base = '' & lang_base = '' & ,
  86.    open_base = '' & user_dir.0 = 0 Then Do
  87.    Say 'No directories were selected for checking'
  88.    Call Clean_up
  89.    End
  90.  
  91. Parse Value Findout(fix_name) with out_level out_file .
  92.  
  93. Say ''
  94. check_line = 'Checking fix pack files in' fix_name || crlf || '   against' os2_base || '*'
  95. If mmpm_base <> '' Then check_line = check_line || ',' mmpm_base || '*'
  96. If speech_base <> '' Then check_line = check_line || ',' speech_base || '*'
  97. If font_base <> '' Then check_line = check_line || ',' font_base || '*'
  98. If lang_base <> '' Then check_line = check_line || ',' lang_base || '*'
  99. If open_base <> '' Then check_line = check_line || ',' open_base || '*' 
  100. If user_base <> '' Then Do i = 1 To user_dir.0
  101.    check_line = check_line || ',' user_dir.i || '*'
  102.    End
  103. check_line = check_line || ', and' root_drive
  104. If out_level Then check_line = check_line || crlf || '   with output to' out_file
  105. Say check_line
  106. Say 'Enter to continue or Enter 'a' to abort'
  107. Parse Upper Pull ans
  108. ans = Left(ans, 1)
  109. If ans = 'A' Then Do
  110.    Say 'Fixcheck aborted by user'
  111.    Call Clean_up
  112.    End
  113. trace 'n'
  114. Do i = 1 To fixfiles.0
  115.    Parse Value Space(fixfiles.i) With file_name pack_name . fix_date fix_time fix_size .
  116.    orexx = Wordpos(file_name, orexx_list)
  117.    If orexx > 0 Then Do
  118.       crexx = Wordpos(file_name, crexx_list)
  119.       If orexx = crexx Then Do
  120.          If objrexx Then Do
  121.             If \Abbrev(pack_name, 'OR') Then Iterate i
  122.             End
  123.          Else Do
  124.             If \Abbrev(pack_name, 'CR') Then Iterate i
  125.             End
  126.          End
  127.       End
  128.    fix_date = Substr(fix_date, 7, 4)||'/'||Substr(fix_date, 1, 5)||'/'Substr(fix_time, 1, 2)||'/'||Substr(fix_time, 4, 2)
  129.    fixfiles.i = file_name fix_date fix_size
  130.    found.0 = 0
  131.    Call Searchit os2_base, file_name, 'FSL'
  132.    Call Searchit mmpm_base, file_name, 'FSL'
  133.    Call Searchit speech_base, file_name, 'FSL'
  134.    Call Searchit font_base, file_name, 'FSL'
  135.    Call Searchit lang_base, file_name, 'FSL'
  136.    Call Searchit open_base, file_name, 'FSL'
  137.    If user_base <> '' Then Do k = 1 To user_dir.0
  138.       Call Searchit user_dir.k, file_name, 'FSL'
  139.       End
  140.    Call Searchit root_drive, file_name, 'FL'
  141.    If found.0 > 0 Then Do j = 1 To found.0
  142.       Parse Value Space(found.j) With updated_date updated_time updated_size . updated_name
  143.       updated_date = Translate(updated_date, '/', '-')
  144.       updated_time = Translate(updated_time, '/', ':')
  145.       updated_time = Left(updated_time, Lastpos('/', updated_time) -1)
  146.       updated_date = updated_date || '/' || updated_time
  147.       If Pos('\OS2\INSTALL\IBMINST\', Translate(updated_name)) > 0 Then Iterate j 
  148.       If j > 1 Then multiples = multiples + 1
  149.       Select
  150.          When (updated_date = fix_date) & (updated_size = fix_size) Then Do
  151.             equaled = equaled + 1
  152.             equaled.equaled = fixfiles.i 'Equal -' updated_name
  153.             updated = updated + 1
  154.             updated.updated = equaled.equaled
  155.             End
  156.          When updated_date > fix_date Then Do
  157.             regressions = regressions + 1
  158.             regressions.regressions = fixfiles.i 'Date Regression -' updated_date updated_name 
  159.             updated = updated + 1
  160.             updated.updated = regressions.regressions
  161.             End
  162.          When updated_date < fix_date Then Do
  163.             backlevel = backlevel + 1
  164.             backlevel.backlevel = fixfiles.i 'Backdated -' updated_date updated_size updated_name
  165.             updated = updated + 1
  166.             updated.updated = backlevel.backlevel
  167.             End
  168.          When (updated_date = fix_date) & (updated_size <> fix_size) Then Do
  169.             regressions = regressions + 1
  170.             regressions.regressions = fixfiles.i 'Size Regression -' updated_size updated_name 
  171.             updated = updated + 1
  172.             updated.updated = regressions.regressions
  173.             End
  174.          Otherwise Nop
  175.          End
  176.       End
  177.    Else Do
  178.       notfound = notfound + 1
  179.       notfound.notfound = fixfiles.i 'No file to update found'
  180.       End
  181.    End
  182.  
  183. Call Outtitle check_line
  184. Call Outline 'Number of fix files found for OS/2 level' fix_level '=' fixfiles.0
  185. Call Outline 'Number of fix files found without files to update =' notfound
  186. fixfiles = fixfiles.0 - notfound
  187. Call Outline 'Number of fix files elgible for application found =' fixfiles
  188. Call Outline 'Number of multiple file occurrences found =' multiples
  189. Call Outline ''
  190. Call Outline 'Number of system files elgible for updating found =' updated
  191. Call Outline 'Number of possible regressions found =' regressions
  192. Call Outline 'Number of backdated files found =' backlevel
  193. Call Outline 'Number of equal files found =' equaled
  194.  
  195. If updated > 0 & update_detail Then Do
  196.    Call Outtitle 'Number of system files elgible for updating found =' updated
  197.    Do i = 1 to updated
  198.       Call Outline updated.i
  199.       End
  200.    End
  201.  
  202. If regressions > 0 Then Do
  203.    Call Outtitle 'Number of possible regressions found =' regressions
  204.    Do i = 1 To regressions
  205.       Call Outline regressions.i
  206.       End
  207.    End
  208.  
  209. If backlevel > 0 Then Do
  210.    Call Outtitle 'Number of backdated files found =' backlevel
  211.    Do i = 1 To backlevel
  212.       Call Outline backlevel.i
  213.       End
  214.    End
  215.  
  216. If equaled > 0 Then Do
  217.    Call Outtitle 'Number of equal files found =' equaled
  218.    Do i = 1 To equaled
  219.       Call Outline equaled.i
  220.       End
  221.    End
  222.  
  223. If notfound > 0 Then Do
  224.    Call Outtitle 'Number of fix files found without files to update =' notfound
  225.    Do i = 1 to notfound
  226.       Call Outline notfound.i
  227.       End
  228.    End
  229. If out_level Then Do
  230.    rc = Stream(out_file, 'C', 'CLOSE')
  231.    Say 'The output has been written to' out_file
  232.    End
  233. Call Outtitle 'End of fix check run'
  234. Call Clean_up
  235.  
  236. Clean_up:
  237.    Call SysDropFuncs
  238.    Exit
  239.  
  240. Outtitle: Procedure Expose out_level out_file
  241.    Parse Arg title
  242.    Call Outline ''
  243.    Call Outline title
  244.    Call Outline ''
  245.    Return
  246.  
  247. Outline: Procedure Expose out_level out_file
  248.    Parse Arg out_line
  249.    If out_level Then Call Lineout out_file, out_line
  250.    Else Say out_line
  251.    Return 0
  252.  
  253. Searchit: Procedure Expose locate. found. trace
  254.    Parse Arg base, file_name, option
  255.    If base <> '' Then Do
  256.       return_code = SysFileTree(base || file_name, 'locate.', option)
  257.       Call Copyfound return_code
  258.       End
  259.    Return
  260.  
  261. Copyfound: Procedure Expose locate. found. trace
  262.    base = ''
  263.    Parse Arg return_code, junk
  264.    If return_code = 0 & locate.0 > 0 Then Do i = 1 To locate.0
  265.       j = found.0
  266.       j = j + 1
  267.       found.j = locate.i
  268.       found.0 = j
  269.       End
  270.    Return
  271.  
  272. Filefind: Procedure
  273.    Parse Upper Arg file, type, junk
  274.    If type = '' | type = 'F' Then type = 'F'
  275.    return_code = SysFileTree(file, 'file', type)
  276.    If return_code = 0 Then Do
  277.       If file.0 = 1 Then status = 1
  278.       Else status = 0
  279.       End
  280.    Else status = 0
  281.    Return status
  282.  
  283. Findmrm: Procedure Expose trace drive_map
  284.    install = ''
  285.    mrm_index = 0
  286.    mrm_found. = ''
  287.    found. = ''
  288.    Parse Arg mrm, dir, junk
  289.    Say ''
  290.    Say 'Checking all drives for' mrm
  291.    Do i = 1 to Words(drive_map)
  292.       drive = Word(drive_map, i)
  293.       search = drive || '\' || mrm
  294.       return_code = SysFileTree(search, 'found.', 'FSO')
  295.       If return_code = 0 & found.0 > 0 Then Do j = 1 to found.0
  296.          mrm_index = mrm_index + 1
  297.          mrm_found.mrm_index = found.j
  298.          End
  299.       End
  300.    If mrm_index > 0 Then Do
  301.       Say 'The following' mrm 'files were found'
  302.       Say 'Please select one by number from the following list'
  303.       Say '   or press ENTER to bypass checking'
  304.       Do i = 1 to mrm_index
  305.          Say i '-' mrm_found.i
  306.          End
  307.       Parse Upper Pull ans .
  308.       If Datatype(ans, 'W') & (0 < ans < (mrm_index + 1)) Then
  309.          install = mrm_found.ans
  310.       Else Do
  311.          Say 'Invalid selection, terminating run'
  312.          End
  313.       End
  314.    Else Do
  315.       Say 'Could not find' mrm 'on any local drive'
  316.       Say 'Terminating run'
  317.       End
  318.    If install <> '' Then Do
  319.       install = Filespec('DRIVE', install) || Filespec('PATH', install)
  320.       install = Strip(install, 'T', '\')
  321.       End
  322.    Return install
  323.  
  324. Findaux: Procedure Expose user_dir
  325.    aux = ''
  326.    Parse Arg root, dir, fix, title, junk
  327.    Say ''
  328.    rc = SysFileTree(root || dir, 'dirs.', 'DO')
  329.    If rc = 0 & dirs.0 > 0 Then Do
  330.       Say 'Found the following directory for' title
  331.       Say 'Please select its number from the following list'
  332.       Say '   or press ENTER to bypass checking'
  333.       Do i = 1 To dirs.0
  334.          Say i dirs.i
  335.          End
  336.       Parse Upper Pull ans .
  337.       If Datatype(ans, 'W') & ans = 1 Then Do
  338.          aux = dirs.1
  339.          aux = Strip(aux, 'T', '*')
  340.          If Lastpos('\', aux) <> Length(aux) Then aux = aux || '\'
  341.          Say 'Fixes in' fix 'for' title 'will be checked against' aux || '*'
  342.          End
  343.       Else Do
  344.          Say 'Fixes in' fix 'for' title 'will not be checked'
  345.          End
  346.       End
  347.    Else Do
  348.       Say 'No directory for' root || dir 'was found' 
  349.       Say 'Fixes in' fix 'for' title 'will not be checked'
  350.       Say 'unless the directory is specified in' root || user_dir
  351.       End
  352.    Return aux
  353.  
  354. Finduser: Procedure Expose user_dir.
  355.    user = ''
  356.    Parse Arg root, dir, fix, title, junk
  357.    Say ''
  358.    rc = SysFileTree(root || dir, 'dirs.', 'DO')
  359.    If rc = 0 & dirs.0 > 0 Then Do
  360.       Say 'Found the following file for' title
  361.       Say 'Please select its number from the following list'
  362.       Say '   or press ENTER to bypass checking'
  363.       Do i = 1 To dirs.0
  364.          Say i dirs.i
  365.          End
  366.       Parse Upper Pull ans .
  367.       If Datatype(ans, 'W') & ans = 1 Then Do
  368.          user = dirs.1
  369.          Do i = 1 Until Lines(user) = 0
  370.             user_dir.0 = user_dir.0 + 1
  371.             user_dir.i = Linein(user)
  372.             user_dir.i = Strip(user_dir.i, 'T', '*')
  373.             If Lastpos('\', user_dir.i) <> Length(user_dir.i) Then user_dir.i = user_dir.i || '\'
  374.             End
  375.          Say 'Relocated components will be checked in the following directory(ies)'
  376.          Do i = 1 To user_dir.0
  377.             Say user_dir.i || '*'
  378.             End         
  379.          End
  380.       Else Do
  381.          Say 'Fixes in' fix 'for' title 'will not be checked'
  382.          End
  383.       End
  384.    Else Do
  385.       Say 'No file' root || dir 'was found' 
  386.       Say 'Fixes in' fix 'for' title 'will not be checked'
  387.       End
  388.    Return user
  389.  
  390. Selectroot: Procedure
  391.    base = ''
  392.    Parse Upper Arg comp, dir, junk
  393.    Say '   You may enter a root drive to be checked for' comp 'fixes'
  394.    Say '   or press ENTER to bypass checking'
  395.    Parse Upper Pull ans .
  396.    ans = Left(ans, 1)
  397.    If Datatype(ans, 'U') Then base = ans || dir
  398.    Return base
  399.  
  400. Findroot: Procedure Expose trace
  401.    root = ''
  402.    Parse Arg install, fix, junk
  403.    root = install
  404.    root = Left(root, Lastpos('\', root) -1)
  405.    root = Left(root, Lastpos('\', root))
  406.    Say ''
  407.    Say 'Will check fixpack files for' fix 'against root drive' root
  408.    Return root
  409.  
  410. Findbase: Procedure Expose trace
  411.    base = ''
  412.    Parse Arg install, fix, junk
  413.    base = install
  414.    base = Left(base, Lastpos('\', base))
  415.    base = base
  416.    Say ''
  417.    Say 'Will check fixpack files for' fix 'against base directory' base || '*'
  418.    Return base
  419.  
  420. Findout: Procedure
  421.    Parse Upper Arg fix, junk
  422.    new_file = ''
  423.    Say ''
  424.    Say 'Would you like your output to a file (Y|n)?'
  425.    Parse Upper Pull ans
  426.    out_level = \ Abbrev(ans, 'N')
  427.    If out_level Then Do
  428.       Parse Upper Source . . source_path .
  429.       source_path = Left(source_path, Lastpos('\', source_path))
  430.       lst = Substr(fix, Lastpos('\', fix) + 1)
  431.       Parse Upper Var lst lst '.' .
  432.       def_file = source_path || lst || '.LST'
  433.       Do Until new_file = ''
  434.          If Stream(def_file, 'C', 'QUERY EXISTS') <> '' Then Do
  435.             Say def_file 'exists and will be replaced'
  436.             Say '   unless you enter a new fully qualified name now'
  437.             Parse Upper Pull new_file
  438.             If new_file <> '' Then def_file = new_file
  439.             End
  440.          Else new_file = ''
  441.          End
  442.       If Stream(def_file, 'C', 'QUERY EXISTS') <> '' Then '@DEL' def_file
  443.       out_file = def_file
  444.       Say 'Your output will be placed in the file' out_file
  445.       End
  446.    Return out_level out_file
  447.  
  448. Initialize:
  449.    fix_name = ''
  450.    root_drive = ''
  451.    os2_base = ''
  452.    mmpm_base = ''
  453.    regressions. = ''
  454.    regressions = 0
  455.    backlevel. = ''
  456.    backlevel = 0
  457.    notfound. = ''
  458.    notfound = 0
  459.    updated. = ''
  460.    updated = 0
  461.    equaled. = ''
  462.    equaled = 0
  463.    multiples = 0
  464.    esc = D2c(27)              /* Escape character */
  465.    crlf = D2c(13) || D2c(10)  /* carriage return + linefeed */
  466.    Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  467.    Call SysLoadFuncs
  468.    Parse Version . rx_level .
  469.    If rx_level > 4.00 Then objrexx = 1
  470.    Else objrexx = 0
  471.    drive_map = ''
  472.    drive_list = SysDriveMap(,'LOCAL')
  473.    Do i = 1 to Words(drive_list)
  474.       drive = Word(drive_list, i)
  475.       driveinfo = SysDriveInfo(drive)
  476.       If driveinfo = '' | Word(driveinfo, 2) = 0 Then Iterate
  477.       drive_map = drive_map drive
  478.       End
  479.    drive_map = Strip(drive_map)
  480.    Return
  481.