INSTALL | 10 +++++-----
Makefile.PL | 10 ++++++++--
ci/deps.perl | 5 +++--
script/public-inbox-httpd | 15 +++++++++------
script/public-inbox.cgi | 15 +++++++++------
t/cgi.t | 1 +
t/httpd-https.t | 2 +-
t/psgi_attach.t | 6 ++----
t/psgi_bad_mids.t | 4 ++--
t/psgi_mount.t | 17 ++++++++---------
t/psgi_multipart_not.t | 2 +-
t/psgi_search.t | 2 +-
t/psgi_text.t | 5 ++---
t/psgi_v2.t | 2 +-
t/solver_git.t | 2 +-
t/view.t | 3 ++-
xt/mem-msgview.t | 3 +--
xt/perf-msgview.t | 2 +-
xt/solver.t | 2 +-
diff --git a/INSTALL b/INSTALL
index 137c9a54b1601dc6e0d75a29e5c9ff7816062204..f834b49f01fe5107415a813fdcf83e62ea7c77af 100644
--- a/INSTALL
+++ b/INSTALL
@@ -39,11 +39,6 @@ * Email::MIME deb: libemail-mime-perl
pkg: p5-Email-MIME
rpm: perl-Email-MIME
-* Plack deb: libplack-perl
- pkg: p5-Plack
- rpm: perl-Plack, perl-Plack-Test,
- (for HTML/Atom generation)
-
* URI::Escape deb: liburi-perl
pkg: p5-URI
rpm: perl-URI
@@ -54,6 +49,11 @@ "pkg" is for the FreeBSD package (maybe other common BSDs, too), and
"rpm" is for RPM-based distributions (only known to work on Fedora).
Numerous optional modules are likely to be useful as well:
+
+* Plack deb: libplack-perl
+ pkg: p5-Plack
+ rpm: perl-Plack, perl-Plack-Test,
+ (for HTML/Atom generation)
- DBD::SQLite deb: libdbd-sqlite3-perl
pkg: p5-DBD-SQLite
diff --git a/Makefile.PL b/Makefile.PL
index 3492d9653ece202ae1061970798828f4c9a3d78e..6b20385a56838708719ad44cea75ed3c2e523de9 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -127,8 +127,14 @@ # libperl$PERL_VERSION or libencode-perl on Debian,
# `perl5' on FreeBSD
'Encode' => 0,
- # TODO: these should really be made optional...
- 'Plack' => 0,
+ # Plack is needed for public-inbox-httpd and PublicInbox::WWW
+ # 'Plack' => 0,
+
+ # Filesys::Notify::Simple is pulled in by Plack, but also
+ # needed by public-inbox-watch (for now)
+ 'Filesys::Notify::Simple' => 0,
+
+ # TODO: this should really be made optional...
'URI::Escape' => 0,
# We have more test dependencies, but do not force
diff --git a/ci/deps.perl b/ci/deps.perl
index 330ba2f32fa43140bcde89733093afbb8bc1acfb..08722e1c41902275704a85b97f99be258192831d 100755
--- a/ci/deps.perl
+++ b/ci/deps.perl
@@ -9,7 +9,7 @@ my $usage = "$0 PKG_FMT PROFILE [PROFILE_MOD]";
my $pkg_fmt = shift;
@ARGV or die $usage, "\n";
-my @test_essential = qw(Test::Simple Plack::Test);
+my @test_essential = qw(Test::Simple); # we actually use Test::More
# package profiles
my $profiles = {
@@ -27,7 +27,6 @@ Email::MIME::ContentType
Encode
ExtUtils::MakeMaker
Filesys::Notify::Simple
- Plack
URI::Escape
), @test_essential ],
@@ -40,6 +39,8 @@ DBI
IO::Compress::Gzip
Inline::C
Net::Server
+ Plack
+ Plack::Test
Plack::Middleware::Deflater
Plack::Middleware::ReverseProxy
Search::Xapian
diff --git a/script/public-inbox-httpd b/script/public-inbox-httpd
index b2464f4efc0d31be9909c872c3969353e33768c6..09da505e5028952a60551f7bd2ffc25cf57c7780 100755
--- a/script/public-inbox-httpd
+++ b/script/public-inbox-httpd
@@ -1,15 +1,18 @@
#!/usr/bin/perl -w
-# Copyright (C) 2016-2019 all contributors
+# Copyright (C) 2016-2020 all contributors
# License: AGPL-3.0+
#
# Standalone HTTP server for public-inbox.
use strict;
-use warnings;
-use Plack::Util;
use PublicInbox::Daemon;
-use PublicInbox::HTTP;
-use PublicInbox::HTTPD;
-use Plack::Builder;
+BEGIN {
+ for (qw(Plack::Builder Plack::Util)) {
+ eval("require $_") or die "E: Plack is required for $0\n";
+ }
+ Plack::Builder->import;
+ require PublicInbox::HTTP;
+ require PublicInbox::HTTPD;
+}
my %httpds;
my $app;
my $refresh = sub {
diff --git a/script/public-inbox.cgi b/script/public-inbox.cgi
index c0e8e6c329b792333941f6f8d975fcb77d7dfb3e..c766483a208cacb4dceec28e8c80795447591ed6 100755
--- a/script/public-inbox.cgi
+++ b/script/public-inbox.cgi
@@ -1,14 +1,17 @@
#!/usr/bin/perl -w
-# Copyright (C) 2014-2019 all contributors
+# Copyright (C) 2014-2020 all contributors
# License: AGPL-3.0+ or later
#
# Enables using PublicInbox::WWW as a CGI script
use strict;
-use warnings;
-use Plack::Builder;
-use Plack::Handler::CGI;
-use PublicInbox::WWW;
-BEGIN { PublicInbox::WWW->preload if $ENV{MOD_PERL} }
+BEGIN {
+ for (qw(Plack::Builder Plack::Handler::CGI)) {
+ eval("require $_") or die "E: Plack is required for $0\n";
+ }
+ Plack::Builder->import;
+ require PublicInbox::WWW;
+ PublicInbox::WWW->preload if $ENV{MOD_PERL};
+}
my $www = PublicInbox::WWW->new;
my $have_deflater = eval { require Plack::Middleware::Deflater; 1 };
my $app = builder {
diff --git a/t/cgi.t b/t/cgi.t
index 9f67d5c0bd0004d89275c0d4e22a615993c3bc48..5760596ca66cda6fcf61f734f41a6c04da6615f4 100644
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -7,6 +7,7 @@ use warnings;
use Test::More;
use Email::MIME;
use PublicInbox::TestCommon;
+require_mods(qw(Plack::Handler::CGI Plack::Util));
my ($tmpdir, $for_destroy) = tmpdir();
my $home = "$tmpdir/pi-home";
my $pi_home = "$home/.public-inbox";
diff --git a/t/httpd-https.t b/t/httpd-https.t
index 265febe5ea843f7afb2691ab43657c1a5c8aafde..9ce060c8c7c1c8865648f92c381704eabac941c0 100644
--- a/t/httpd-https.t
+++ b/t/httpd-https.t
@@ -6,7 +6,7 @@ use Test::More;
use Socket qw(SOCK_STREAM IPPROTO_TCP SOL_SOCKET);
use PublicInbox::TestCommon;
# IO::Poll is part of the standard library, but distros may split them off...
-require_mods(qw(IO::Socket::SSL IO::Poll));
+require_mods(qw(IO::Socket::SSL IO::Poll Plack::Util));
my $cert = 'certs/server-cert.pem';
my $key = 'certs/server-key.pem';
unless (-r $key && -r $cert) {
diff --git a/t/psgi_attach.t b/t/psgi_attach.t
index 0c3174bc241c7c257567ea0905307c876316ae50..1ef5318cd4799aab1a5469b7884572acaa4faae4 100644
--- a/t/psgi_attach.t
+++ b/t/psgi_attach.t
@@ -9,15 +9,14 @@ my ($tmpdir, $for_destroy) = tmpdir();
my $maindir = "$tmpdir/main.git";
my $addr = 'test-public@example.com';
my $cfgpfx = "publicinbox.test";
-my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape);
+my @mods = qw(HTTP::Request::Common Plack::Builder Plack::Test URI::Escape);
require_mods(@mods);
use_ok $_ foreach @mods;
+use_ok 'PublicInbox::WWW';
use PublicInbox::Import;
use PublicInbox::Git;
use PublicInbox::Config;
-use PublicInbox::WWW;
use_ok 'PublicInbox::WwwAttach';
-use Plack::Builder;
my $config = PublicInbox::Config->new(\<content;
ok(length($dot_res) >= length($dot), 'dot almost matches');
$res = $cb->(GET('/test/Z%40B/4-any-filename.txt'));
is($res->content, $dot_res, 'user-specified filename is OK');
-
});
}
done_testing();
diff --git a/t/psgi_bad_mids.t b/t/psgi_bad_mids.t
index 5cdd249e7ea3608fdc0c45da2de85e826d4c32cd..b568786dfb4c3241810477a11402feee9e744eec 100644
--- a/t/psgi_bad_mids.t
+++ b/t/psgi_bad_mids.t
@@ -5,12 +5,12 @@ use warnings;
use Test::More;
use PublicInbox::MIME;
use PublicInbox::Config;
-use PublicInbox::WWW;
use PublicInbox::TestCommon;
my @mods = qw(DBD::SQLite HTTP::Request::Common Plack::Test
- URI::Escape Plack::Builder);
+ URI::Escape Plack::Builder PublicInbox::WWW);
require_mods(@mods);
use_ok($_) for @mods;
+use_ok 'PublicInbox::WWW';
use_ok 'PublicInbox::V2Writable';
my ($inboxdir, $for_destroy) = tmpdir();
my $cfgpfx = "publicinbox.bad-mids";
diff --git a/t/psgi_mount.t b/t/psgi_mount.t
index 751c13b715a0c8616a79e7e5b0ef58eac3da8497..d29df054586d477fb598558a82adcd065340c500 100644
--- a/t/psgi_mount.t
+++ b/t/psgi_mount.t
@@ -9,15 +9,14 @@ my ($tmpdir, $for_destroy) = tmpdir();
my $maindir = "$tmpdir/main.git";
my $addr = 'test-public@example.com';
my $cfgpfx = "publicinbox.test";
-my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape);
+my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape
+ Plack::Builder Plack::App::URLMap);
require_mods(@mods);
use_ok $_ foreach @mods;
+use_ok 'PublicInbox::WWW';
use PublicInbox::Import;
use PublicInbox::Git;
use PublicInbox::Config;
-use PublicInbox::WWW;
-use Plack::Builder;
-use Plack::App::URLMap;
my $config = PublicInbox::Config->new(\<done;
}
my $www = PublicInbox::WWW->new($config);
-my $app = builder {
- enable 'Head';
- mount '/a' => builder { sub { $www->call(@_) } };
- mount '/b' => builder { sub { $www->call(@_) } };
-};
+my $app = builder(sub {
+ enable('Head');
+ mount('/a' => builder(sub { sub { $www->call(@_) } }));
+ mount('/b' => builder(sub { sub { $www->call(@_) } }));
+});
test_psgi($app, sub {
my ($cb) = @_;
diff --git a/t/psgi_multipart_not.t b/t/psgi_multipart_not.t
index 606151c49d6006a5e401a07c89ba29242c8f0cff..47a691f67c98be1a22ea64ef178ce8073779f1f0 100644
--- a/t/psgi_multipart_not.t
+++ b/t/psgi_multipart_not.t
@@ -5,12 +5,12 @@ use warnings;
use Test::More;
use Email::MIME;
use PublicInbox::Config;
-use PublicInbox::WWW;
use PublicInbox::TestCommon;
my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common
Plack::Test URI::Escape Plack::Builder Plack::Test);
require_mods(@mods);
use_ok($_) for (qw(HTTP::Request::Common Plack::Test));
+use_ok 'PublicInbox::WWW';
use_ok 'PublicInbox::V2Writable';
my ($repo, $for_destroy) = tmpdir();
my $ibx = PublicInbox::Inbox->new({
diff --git a/t/psgi_search.t b/t/psgi_search.t
index 534063f8ed5206bbd8229dd92699973c2270cde1..5310e5aba9553bbabf252da82c97d3a520c9165e 100644
--- a/t/psgi_search.t
+++ b/t/psgi_search.t
@@ -7,13 +7,13 @@ use Email::MIME;
use PublicInbox::Config;
use PublicInbox::Inbox;
use PublicInbox::InboxWritable;
-use PublicInbox::WWW;
use bytes (); # only for bytes::length
use PublicInbox::TestCommon;
my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test
URI::Escape Plack::Builder);
require_mods(@mods);
use_ok($_) for (qw(HTTP::Request::Common Plack::Test));
+use_ok 'PublicInbox::WWW';
my ($tmpdir, $for_destroy) = tmpdir();
my $ibx = PublicInbox::Inbox->new({
diff --git a/t/psgi_text.t b/t/psgi_text.t
index 757a1294ba6d6d0312da3aa7154e02133adfb9e0..7cb7a165cdc226998935f35a8eee8bf506baa5dd 100644
--- a/t/psgi_text.t
+++ b/t/psgi_text.t
@@ -9,15 +9,14 @@ my ($tmpdir, $for_destroy) = tmpdir();
my $maindir = "$tmpdir/main.git";
my $addr = 'test-public@example.com';
my $cfgpfx = "publicinbox.test";
-my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape);
+my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape Plack::Builder);
require_mods(@mods);
use_ok $_ foreach @mods;
use PublicInbox::Import;
use PublicInbox::Git;
use PublicInbox::Config;
-use PublicInbox::WWW;
+use_ok 'PublicInbox::WWW';
use_ok 'PublicInbox::WwwText';
-use Plack::Builder;
my $config = PublicInbox::Config->new(\</dev/null`);
plan skip_all => "$0 must be run from a git working tree" if $?;
diff --git a/t/view.t b/t/view.t
index 92962b15f2007eeac9b3df438508edc5be94ea2f..38c12fcc1fda8bddd64be81dba0c17920228142b 100644
--- a/t/view.t
+++ b/t/view.t
@@ -3,8 +3,9 @@ # License: AGPL-3.0+
use strict;
use warnings;
use Test::More;
+use PublicInbox::TestCommon;
use Email::MIME;
-use Plack::Util;
+require_mods('Plack::Util');
use_ok 'PublicInbox::View';
use_ok 'PublicInbox::Config';
diff --git a/xt/mem-msgview.t b/xt/mem-msgview.t
index 1ea0f559ee0a329482bba0db94524843a1dc8332..0c3ad71070bb595f59811f1b3f070ee377c11918 100644
--- a/xt/mem-msgview.t
+++ b/xt/mem-msgview.t
@@ -6,9 +6,8 @@ use IO::Handle; # ->flush
use Fcntl qw(SEEK_SET);
use PublicInbox::TestCommon;
use PublicInbox::Tmpfile;
-use PublicInbox::WWW;
use Test::More;
-my @mods = qw(DBD::SQLite BSD::Resource);
+my @mods = qw(DBD::SQLite BSD::Resource PublicInbox::WWW);
require_mods(@mods);
use_ok($_) for @mods;
my $lines = $ENV{NR_LINES} // 100000;
diff --git a/xt/perf-msgview.t b/xt/perf-msgview.t
index 11bd3a5d64657ff8d476e1273fd38d5f71490265..8c9037ee215e019dd9664a4c694d5b7034eae627 100644
--- a/xt/perf-msgview.t
+++ b/xt/perf-msgview.t
@@ -18,7 +18,7 @@ } else {
warn
"git <2.19, cat-file lacks --unordered, locality suffers\n";
}
-
+require_mods qw(Plack::Util);
use_ok 'Plack::Util';
my $ibx = PublicInbox::Inbox->new({ inboxdir => $inboxdir, name => 'name' });
my $git = $ibx->git;
diff --git a/xt/solver.t b/xt/solver.t
index 4ff57fe75d4de1fe60443f64add4e03e7f5075a4..5307e1201cb96251b284eabf748d620aed485659 100644
--- a/xt/solver.t
+++ b/xt/solver.t
@@ -5,10 +5,10 @@ use strict;
use Test::More;
use PublicInbox::TestCommon;
use PublicInbox::Config; # this relies on PI_CONFIG // ~/.public-inbox/config
-use PublicInbox::WWW;
my @psgi = qw(HTTP::Request::Common Plack::Test URI::Escape Plack::Builder);
require_mods(qw(DBD::SQLite Search::Xapian), @psgi);
use_ok($_) for @psgi;
+use_ok 'PublicInbox::WWW';
my $cfg = PublicInbox::Config->new;
my $www = PublicInbox::WWW->new($cfg);
my $app = sub {