getHPPatches.pl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/tools/ns/bin/perl5.6.1 -w
  2. # --- BEGIN COPYRIGHT BLOCK ---
  3. # This Program is free software; you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation; version 2 of the License.
  6. #
  7. # This Program is distributed in the hope that it will be useful, but WITHOUT
  8. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  10. #
  11. # You should have received a copy of the GNU General Public License along with
  12. # this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  13. # Place, Suite 330, Boston, MA 02111-1307 USA.
  14. #
  15. # In addition, as a special exception, Red Hat, Inc. gives You the additional
  16. # right to link the code of this Program with code not covered under the GNU
  17. # General Public License ("Non-GPL Code") and to distribute linked combinations
  18. # including the two, subject to the limitations in this paragraph. Non-GPL Code
  19. # permitted under this exception must only link to the code of this Program
  20. # through those well defined interfaces identified in the file named EXCEPTION
  21. # found in the source code files (the "Approved Interfaces"). The files of
  22. # Non-GPL Code may instantiate templates or use macros or inline functions from
  23. # the Approved Interfaces without causing the resulting work to be covered by
  24. # the GNU General Public License. Only Red Hat, Inc. may make changes or
  25. # additions to the list of Approved Interfaces. You must obey the GNU General
  26. # Public License in all respects for all of the Program code and other code used
  27. # in conjunction with the Program except the Non-GPL Code covered by this
  28. # exception. If you modify this file, you may extend this exception to your
  29. # version of the file, but you are not obligated to do so. If you do not wish to
  30. # provide this exception without modification, you must delete this exception
  31. # statement from your version and license this file solely under the GPL without
  32. # exception.
  33. #
  34. #
  35. # Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  36. # Copyright (C) 2005 Red Hat, Inc.
  37. # All rights reserved.
  38. # --- END COPYRIGHT BLOCK ---
  39. $patchcmd = "swlist -l bundle";
  40. # [output sample]
  41. # Initializing...
  42. # Contacting target "linux2"...
  43. #
  44. # Target: linux2:/
  45. #
  46. #
  47. # B6268AA B.11.00.05 Graphics and Technical Computing Software
  48. # BUNDLE B.11.00 Patch Bundle
  49. # HPUXEng64RT B.11.00.01 English HP-UX 64-bit Runtime Environment
  50. # HWE1100 B.11.00.0206.5 Hardware Enablement Patches for HP-UX 11.00, June 2002
  51. # OnlineDiag B.11.00.21.10 HPUX 11.0 Support Tools Bundle, Jun 2002
  52. # QPK1100 B.11.00.64.4 Quality Pack for HP-UX 11.00, March 2004
  53. # UnlimUserLic B.11.00.02 HP-UX Unlimited-User License
  54. # XSWGR1100 B.11.00.47.08 General Release Patches, November 1999 (ACE)
  55. %month2digit = (
  56. 'January', 1,
  57. 'February', 2,
  58. 'March', 3,
  59. 'April', 4,
  60. 'May', 5,
  61. 'June', 6,
  62. 'July', 7,
  63. 'August', 8,
  64. 'September', 9,
  65. 'October', 10,
  66. 'November', 11,
  67. 'December', 12,
  68. );
  69. open PATCHCMD, "$patchcmd|" or die "Error: could not open $patchcmd: $!";
  70. sleep 1;
  71. $qpk_str = "";
  72. $month_year = "";
  73. while (<PATCHCMD>) {
  74. chop;
  75. if (/^\s+(QPK.*), ([A-Za-z]* [12][0-9]*)/) {
  76. $qpk_str = $1;
  77. $month_year = $2;
  78. }
  79. }
  80. close PATCHCMD;
  81. $date = gmtime;
  82. $host = `hostname`;
  83. chop $host;
  84. $dom = `domainname`;
  85. $un = `uname -a`;
  86. print "/* This list was generated by $0 */\n";
  87. print "/* on $host.$dom */\n";
  88. print "/* at $date GMT */\n";
  89. print "/* Here is the information from uname -a:\n";
  90. print $un;
  91. if ( $qpk_str eq "" )
  92. {
  93. print " Quality Pack is not installed on the system. */\n";
  94. }
  95. else
  96. {
  97. ($qpkname, $version, $description) = split(/[ ]+/, $qpk_str, 3);
  98. print "$qpkname\n";
  99. print "$version\n";
  100. print "$description\n";
  101. if ( $month_year eq "" )
  102. {
  103. print " Quality pack has no date info. */\n";
  104. print "$qpk_str <$month_year>\n";
  105. }
  106. else
  107. {
  108. ($month, $year) = split(/\s/, $month_year, 2);
  109. $mo = $month2digit{$month};
  110. print " The following is a Quality Pack installed on the system. */\n";
  111. print "{\"$qpkname\", \"$version\", \"$description\", $year, $mo, 0},\n";
  112. }
  113. }