From c4841d9f15e0359233b881c8f844097caa891961 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 26 Oct 2015 19:39:25 -0400 Subject: sbosrcarch: add status mode --- sbosrcarch | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/sbosrcarch b/sbosrcarch index 650315b..5fe3e07 100755 --- a/sbosrcarch +++ b/sbosrcarch @@ -145,6 +145,15 @@ Will not modify the archive in any way, but might recommend fixes. With -v, lists all SlackBuilds not covered by the archive. + is quite I/O and CPU intensive, as it must read and md5sum every +file in the archive. + +=item B I<[-v]> + +Checks the coverage of the archive. Like , but doesn't md5sum the +files (it just assumes they're correct). Use this as a quick way to get +a status report. + =item B I<[-f] [ ...]> Manually add (possibly already downloaded) files to the archive. @@ -370,6 +379,7 @@ our ($curl, $curlopts); our (%whitehash, %blackhash, $use_bwlist); our @whitelist = (); our @blacklist = (); +our $quickcheck; # used by check_mode() and its *wanted helpers our %infofilecount; our %parsedinfo; @@ -1504,7 +1514,7 @@ sub check_byname_wanted { } my $dls = $parsedinfo{"$category/$prgnam"}; - my $md5 = md5sum_file($_); + my $md5 = md5sum_file($_) unless $quickcheck; my $foundfile; # make $info and printable (relative path only) @@ -1514,13 +1524,15 @@ sub check_byname_wanted { my $infofilename = url_to_filename($dl); if($infofilename eq $filename) { $foundfile++; - if($md5 ne $dls->{$dl}) { - print "$info: $shortname: wrong md5sum (should be $dls->{$dl})\n"; - } else { - # check by-md5 file existence only (check_bymd5_wanted will do more) - my $md5file = md5_dir($md5) . "/" . $filename; - if(! -e $md5file) { - print "$info: $shortname: missing $md5file\n"; + if(!$quickcheck) { + if($md5 ne $dls->{$dl}) { + print "$info: $shortname: wrong md5sum (should be $dls->{$dl})\n"; + } else { +# check by-md5 file existence only (check_bymd5_wanted will do more) + my $md5file = md5_dir($md5) . "/" . $filename; + if(! -e $md5file) { + print "$info: $shortname: missing $md5file\n"; + } } } } @@ -1594,6 +1606,7 @@ sub check_info_wanted { } sub check_mode { + $quickcheck = shift; # 1 = don't md5sum stuff shift @ARGV; my $verbose = ($ARGV[0] && $ARGV[0] =~ /^-*v(?:erbose)?$/); @@ -1608,8 +1621,10 @@ sub check_mode { print "* Checking by-name tree...\n"; find({wanted => \&check_byname_wanted, no_chdir => 1}, "by-name"); - print "* Checking by-md5 tree...\n"; - find({wanted => \&check_bymd5_wanted, no_chdir => 1}, "by-md5"); + if(!$quickcheck) { + print "* Checking by-md5 tree...\n"; + find({wanted => \&check_bymd5_wanted, no_chdir => 1}, "by-md5"); + } my @missingfilebuilds; for(keys %infofilecount) { @@ -1722,7 +1737,8 @@ for ($ARGV[0]) { /add/ && do { add_or_rm_mode(); }; /rm/ && do { add_or_rm_mode(); }; /trim/ && do { trim_mode(); }; - /check/ && do { check_mode(); }; + /check/ && do { check_mode(0); }; + /status/ && do { check_mode(1); }; /bwlist/ && do { bwlist_mode(); }; usage(); } -- cgit v1.2.3