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