source: ocsinventory-agent/trunk/fuentes/lib/Ocsinventory/Agent/Backend/OS/Generic/Packaging/RPM.pm @ 468

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

Copyt trusty code

File size: 960 bytes
Line 
1package Ocsinventory::Agent::Backend::OS::Generic::Packaging::RPM;
2
3use strict;
4use warnings;
5
6sub check {
7  return unless can_run("rpm");
8
9  # Some time rpm is a wrapper or an alias for another
10  `rpm --version 2>&1`;
11  return if ($? >> 8)!=0;
12  1;
13}
14
15sub run {
16  my $params = shift;
17  my $common = $params->{common};
18  my $logger = $params->{logger};
19
20  my @list;
21  my $buff;
22  foreach (`rpm -qa --queryformat "%{NAME}.%{ARCH} %{VERSION}-%{RELEASE} --%{INSTALLTIME:date}-- --%{SIZE}-- %{SUMMARY}\n--\n" 2>/dev/null`) {
23    if (! /^--/) {
24      chomp;
25      $buff .= $_;
26    } elsif ($buff =~ s/^(\S+)\s+(\S+)\s+--(.*)--\s+--(.*)--\s+(.*)//) {
27    $common->addSoftware({
28        'NAME'          => $1,
29        'VERSION'       => $2,
30        'INSTALLDATE'   => $3,
31        'FILESIZE'      => $4,
32        'COMMENTS'      => $5,
33        'FROM'          => 'rpm'
34                });
35    } else {
36      $logger->debug("Should never go here!");
37      $buff = '';
38    }
39  }
40}
41
421;
Note: See TracBrowser for help on using the repository browser.