]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/LeiSucks.pm
imap+nntp: share COMPRESS implementation
[public-inbox.git] / lib / PublicInbox / LeiSucks.pm
1 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 # Undocumented hidden command somebody might discover if they're
5 # frustrated and need to report a bug.  There's no manpage and
6 # it won't show up in tab completions or help.
7 package PublicInbox::LeiSucks;
8 use strict;
9 use v5.10.1;
10 use Digest::SHA ();
11 use Config;
12 use POSIX ();
13 use PublicInbox::Config;
14 use PublicInbox::IPC;
15
16 sub lei_sucks {
17         my ($lei, @argv) = @_;
18         $lei->start_pager if -t $lei->{1};
19         my ($os, undef, $rel, undef, $mac)= POSIX::uname();
20         if ($mac eq 'x86_64' && $Config{ptrsize} == 4) {
21                 $mac .= $Config{cppsymbols} =~ /\b__ILP32__=1\b/ ?
22                         ',u=x32' : ',u=x86';
23         }
24         eval { require PublicInbox };
25         my $pi_ver = eval('$PublicInbox::VERSION') // '(???)';
26         my $nproc = PublicInbox::IPC::detect_nproc() // '?';
27         my @out = ("lei $pi_ver\n",
28                 "perl $Config{version} / $os $rel / $mac ".
29                 "ptrsize=$Config{ptrsize} nproc=$nproc\n");
30         chomp(my $gv = `git --version` || "git missing");
31         $gv =~ s/ version / /;
32         my $json = ref(PublicInbox::Config->json);
33         $json .= ' ' . eval('$'.$json.'::VERSION') if $json;
34         $json ||= '(no JSON)';
35         push @out, "$gv / $json\n";
36         if (eval { require PublicInbox::Over }) {
37                 push @out, 'SQLite '.
38                         (eval('$DBD::SQLite::sqlite_version') // '(undef)') .
39                         ', DBI '.(eval('$DBI::VERSION') // '(undef)') .
40                         ', DBD::SQLite '.
41                         (eval('$DBD::SQLite::VERSION') // '(undef)')."\n";
42         } else {
43                 push @out, "Unable to load DBI / DBD::SQLite: $@\n";
44         }
45         if (eval { require PublicInbox::Search } &&
46                         PublicInbox::Search::load_xapian()) {
47                 push @out, 'Xapian '.
48                         join('.', map {
49                                 $PublicInbox::Search::Xap->can($_)->();
50                         } qw(major_version minor_version revision)) .
51                         ", bindings: $PublicInbox::Search::Xap";
52                 my $xs_ver = eval '$'."$PublicInbox::Search::Xap".'::VERSION';
53                 push @out, $xs_ver ? " $xs_ver\n" : " SWIG\n";
54         } else {
55                 push @out, "Xapian not available: $@\n";
56         }
57         my $dig = Digest::SHA->new(1);
58         push @out, "public-inbox blob OIDs of loaded features:\n";
59         for my $m (grep(m{^PublicInbox/}, sort keys %INC)) {
60                 my $f = $INC{$m} // next; # lazy require failed (missing dep)
61                 $dig->add('blob '.(-s $f)."\0");
62                 $dig->addfile($f);
63                 push @out, '  '.$dig->hexdigest.' '.$m."\n";
64         }
65         push @out, <<'EOM';
66 Let us know how it sucks!  Please include the above and any other
67 relevant information when sending plain-text mail to us at:
68 meta@public-inbox.org -- archives: https://public-inbox.org/meta/
69 EOM
70         $lei->out(@out);
71 }
72
73 1;