51 lines
1.0 KiB
Perl
Executable File
51 lines
1.0 KiB
Perl
Executable File
#!/usr/bin/perl
|
|
#
|
|
# $Id: prtcheckmissing,v 1.1 2003/10/27 15:26:50 opel Exp $
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
my @missing;
|
|
my @mask = parse_pkgadd_conf();
|
|
|
|
local $/ = ""; # read files paragraph-wise; see ``perldoc perlvar''
|
|
|
|
open my $dbh, "< /var/lib/pkg/db"
|
|
or die "Couldn't open package database!\n";
|
|
|
|
while(<$dbh>) {
|
|
my ($pkg_name, $pkg_version, @pkg_file) = split /\n/;
|
|
@missing = grep { (! -e "/$_") && wanted($_, @mask) } @pkg_file;
|
|
next if not @missing;
|
|
|
|
print map "/$_ $pkg_name\n", @missing;
|
|
}
|
|
|
|
close($dbh);
|
|
|
|
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;
|
|
}
|