]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiSucks.pm
No ext_urls
[public-inbox.git] / lib / PublicInbox / LeiSucks.pm
index a71158f36f03c97c9b3cdc8a0c0a96e8cbdd8c70..35d0a8de5dc51c0710d67ddc8ca5613745140756 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # Undocumented hidden command somebody might discover if they're
@@ -7,11 +7,11 @@
 package PublicInbox::LeiSucks;
 use strict;
 use v5.10.1;
-use Digest::SHA ();
+use PublicInbox::SHA qw(sha1_hex);
 use Config;
 use POSIX ();
 use PublicInbox::Config;
-use PublicInbox::Search;
+use PublicInbox::IPC;
 
 sub lei_sucks {
        my ($lei, @argv) = @_;
@@ -23,9 +23,10 @@ sub lei_sucks {
        }
        eval { require PublicInbox };
        my $pi_ver = eval('$PublicInbox::VERSION') // '(???)';
+       my $nproc = PublicInbox::IPC::detect_nproc() // '?';
        my @out = ("lei $pi_ver\n",
                "perl $Config{version} / $os $rel / $mac ".
-               "ptrsize=$Config{ptrsize}\n");
+               "ptrsize=$Config{ptrsize} nproc=$nproc\n");
        chomp(my $gv = `git --version` || "git missing");
        $gv =~ s/ version / /;
        my $json = ref(PublicInbox::Config->json);
@@ -41,7 +42,8 @@ sub lei_sucks {
        } else {
                push @out, "Unable to load DBI / DBD::SQLite: $@\n";
        }
-       if (PublicInbox::Search::load_xapian()) {
+       if (eval { require PublicInbox::Search } &&
+                       PublicInbox::Search::load_xapian()) {
                push @out, 'Xapian '.
                        join('.', map {
                                $PublicInbox::Search::Xap->can($_)->();
@@ -52,13 +54,13 @@ sub lei_sucks {
        } else {
                push @out, "Xapian not available: $@\n";
        }
-       my $dig = Digest::SHA->new(1);
        push @out, "public-inbox blob OIDs of loaded features:\n";
        for my $m (grep(m{^PublicInbox/}, sort keys %INC)) {
-               my $f = $INC{$m};
-               $dig->add('blob '.(-s $f)."\0");
-               $dig->addfile($f);
-               push @out, '  '.$dig->hexdigest.' '.$m."\n";
+               my $f = $INC{$m} // next; # lazy require failed (missing dep)
+               open my $fh, '<', $f or do { warn "open($f): $!"; next };
+               my $hex = sha1_hex('blob '.(-s $fh)."\0".
+                               (do { local $/; <$fh> } // die("read: $!")));
+               push @out, '  '.$hex.' '.$m."\n";
        }
        push @out, <<'EOM';
 Let us know how it sucks!  Please include the above and any other