prtcheckmissing: detect missing symlinks too
This commit is contained in:
parent
c225a44932
commit
b75ee0be7f
|
@ -1,27 +1,47 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
#
|
#
|
||||||
# $Id: prtcheckmissing,v 1.1 2003/10/27 15:26:50 opel Exp $
|
# $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 strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
my @missing;
|
my @installed; my @regfiles; my @symlinks; my @missingReg; my @missingSym;
|
||||||
my @mask = parse_pkgadd_conf();
|
my @mask = parse_pkgadd_conf();
|
||||||
|
|
||||||
local $/ = ""; # read files paragraph-wise; see ``perldoc perlvar''
|
open(PORTLIST,"-|","prt-get printf '%i:%p/%n\n'");
|
||||||
|
while (<PORTLIST>) {
|
||||||
open my $dbh, "< /var/lib/pkg/db"
|
push(@installed,$1) if m/^yes:(.+)/;
|
||||||
or die "Couldn't open package database!\n";
|
}
|
||||||
|
|
||||||
while(<$dbh>) {
|
foreach (@installed) {
|
||||||
my ($pkg_name, $pkg_version, @pkg_file) = split /\n/;
|
local $/ = ""; # read files paragraph-wise; see ``perldoc perlvar''
|
||||||
@missing = grep { (! -e "/$_") && wanted($_, @mask) } @pkg_file;
|
my $pf = "$_/.footprint";
|
||||||
next if not @missing;
|
my $pkg_name = (split /\//)[-1];
|
||||||
|
open (my $dbh, $pf)
|
||||||
print map "/$_ $pkg_name\n", @missing;
|
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;
|
||||||
|
|
||||||
|
# apply the pkgadd rules to eliminate false positives
|
||||||
|
@missingSym = grep { (! -e "/$_") && wanted($_, @mask) } @symlinks;
|
||||||
|
@missingReg = grep { (! -e "/$_") && wanted($_, @mask) } @regfiles;
|
||||||
|
|
||||||
|
# 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
close($dbh);
|
|
||||||
|
|
||||||
sub parse_pkgadd_conf {
|
sub parse_pkgadd_conf {
|
||||||
my @unwanted;
|
my @unwanted;
|
||||||
|
|
Loading…
Reference in New Issue