source: ocsinventory-agent/trunk/fuentes/lib/Ocsinventory/Agent/Backend/OS/MacOS/Packages.pm @ 468

Last change on this file since 468 was 468, checked in by mabarracus, 4 years ago

Copyt trusty code

File size: 1.1 KB
Line 
1package Ocsinventory::Agent::Backend::OS::MacOS::Packages;
2
3use strict;
4use warnings;
5
6sub check {
7    my $params = shift;
8
9    return unless can_load("Mac::SysProfile");
10    # Do not run an package inventory if there is the --nosoft parameter
11    return if ($params->{config}->{nosoft});
12
13    1;
14}
15
16sub run {
17    my $params = shift;
18    my $common = $params->{common};
19
20    my $profile = Mac::SysProfile->new();
21    my $data = $profile->gettype('SPApplicationsDataType'); # might need to check version of darwin
22
23    return unless($data && ref($data) eq 'ARRAY');
24
25    # for each app, normalize the information, then add it to the inventory stack
26    foreach my $app (@$data){
27        #my $a = $apps->{$app};
28        my $kind = $app->{'runtime_environment'} ? $app->{'runtime_environment'} : 'UNKNOWN';
29        my $comments = '['.$kind.']';
30        $common->addSoftware({
31            'NAME'      => $app->{'_name'},
32            'VERSION'   => $app->{'version'} || 'unknown',
33            'COMMENTS'  => $comments,
34            'PUBLISHER' => $app->{'info'} || 'unknown',
35        });
36    }
37}
38
391;
Note: See TracBrowser for help on using the repository browser.