getHPPatches.pl 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/tools/ns/bin/perl5.6.1 -w
  2. # --- BEGIN COPYRIGHT BLOCK ---
  3. # Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  4. # Copyright (C) 2005 Red Hat, Inc.
  5. # All rights reserved.
  6. #
  7. # License: GPL (version 3 or any later version).
  8. # See LICENSE for details.
  9. # --- END COPYRIGHT BLOCK ---
  10. $patchcmd = "swlist -l bundle";
  11. # [output sample]
  12. # Initializing...
  13. # Contacting target "linux2"...
  14. #
  15. # Target: linux2:/
  16. #
  17. #
  18. # B6268AA B.11.00.05 Graphics and Technical Computing Software
  19. # BUNDLE B.11.00 Patch Bundle
  20. # HPUXEng64RT B.11.00.01 English HP-UX 64-bit Runtime Environment
  21. # HWE1100 B.11.00.0206.5 Hardware Enablement Patches for HP-UX 11.00, June 2002
  22. # OnlineDiag B.11.00.21.10 HPUX 11.0 Support Tools Bundle, Jun 2002
  23. # QPK1100 B.11.00.64.4 Quality Pack for HP-UX 11.00, March 2004
  24. # UnlimUserLic B.11.00.02 HP-UX Unlimited-User License
  25. # XSWGR1100 B.11.00.47.08 General Release Patches, November 1999 (ACE)
  26. %month2digit = (
  27. 'January', 1,
  28. 'February', 2,
  29. 'March', 3,
  30. 'April', 4,
  31. 'May', 5,
  32. 'June', 6,
  33. 'July', 7,
  34. 'August', 8,
  35. 'September', 9,
  36. 'October', 10,
  37. 'November', 11,
  38. 'December', 12,
  39. );
  40. open PATCHCMD, "$patchcmd|" or die "Error: could not open $patchcmd: $!";
  41. sleep 1;
  42. $qpk_str = "";
  43. $month_year = "";
  44. while (<PATCHCMD>) {
  45. chop;
  46. if (/^\s+(QPK.*), ([A-Za-z]* [12][0-9]*)/) {
  47. $qpk_str = $1;
  48. $month_year = $2;
  49. }
  50. }
  51. close PATCHCMD;
  52. $date = gmtime;
  53. $host = `hostname`;
  54. chop $host;
  55. $dom = `domainname`;
  56. $un = `uname -a`;
  57. print "/* This list was generated by $0 */\n";
  58. print "/* on $host.$dom */\n";
  59. print "/* at $date GMT */\n";
  60. print "/* Here is the information from uname -a:\n";
  61. print $un;
  62. if ( $qpk_str eq "" )
  63. {
  64. print " Quality Pack is not installed on the system. */\n";
  65. }
  66. else
  67. {
  68. ($qpkname, $version, $description) = split(/[ ]+/, $qpk_str, 3);
  69. print "$qpkname\n";
  70. print "$version\n";
  71. print "$description\n";
  72. if ( $month_year eq "" )
  73. {
  74. print " Quality pack has no date info. */\n";
  75. print "$qpk_str <$month_year>\n";
  76. }
  77. else
  78. {
  79. ($month, $year) = split(/\s/, $month_year, 2);
  80. $mo = $month2digit{$month};
  81. print " The following is a Quality Pack installed on the system. */\n";
  82. print "{\"$qpkname\", \"$version\", \"$description\", $year, $mo, 0},\n";
  83. }
  84. }