prtcheckmissing: no need to distinguish between symlinks and regular files

This commit is contained in:
John McQuah 2023-03-27 15:37:34 -04:00
parent 287e853171
commit 40d0787003
1 changed files with 8 additions and 28 deletions

View File

@ -2,46 +2,26 @@
#
# $Id: prtcheckmissing,v 1.1 2003/10/27 15:26:50 opel Exp $
# prtcheckmissing,v 1.2 2022/05/31 18:41:19 jmq Exp $
# prtcheckmissing,v 1.3 2023/03/25 15:55:20 jmq Exp $
use strict;
use warnings;
my @installed; my @regfiles; my @symlinks; my @missingReg; my @missingSym;
my @mask = parse_pkgadd_conf();
open(PORTLIST,"-|","prt-get printf '%i:%p/%n\n'");
while (<PORTLIST>) {
push(@installed,$1) if m/^yes:(.+)/;
}
open (my $dbh, "/var/lib/pkg/db") or die "Could not read package database!\n";
local $/ = ""; # read files paragraph-wise; see ``perldoc perlvar''
foreach (@installed) {
local $/ = ""; # read files paragraph-wise; see ``perldoc perlvar''
my $pf = "$_/.footprint";
my $pkg_name = (split /\//)[-1];
open (my $dbh, $pf)
or die "Could not read $pf !\n";
while(<$dbh>) {
my @pkg_file = split /\n/;
# erase the annotations that appear in the footprint
foreach (@pkg_file) { s/ \(EMPTY\)//; s/ \([0-9]+, [0-9]+\)//; }
# extract the paths, ignoring fields for mode and uid/gid
@symlinks = map {(split /[\t ]/, $_)[2]} grep {m/ -> /} @pkg_file;
@regfiles = map {(split /\t/, $_)[2]} grep { !m/ -> / } @pkg_file;
while(<$dbh>) {
my ($name, $version, @files) = split /\n/;
# apply the pkgadd rules to eliminate false positives
@missingSym = grep { (! -e "/$_") && wanted($_, @mask) } @symlinks;
@missingReg = grep { (! -e "/$_") && wanted($_, @mask) } @regfiles;
my @missing = grep { (! -e "/$_") && wanted($_, @mask) } @files;
# final report for this package
next if ((not @missingSym) and (not @missingReg));
print map "/$_ $pkg_name\n", @missingReg if (@missingReg);
print map "/$_ $pkg_name\n", @missingSym if (@missingSym);
}
close($dbh);
next if not @missing;
print map "/$_ $name\n", @missing;
}
close($dbh);
sub parse_pkgadd_conf {
my @unwanted;