summaryrefslogtreecommitdiffstats
path: root/ldap/systools/getHPPatches.pl
blob: 4d1be441e2f4ea37f03b495db21ed418f5643701 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/tools/ns/bin/perl5.6.1 -w

$patchcmd = "swlist -l bundle";
# [output sample]
# Initializing...
# Contacting target "linux2"...
#
# Target:  linux2:/
#
#
# B6268AA      B.11.00.05     Graphics and Technical Computing Software 
# BUNDLE       B.11.00        Patch Bundle   
# HPUXEng64RT  B.11.00.01     English HP-UX 64-bit Runtime Environment 
# HWE1100      B.11.00.0206.5 Hardware Enablement Patches for HP-UX 11.00, June 2002 
# OnlineDiag   B.11.00.21.10  HPUX 11.0 Support Tools Bundle, Jun 2002 
# QPK1100      B.11.00.64.4   Quality Pack for HP-UX 11.00, March 2004 
# UnlimUserLic B.11.00.02     HP-UX Unlimited-User License 
# XSWGR1100    B.11.00.47.08  General Release Patches, November 1999 (ACE) 

%month2digit = (
    'January',   1,
    'February',  2,
    'March',     3,
    'April',     4,
    'May',       5,
    'June',      6,
    'July',      7,
    'August',    8,
    'September', 9,
    'October',   10,
    'November',  11,
    'December',  12,
);

open PATCHCMD, "$patchcmd|" or die "Error: could not open $patchcmd: $!";
sleep 1;

$qpk_str = "";
$month_year = "";
while (<PATCHCMD>) {
  chop;
  if (/^\s+(QPK.*), ([A-Za-z]* [12][0-9]*)/) {
    $qpk_str = $1;
    $month_year = $2;
  }
}
close PATCHCMD;

$date = gmtime;
$host = `hostname`;
chop $host;
$dom = `domainname`;
$un = `uname -a`;

print "/* This list was generated by $0 */\n";
print "/*   on $host.$dom */\n";
print "/*   at $date GMT */\n";
print "/* Here is the information from uname -a:\n";
print $un;
if ( $qpk_str eq "" )
{
    print " Quality Pack is not installed on the system. */\n";
}
else
{
    ($qpkname, $version, $description) = split(/[     ]+/, $qpk_str, 3);
    print "$qpkname\n";
    print "$version\n";
    print "$description\n";

    if ( $month_year eq "" )
    {
        print " Quality pack has no date info. */\n";
        print "$qpk_str <$month_year>\n";
    }
    else
    {
        ($month, $year) = split(/\s/, $month_year, 2);
        $mo = $month2digit{$month};
        print " The following is a Quality Pack installed on the system. */\n";
        print "{\"$qpkname\", \"$version\", \"$description\", $year, $mo, 0},\n";
    }
}