]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/LeiSucks.pm
e832f95e07367d28bfcea8e6a0c5b77d026b71ba
[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
15 sub lei_sucks {
16         my ($lei, @argv) = @_;
17         $lei->start_pager if -t $lei->{1};
18         my ($os, undef, $rel, undef, $mac)= POSIX::uname();
19         if ($mac eq 'x86_64' && $Config{ptrsize} == 4) {
20                 $mac .= $Config{cppsymbols} =~ /\b__ILP32__=1\b/ ?
21                         ',u=x32' : ',u=x86';
22         }
23         eval { require PublicInbox };
24         my $pi_ver = eval('$PublicInbox::VERSION') // '(???)';
25         my @out = ("lei $pi_ver\n",
26                 "perl $Config{version} / $os $rel / $mac ".
27                 "ptrsize=$Config{ptrsize}\n");
28         chomp(my $gv = `git --version` || "git missing");
29         $gv =~ s/ version / /;
30         my $json = ref(PublicInbox::Config->json);
31         $json .= ' ' . eval('$'.$json.'::VERSION') if $json;
32         $json ||= '(no JSON)';
33         push @out, "$gv / $json\n";
34         if (eval { require PublicInbox::Over }) {
35                 push @out, 'SQLite '.
36                         (eval('$DBD::SQLite::sqlite_version') // '(undef)') .
37                         ', DBI '.(eval('$DBI::VERSION') // '(undef)') .
38                         ', DBD::SQLite '.
39                         (eval('$DBD::SQLite::VERSION') // '(undef)')."\n";
40         } else {
41                 push @out, "Unable to load DBI / DBD::SQLite: $@\n";
42         }
43         if (eval { require PublicInbox::Search } &&
44                         PublicInbox::Search::load_xapian()) {
45                 push @out, 'Xapian '.
46                         join('.', map {
47                                 $PublicInbox::Search::Xap->can($_)->();
48                         } qw(major_version minor_version revision)) .
49                         ", bindings: $PublicInbox::Search::Xap";
50                 my $xs_ver = eval '$'."$PublicInbox::Search::Xap".'::VERSION';
51                 push @out, $xs_ver ? " $xs_ver\n" : " SWIG\n";
52         } else {
53                 push @out, "Xapian not available: $@\n";
54         }
55         my $dig = Digest::SHA->new(1);
56         push @out, "public-inbox blob OIDs of loaded features:\n";
57         for my $m (grep(m{^PublicInbox/}, sort keys %INC)) {
58                 my $f = $INC{$m} // next; # lazy require failed (missing dep)
59                 $dig->add('blob '.(-s $f)."\0");
60                 $dig->addfile($f);
61                 push @out, '  '.$dig->hexdigest.' '.$m."\n";
62         }
63         push @out, <<'EOM';
64 Let us know how it sucks!  Please include the above and any other
65 relevant information when sending plain-text mail to us at:
66 meta@public-inbox.org -- archives: https://public-inbox.org/meta/
67 EOM
68         $lei->out(@out);
69 }
70
71 1;