| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Alien::Packages::LsLpp; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 1123 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 42 |  | 
| 4 | 1 |  |  | 1 |  | 6 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 41 |  | 
| 5 | 1 |  |  | 1 |  | 5 | use vars qw($VERSION @ISA); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 693 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | =head1 NAME | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | Alien::Packages::LsLpp - handles AIX lslpp packaging system | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | =cut | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | $VERSION = "0.003"; | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | require Alien::Packages::Base; | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | @ISA = qw(Alien::Packages::Base); | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | =head1 ISA | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | Alien::Packages::LsLpp | 
| 22 |  |  |  |  |  |  | ISA Alien::Packages::Base | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | =cut | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | require IPC::Cmd; | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | my $lslpp; | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | =head1 SUBROUTINES/METHODS | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | =head2 usable | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | Returns true when the C command could be found in the path. | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | =cut | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | sub usable | 
| 39 |  |  |  |  |  |  | { | 
| 40 | 1 | 50 |  | 1 | 1 | 10 | unless ( defined($lslpp) ) | 
| 41 |  |  |  |  |  |  | { | 
| 42 | 1 |  |  |  |  | 9 | $lslpp = IPC::Cmd::can_run('lslpp'); | 
| 43 | 1 |  | 50 |  |  | 1123 | $lslpp ||= ''; | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 1 |  |  |  |  | 13 | return $lslpp; | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | =head2 pkgtype | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | Returns the pkg type "lpp". | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | =cut | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | sub pkgtype | 
| 56 |  |  |  |  |  |  | { | 
| 57 | 0 |  |  | 0 | 1 |  | return 'lpp'; | 
| 58 |  |  |  |  |  |  | } | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | =head2 list_packages | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | Get's the list of installed filesets. | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | =cut | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | sub list_packages | 
| 67 |  |  |  |  |  |  | { | 
| 68 | 0 |  |  | 0 | 1 |  | my $self = $_[0]; | 
| 69 | 0 |  |  |  |  |  | my @packages; | 
| 70 |  |  |  |  |  |  |  | 
| 71 | 0 |  |  |  |  |  | my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = | 
| 72 |  |  |  |  |  |  | $self->_run_ipc_cmd( command => [ $lslpp, '-lc' ], | 
| 73 |  |  |  |  |  |  | verbose => 0, ); | 
| 74 |  |  |  |  |  |  |  | 
| 75 | 0 | 0 |  |  |  |  | if ($success) | 
| 76 |  |  |  |  |  |  | { | 
| 77 | 0 |  |  |  |  |  | chomp $stdout_buf->[0]; | 
| 78 | 0 |  |  |  |  |  | my @pkglist = split( /\n/, $stdout_buf->[0] ); | 
| 79 | 0 |  |  |  |  |  | foreach my $pkg (@pkglist) | 
| 80 |  |  |  |  |  |  | { | 
| 81 | 0 | 0 |  |  |  |  | next if ( $pkg =~ m/^#/ ); | 
| 82 | 0 |  |  |  |  |  | my @pkg_details = split( ':', $pkg ); | 
| 83 | 0 | 0 |  |  |  |  | next if ( scalar @pkg_details < 7 ); | 
| 84 | 0 |  |  |  |  |  | my %pkg_details; | 
| 85 | 0 |  |  |  |  |  | @pkg_details{ 'Package', 'Version', 'Summary' } = | 
| 86 |  |  |  |  |  |  | ( @pkg_details[ 1, 2 ], $pkg_details[6] ); | 
| 87 | 0 |  |  |  |  |  | push( @packages, \%pkg_details ); | 
| 88 |  |  |  |  |  |  | } | 
| 89 |  |  |  |  |  |  | } | 
| 90 |  |  |  |  |  |  |  | 
| 91 | 0 |  |  |  |  |  | return @packages; | 
| 92 |  |  |  |  |  |  | } | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =head2 list_fileowners | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | Returns the filesets which have installed a file. | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =cut | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | sub list_fileowners | 
| 101 |  |  |  |  |  |  | { | 
| 102 | 0 |  |  | 0 | 1 |  | my ( $self, @files ) = @_; | 
| 103 | 0 |  |  |  |  |  | my %file_owners; | 
| 104 |  |  |  |  |  |  |  | 
| 105 | 0 |  |  |  |  |  | foreach my $file (@files) | 
| 106 |  |  |  |  |  |  | { | 
| 107 | 0 |  |  |  |  |  | my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = | 
| 108 |  |  |  |  |  |  | $self->_run_ipc_cmd( command => [ $lslpp, '-wc', $file ], | 
| 109 |  |  |  |  |  |  | verbose => 0, ); | 
| 110 |  |  |  |  |  |  |  | 
| 111 | 0 | 0 |  |  |  |  | if ($success) | 
| 112 |  |  |  |  |  |  | { | 
| 113 | 0 |  |  |  |  |  | chomp $stdout_buf->[0]; | 
| 114 | 0 |  |  |  |  |  | my @output = split( /\n/, $stdout_buf->[0] ); | 
| 115 | 0 |  |  |  |  |  | foreach my $line (@output) | 
| 116 |  |  |  |  |  |  | { | 
| 117 | 0 | 0 |  |  |  |  | next if ( $line =~ m/^#/ ); | 
| 118 | 0 |  |  |  |  |  | my @info = split( ":", $line ); | 
| 119 | 0 | 0 |  |  |  |  | next if ( scalar @info < 3 );    # nonsense line | 
| 120 | 0 |  |  |  |  |  | push( @{ $file_owners{$file} }, { Package => $info[1] } ); | 
|  | 0 |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | } | 
| 122 |  |  |  |  |  |  | } | 
| 123 |  |  |  |  |  |  | } | 
| 124 |  |  |  |  |  |  |  | 
| 125 | 0 |  |  |  |  |  | return %file_owners; | 
| 126 |  |  |  |  |  |  | } | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | =head1 AUTHOR | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | Jens Rehsack, C<<  >> | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | =head1 LICENSE AND COPYRIGHT | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | Copyright 2010 Jens Rehsack. | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it | 
| 137 |  |  |  |  |  |  | under the terms of either: the GNU General Public License as published | 
| 138 |  |  |  |  |  |  | by the Free Software Foundation; or the Artistic License. | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | See http://dev.perl.org/licenses/ for more information. | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | =cut | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | 1; |