2023-03-21 20:34:20 -04:00
|
|
|
#!/usr/bin/perl
|
|
|
|
#
|
|
|
|
# $Id: prtcheckmissing,v 1.1 2003/10/27 15:26:50 opel Exp $
|
2023-03-25 11:00:24 -04:00
|
|
|
# prtcheckmissing,v 1.2 2022/05/31 18:41:19 jmq Exp $
|
2023-03-21 20:34:20 -04:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
my @mask = parse_pkgadd_conf();
|
|
|
|
|
2023-03-27 15:37:34 -04:00
|
|
|
open (my $dbh, "/var/lib/pkg/db") or die "Could not read package database!\n";
|
|
|
|
local $/ = ""; # read files paragraph-wise; see ``perldoc perlvar''
|
2023-03-21 20:34:20 -04:00
|
|
|
|
2023-03-27 15:37:34 -04:00
|
|
|
while(<$dbh>) {
|
|
|
|
my ($name, $version, @files) = split /\n/;
|
2023-03-21 20:34:20 -04:00
|
|
|
|
2023-03-25 11:00:24 -04:00
|
|
|
# apply the pkgadd rules to eliminate false positives
|
2023-03-27 15:37:34 -04:00
|
|
|
my @missing = grep { (! -e "/$_") && wanted($_, @mask) } @files;
|
2023-03-21 20:34:20 -04:00
|
|
|
|
2023-03-25 11:00:24 -04:00
|
|
|
# final report for this package
|
2023-03-27 15:37:34 -04:00
|
|
|
next if not @missing;
|
|
|
|
print map "/$_ $name\n", @missing;
|
2023-03-21 20:34:20 -04:00
|
|
|
}
|
2023-03-27 15:37:34 -04:00
|
|
|
close($dbh);
|
2023-03-21 20:34:20 -04:00
|
|
|
|
|
|
|
sub parse_pkgadd_conf {
|
|
|
|
my @unwanted;
|
|
|
|
local $/ = "\n";
|
|
|
|
open my $pah, "< /etc/pkgadd.conf"
|
|
|
|
or die "Couldn't open pkgadd install rules!\n";
|
|
|
|
|
|
|
|
while(<$pah>) {
|
|
|
|
next if /^\s*#/ or /^$/;
|
|
|
|
my ($event, $pattern, $choice) = split;
|
|
|
|
push (@unwanted, qr/$pattern/s) if ($event eq "INSTALL" and $choice eq "NO");
|
|
|
|
}
|
|
|
|
close ($pah);
|
|
|
|
|
|
|
|
return @unwanted;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub wanted {
|
|
|
|
my $testfile = shift;
|
|
|
|
my $retval = 1;
|
|
|
|
while (my $regexp=shift) {
|
|
|
|
$retval = 0 if $testfile =~ $regexp;
|
|
|
|
last if $retval==0;
|
|
|
|
}
|
|
|
|
return $retval;
|
|
|
|
}
|