prtcheckmissing: initial import, honoring custom rules in pkgadd.conf
This commit is contained in:
parent
4037fba241
commit
35ded8f2f8
|
@ -0,0 +1,50 @@
|
||||||
|
#!/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;
|
||||||
|
}
|
Loading…
Reference in New Issue