#!/usr/bin/env perl use warnings; use strict; # Description: Get software packages installed on IPFire router our $VERSION = '1.3'; # IPFire software module for sysinfo client # Author: R. W. Rodolico # Date: 2016-04-08 # gets information on software on systems with dpkg on them (Debian) BEGIN { push @INC, shift; } use library; exit unless -d '/opt/pakfire'; my $CATEGORY = 'software'; my $pakfireInstallInfo = '/opt/pakfire/db/installed'; my $updates = 'meta-core-upgrade-' . `cat /opt/pakfire/db/core/mine`; chomp $updates; opendir( my $installsDir, $pakfireInstallInfo ) or die "could not open pakFire installs dir $pakfireInstallInfo: $!\n"; my @files = grep { ! /^\./ && -f "$pakfireInstallInfo/$_" } readdir( $installsDir ); closedir $installsDir; foreach my $thisPackage ( @files ) { next if $thisPackage =~ m/meta-core-upgrade/ && $thisPackage ne $updates; open PACKAGE, "<$pakfireInstallInfo/$thisPackage" or die "could not open package file $pakfireInstallInfo/$thisPackage: $!\n"; my %packageInfo; while ( my $line = ) { next unless $line =~ m/:/; chomp $line; my ( $key, $value ) = split( ':', $line ); $packageInfo{$key} = $value; } print "$CATEGORY\t$packageInfo{'Name'}\tversion\t$packageInfo{'ProgVersion'}\n"; print "$CATEGORY\t$packageInfo{'Name'}\trelease\t$packageInfo{'Release'}\n"; } 1;