* [PATCH 1/2] build: generate PublicInbox.pm with $VERSION
2021-04-01 9:32 [PATCH 0/2] lei sucks Eric Wong
@ 2021-04-01 9:32 ` Eric Wong
2021-04-01 9:32 ` [PATCH 2/2] lei sucks: sub-command to aid bug reporting Eric Wong
1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2021-04-01 9:32 UTC (permalink / raw)
To: meta
Thanks to git-describe, we can generate and update this
file to aid users in bug reporting.
---
.gitignore | 1 +
MANIFEST | 1 +
Makefile.PL | 9 +++++++--
t/config.t | 7 ++++---
version-gen.perl | 29 +++++++++++++++++++++++++++++
5 files changed, 42 insertions(+), 5 deletions(-)
create mode 100644 version-gen.perl
diff --git a/.gitignore b/.gitignore
index f7e4c595..f0370cca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,4 @@
/NEWS.atom
/NEWS
*.log
+/lib/PublicInbox.pm
diff --git a/MANIFEST b/MANIFEST
index 49d273fc..5e3b4aec 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -482,6 +482,7 @@ t/www_listing.t
t/www_static.t
t/x-unknown-alpine.eml
t/xcpdb-reshard.t
+version-gen.perl
xt/cmp-msgstr.t
xt/cmp-msgview.t
xt/create-many-inboxes.t
diff --git a/Makefile.PL b/Makefile.PL
index feb89ec1..129b082d 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -5,6 +5,7 @@ use strict;
use ExtUtils::MakeMaker;
open my $m, '<', 'MANIFEST' or die "open(MANIFEST): $!\n";
chomp(my @manifest = (<$m>));
+push @manifest, 'lib/PublicInbox.pm'; # generated
my @EXE_FILES = grep(m!^script/!, @manifest);
my $v = {};
my $t = {};
@@ -139,7 +140,7 @@ WriteMakefile(
NAME => 'PublicInbox', # n.b. camel-case is not our choice
# XXX drop "PENDING" in .pod before updating this!
- VERSION => '1.6.1',
+ VERSION => '1.7.0.PENDING',
AUTHOR => 'Eric Wong <e@80x24.org>',
ABSTRACT => 'public-inbox server infrastructure',
@@ -242,13 +243,17 @@ Makefile.PL : MANIFEST
# prefix + bindir matches git.git Makefile:
prefix = \$(HOME)
bindir = \$(prefix)/bin
-symlink-install :
+symlink-install : lib/PublicInbox.pm
mkdir -p \$(bindir)
lei=\$\$(realpath lei.sh) && cd \$(bindir) && \\
for x in \$(EXE_FILES); do \\
ln -sf "\$\$lei" \$\$(basename "\$\$x"); \\
done
+pure_all :: lib/PublicInbox.pm
+lib/PublicInbox.pm : FORCE
+ VERSION=\$(VERSION) \$(PERL) -w ./version-gen.perl
+
update-copyrights :
\@case '\$(GNULIB_PATH)' in '') echo >&2 GNULIB_PATH unset; false;; esac
git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \\
diff --git a/t/config.t b/t/config.t
index 73527ec2..877e5d5d 100644
--- a/t/config.t
+++ b/t/config.t
@@ -1,11 +1,12 @@
# Copyright (C) 2014-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
-use warnings;
-use Test::More;
-use PublicInbox::Config;
+use v5.10.1;
use PublicInbox::TestCommon;
use PublicInbox::Import;
+use_ok 'PublicInbox';
+ok(defined(eval('$PublicInbox::VERSION')), 'VERSION defined');
+use_ok 'PublicInbox::Config';
my ($tmpdir, $for_destroy) = tmpdir();
{
diff --git a/version-gen.perl b/version-gen.perl
new file mode 100644
index 00000000..e9964e30
--- /dev/null
+++ b/version-gen.perl
@@ -0,0 +1,29 @@
+#!perl -w
+use v5.10.1;
+my $v = $ENV{VERSION} // die 'VERSION unset';
+my $f = './lib/PublicInbox.pm';
+if (-d ($ENV{GIT_DIR} // '.git') || -f '.git') {
+ chomp(my $gv = `git describe --match "v[0-9]*" HEAD`);
+ if ($? == 0) {
+ substr($gv, 0, 1, ''); # remove "v"
+ system(qw(git update-index -q --refresh));
+ if (my @n = `git diff-index --name-only HEAD --`) {
+ $gv .= '-dirty';
+ }
+ $v = $gv;
+ }
+}
+$v =~ tr/-/./;
+if (-f $f && do $f && (eval('$PublicInbox::VERSION') // 'undef') eq $v) {
+ exit
+}
+my $tmp = "$f.tmp.$$";
+open my $fh, '>', $tmp or die "open($tmp): $!";
+print $fh <<EOM or die "print($tmp): $!";
+# this file is generated by $0
+package PublicInbox;
+our \$VERSION = '$v';
+1;
+EOM
+close $fh or die "close($tmp): $!";
+rename($tmp, $f) or die "rename($tmp, $f): $!";
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] lei sucks: sub-command to aid bug reporting
2021-04-01 9:32 [PATCH 0/2] lei sucks Eric Wong
2021-04-01 9:32 ` [PATCH 1/2] build: generate PublicInbox.pm with $VERSION Eric Wong
@ 2021-04-01 9:32 ` Eric Wong
1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2021-04-01 9:32 UTC (permalink / raw)
To: meta
It's a bit of an Easter egg, though it's not possible to hide those
in Free Software... Anyways, it doesn't cost us an entry in %CMD
of LEI.pm and anybody frustrated enough with lei just might type
"lei sucks" on the command-line :>
---
MANIFEST | 1 +
lib/PublicInbox/LeiSucks.pm | 71 +++++++++++++++++++++++++++++++++++++
t/lei.t | 1 +
3 files changed, 73 insertions(+)
create mode 100644 lib/PublicInbox/LeiSucks.pm
diff --git a/MANIFEST b/MANIFEST
index 5e3b4aec..64293bb6 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -203,6 +203,7 @@ lib/PublicInbox/LeiQuery.pm
lib/PublicInbox/LeiRemote.pm
lib/PublicInbox/LeiSearch.pm
lib/PublicInbox/LeiStore.pm
+lib/PublicInbox/LeiSucks.pm
lib/PublicInbox/LeiTag.pm
lib/PublicInbox/LeiToMail.pm
lib/PublicInbox/LeiXSearch.pm
diff --git a/lib/PublicInbox/LeiSucks.pm b/lib/PublicInbox/LeiSucks.pm
new file mode 100644
index 00000000..d364a856
--- /dev/null
+++ b/lib/PublicInbox/LeiSucks.pm
@@ -0,0 +1,71 @@
+# Copyright (C) 2021 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
+# frustrated and need to report a bug. There's no manpage and
+# it won't show up in tab completions or help.
+package PublicInbox::LeiSucks;
+use strict;
+use v5.10.1;
+use Digest::SHA ();
+use Config;
+use POSIX ();
+use PublicInbox::Config;
+use PublicInbox::Search;
+
+sub lei_sucks {
+ my ($lei, @argv) = @_;
+ $lei->start_pager if -t $lei->{1};
+ my ($os, undef, $rel, undef, $mac)= POSIX::uname();
+ if ($mac eq 'x86_64' && $Config{ptrsize} == 4) {
+ $mac = $Config{cppsymbols} =~ /\b__ILP32__=1\b/ ? 'x32' : 'i386'
+ }
+ eval { require PublicInbox };
+ my $pi_ver = eval('$PublicInbox::VERSION') // '(???)';
+ my $daemon = $lei->{oneshot} ? 'oneshot' : 'daemon';
+ my @out = ("lei $pi_ver mode=$daemon\n",
+ "perl $Config{version} / $os $rel / $mac ".
+ "ptrsize=$Config{ptrsize}\n");
+ chomp(my $gv = `git --version` || "git missing");
+ $gv =~ s/ version / /;
+ my $json = ref(PublicInbox::Config->json);
+ $json .= ' ' . eval('$'.$json.'::VERSION') if $json;
+ $json ||= '(no JSON)';
+ push @out, "$gv / $json\n";
+ if (eval { require PublicInbox::Over }) {
+ push @out, 'SQLite '.
+ (eval('$DBD::SQLite::sqlite_version') // '(undef)') .
+ ', DBI '.(eval('$DBI::VERSION') // '(undef)') .
+ ', DBD::SQLite '.
+ (eval('$DBD::SQLite::VERSION') // '(undef)')."\n";
+ } else {
+ push @out, "Unable to load DBI / DBD::SQLite: $@\n";
+ }
+ if (PublicInbox::Search::load_xapian()) {
+ push @out, 'Xapian '.
+ join('.', map {
+ $PublicInbox::Search::Xap->can($_)->();
+ } qw(major_version minor_version revision)) .
+ ", bindings: $PublicInbox::Search::Xap";
+ my $xs_ver = eval '$'."$PublicInbox::Search::Xap".'::VERSION';
+ push @out, $xs_ver ? " $xs_ver\n" : " SWIG\n";
+ } 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";
+ }
+ push @out, <<'EOM';
+Let us know how it sucks! Please include the above and any other
+relevant information when sending plain-text mail to us at:
+meta@public-inbox.org -- archives: https://public-inbox.org/meta/
+EOM
+ $lei->out(@out);
+}
+
+1;
diff --git a/t/lei.t b/t/lei.t
index 0cf97866..2be9b4e8 100644
--- a/t/lei.t
+++ b/t/lei.t
@@ -154,6 +154,7 @@ my $test_fail = sub {
"error noted with q $fl");
}
}
+ lei_ok('sucks', \'yes, but hopefully less every day');
SKIP: {
skip 'no curl', 3 unless which('curl');
lei(qw(q --only http://127.0.0.1:99999/bogus/ t:m));
^ permalink raw reply related [flat|nested] 3+ messages in thread