Commit | Line | Data |
afd7c030 |
1 | package System::Introspector::Probe::Packages::Apt; |
97b10529 |
2 | use Moo; |
3 | |
9ee104cc |
4 | use System::Introspector::Util qw( |
5 | handle_from_command |
6 | transform_exceptions |
7 | ); |
8 | |
97b10529 |
9 | sub gather { |
10 | my ($self) = @_; |
11 | return { |
9ee104cc |
12 | installed => transform_exceptions { |
13 | return { packages => $self->_gather_installed }; |
14 | }, |
97b10529 |
15 | }; |
16 | } |
17 | |
3d4ae7f9 |
18 | sub _open_dpkg_query_pipe { |
97b10529 |
19 | my ($self) = @_; |
9ee104cc |
20 | return handle_from_command 'dpkg-query --show'; |
3d4ae7f9 |
21 | } |
22 | |
23 | sub _gather_installed { |
24 | my ($self) = @_; |
25 | my $pipe = $self->_open_dpkg_query_pipe; |
97b10529 |
26 | my %package; |
27 | while (defined( my $line = <$pipe> )) { |
28 | chomp $line; |
29 | my ($package, $version) = split m{\s+}, $line; |
30 | $package{ $package } = { |
31 | version => $version, |
32 | }; |
33 | } |
34 | return \%package; |
35 | } |
36 | |
37 | 1; |
535e84b6 |
38 | |
39 | __END__ |
40 | |
41 | =head1 NAME |
42 | |
43 | System::Introspector::Packages::Apt - Gather APT package status |
44 | |
45 | =head1 DESCRIPTION |
46 | |
47 | Uses C<dpkg-query> to list all installed packages. |
48 | |
49 | =head1 SEE ALSO |
50 | |
51 | =over |
52 | |
53 | =item L<System::Introspector> |
54 | |
55 | =back |
56 | |
57 | =cut |