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