added base pod to all probes
[scpubgit/System-Introspector.git] / lib / System / Introspector / Packages / Apt.pm
CommitLineData
97b10529 1package System::Introspector::Packages::Apt;
2use Moo;
3
4sub gather {
5 my ($self) = @_;
6 return {
7 installed => $self->_gather_installed,
8 };
9}
10
3d4ae7f9 11sub _open_dpkg_query_pipe {
97b10529 12 my ($self) = @_;
3d4ae7f9 13 my $command = 'dpkg-query --show';
97b10529 14 open my $pipe, '-|', $command
15 or die "Unable to open pipe to '$command': $!\n";
3d4ae7f9 16 return $pipe;
17}
18
19sub _gather_installed {
20 my ($self) = @_;
21 my $pipe = $self->_open_dpkg_query_pipe;
97b10529 22 my %package;
23 while (defined( my $line = <$pipe> )) {
24 chomp $line;
25 my ($package, $version) = split m{\s+}, $line;
26 $package{ $package } = {
27 version => $version,
28 };
29 }
30 return \%package;
31}
32
331;
535e84b6 34
35__END__
36
37=head1 NAME
38
39System::Introspector::Packages::Apt - Gather APT package status
40
41=head1 DESCRIPTION
42
43Uses C<dpkg-query> to list all installed packages.
44
45=head1 SEE ALSO
46
47=over
48
49=item L<System::Introspector>
50
51=back
52
53=cut