From 9b3f1717ed84c11d5df27c9594b76acd444a0e13 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 24 Jun 2018 23:18:32 -0400 Subject: sbosrcarch: add by-md5 stats to check/status --- sbosrcarch | 59 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 21 deletions(-) (limited to 'sbosrcarch') diff --git a/sbosrcarch b/sbosrcarch index 2b49c22..72c3cdb 100755 --- a/sbosrcarch +++ b/sbosrcarch @@ -402,9 +402,11 @@ our $extraneous_byname = 0; our %infofilecount; our %parsedinfo; +our %allmd5sums; our $symlinkcount = 0; our $hardlinkcount = 0; our $filecount = 0; +our $md5_filecount = 0; our $filebytes = 0; our $actualfilecount = 0; our $totalfiles = 0; @@ -1630,8 +1632,6 @@ sub check_bymd5_wanted { return; } - my $realmd5 = md5sum_file($_) || return; - my (undef, $a, $b, $md5dir, $filename, $extra) = split /\//; if(!defined($filename) || defined($extra)) { @@ -1650,14 +1650,25 @@ sub check_bymd5_wanted { } } - my $reala = substr($realmd5, 0, 1); - my $realb = substr($realmd5, 1, 1); - if($reala ne $a || $realb ne $b) { - print "$_: wrong subdir (should be $reala/$realb/$realmd5)\n"; + if(!$quickcheck) { + my $realmd5 = md5sum_file($_) || return; + my $reala = substr($realmd5, 0, 1); + my $realb = substr($realmd5, 1, 1); + if($reala ne $a || $realb ne $b) { + print "$_: wrong subdir (should be $reala/$realb/$realmd5)\n"; + return; + } + + if($realmd5 ne $md5dir) { + print "$_: md5sum mismatch\n"; + return; + } } - if($realmd5 ne $md5dir) { - print "$_: md5sum mismatch\n"; + if($allmd5sums{$md5dir}) { + print "$_ extraneous: not mentioned in any .info file\n" if $verbosecheck; + } else { + $md5_filecount++; } } @@ -1682,6 +1693,7 @@ sub check_info_wanted { $totalfiles += keys %$dls; $infofilecount{"$category/$prgnam"} += keys %$dls; $parsedinfo{"$category/$prgnam"} = $dls; + $allmd5sums{$_}++ for values %$dls; } sub check_mode { @@ -1700,10 +1712,8 @@ sub check_mode { print "* Checking by-name tree...\n"; find({wanted => \&check_byname_wanted, no_chdir => 1}, "by-name"); - if(!$quickcheck) { - print "* Checking by-md5 tree...\n"; - find({wanted => \&check_bymd5_wanted, no_chdir => 1}, "by-md5"); - } + print "* Checking by-md5 tree...\n"; + find({wanted => \&check_bymd5_wanted, no_chdir => 1}, "by-md5"); my @missingfilebuilds; for(keys %infofilecount) { @@ -1711,16 +1721,16 @@ sub check_mode { push @missingfilebuilds, $_ if $count; } - print "---\n"; + if($symlinkcount && $hardlinkcount) { + print "by-md5 contains both symlinks and hardlinks (harmless but messy)\n"; + } + + print "--- by-name summary\n"; if(@missingfilebuilds) { - print "Following SlackBuilds are missing files:\n"; + print "Following SlackBuilds are missing by-name files:\n"; print " $_\n" for sort { $a cmp $b } @missingfilebuilds; } else { - print "All SlackBuild download files present\n"; - } - - if($symlinkcount && $hardlinkcount) { - print "by-md5 contains both symlinks and hardlinks (harmless but messy)\n"; + print "All SlackBuild download files present in by-name.\n"; } my $totalbuildcount = keys %infofilecount; @@ -1731,15 +1741,22 @@ sub check_mode { my $missingfiles = $totalfiles - $filecount; my $filecoverage = sprintf("%.2f", $filecount * 100 / $totalfiles); + my $md5_totalfiles = keys %allmd5sums; + my $md5_missingfiles = $md5_totalfiles - $md5_filecount; + my $md5_filecoverage = sprintf("%.2f", $md5_filecount * 100 / $md5_totalfiles); + print <