added dev-only script to test system 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
11sub _gather_installed {
12 my ($self) = @_;
13 my $command = "dpkg-query --show";
14 open my $pipe, '-|', $command
15 or die "Unable to open pipe to '$command': $!\n";
16 my %package;
17 while (defined( my $line = <$pipe> )) {
18 chomp $line;
19 my ($package, $version) = split m{\s+}, $line;
20 $package{ $package } = {
21 version => $version,
22 };
23 }
24 return \%package;
25}
26
271;