Subversion Repositories camp_sysinfo_client_3

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 rodolico 1
#!/usr/bin/env perl
2
use warnings;
2 rodolico 3
 
20 rodolico 4
$main::VERSION = '1.0';
5
 
6
# IPFire software module for sysinfo client
7
# Author: R. W. Rodolico
8
# Date:   2016-04-08
9
 
2 rodolico 10
# gets information on software on systems with dpkg on them (Debian)
11
 
12
BEGIN {
13
   push @INC, shift;
14
}
15
 
16
use library;
17
 
7 rodolico 18
exit unless -d '/opt/pakfire';
2 rodolico 19
my $CATEGORY = 'software';
20
my $pakfireInstallInfo = '/opt/pakfire/db/installed';
21
my $updates = 'meta-core-upgrade-' . `cat /opt/pakfire/db/core/mine`;
22
chomp $updates;
23
 
24
opendir( my $installsDir, $pakfireInstallInfo ) or die "could not open pakFire installs dir $pakfireInstallInfo: $!\n";
25
my @files = grep { ! /^\./ && -f "$pakfireInstallInfo/$_" } readdir( $installsDir );
26
closedir $installsDir;
27
 
28
foreach my $thisPackage ( @files ) {
29
   next if $thisPackage =~ m/meta-core-upgrade/ && $thisPackage ne $updates;
30
   open PACKAGE, "<$pakfireInstallInfo/$thisPackage" or die "could not open package file $pakfireInstallInfo/$thisPackage: $!\n";
31
   my %packageInfo;
32
   while ( $line = <PACKAGE> ) {
33
      next unless $line =~ m/:/;
34
      chomp $line;
35
      my ( $key, $value ) = split( ':', $line );
36
      $packageInfo{$key} = $value;
37
   }
38
   print "$CATEGORY\t$packageInfo{'Name'}\tversion\t$packageInfo{'ProgVersion'}\n";
39
   print "$CATEGORY\t$packageInfo{'Name'}\trelease\t$packageInfo{'Release'}\n";
40
}
41
1;