* [PATCH 0/2] Plack and Filesys::Notify::Simple are optional
@ 2020-01-10 8:49 Eric Wong
2020-01-10 8:49 ` [PATCH 1/2] make Plack optional for non-WWW and non-httpd users Eric Wong
2020-01-10 8:49 ` [PATCH 2/2] make Filesys::Notify::Simple optional Eric Wong
0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2020-01-10 8:49 UTC (permalink / raw)
To: meta
Not everybody cares for web interfaces or watching Maildirs.
Increase the flexibility of the installation by making these
optional so (nntpd|mda)-only installations can be a thing.
Eric Wong (2):
make Plack optional for non-WWW and non-httpd users
make Filesys::Notify::Simple optional
INSTALL | 10 +++++-----
Makefile.PL | 10 ++++++++--
ci/deps.perl | 10 +++++-----
lib/PublicInbox/WatchMaildir.pm | 3 ++-
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 +-
20 files changed, 63 insertions(+), 53 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] make Plack optional for non-WWW and non-httpd users
2020-01-10 8:49 [PATCH 0/2] Plack and Filesys::Notify::Simple are optional Eric Wong
@ 2020-01-10 8:49 ` Eric Wong
2020-01-10 8:49 ` [PATCH 2/2] make Filesys::Notify::Simple optional Eric Wong
1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2020-01-10 8:49 UTC (permalink / raw)
To: meta
Some users just want to run -mda, -watch, and/or -nntpd.
Let them run just those without forcing them to pull in a
bunch of dependencies.
---
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 +-
19 files changed, 59 insertions(+), 49 deletions(-)
diff --git a/INSTALL b/INSTALL
index 137c9a54..f834b49f 100644
--- a/INSTALL
+++ b/INSTALL
@@ -39,11 +39,6 @@ Beyond that, there is a long list of Perl modules required, starting with:
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
@@ -55,6 +50,11 @@ Where "deb" indicates package names for Debian-derived distributions,
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
rpm: perl-DBD-SQLite
diff --git a/Makefile.PL b/Makefile.PL
index 3492d965..6b20385a 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -127,8 +127,14 @@ WriteMakefile(
# `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 330ba2f3..08722e1c 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 @@ my $profiles = {
Encode
ExtUtils::MakeMaker
Filesys::Notify::Simple
- Plack
URI::Escape
), @test_essential ],
@@ -40,6 +39,8 @@ my $profiles = {
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 b2464f4e..09da505e 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 <meta@public-inbox.org>
+# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# 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 c0e8e6c3..c766483a 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 <meta@public-inbox.org>
+# Copyright (C) 2014-2020 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ or later <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# 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 9f67d5c0..5760596c 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 265febe5..9ce060c8 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 0c3174bc..1ef5318c 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(\<<EOF);
$cfgpfx.address=$addr
$cfgpfx.inboxdir=$maindir
@@ -108,7 +107,6 @@ my $im = PublicInbox::Import->new($git, 'test', $addr);
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 5cdd249e..b568786d 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 751c13b7..d29df054 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(\<<EOF);
$cfgpfx.address=$addr
$cfgpfx.inboxdir=$maindir
@@ -41,11 +40,11 @@ EOF
}
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 606151c4..47a691f6 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 534063f8..5310e5ab 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 757a1294..7cb7a165 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(\<<EOF);
$cfgpfx.address=$addr
$cfgpfx.inboxdir=$maindir
diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index 8c619cee..2ecd7458 100644
--- a/t/psgi_v2.t
+++ b/t/psgi_v2.t
@@ -7,11 +7,11 @@ use PublicInbox::TestCommon;
require_git(2.6);
use PublicInbox::MIME;
use PublicInbox::Config;
-use PublicInbox::WWW;
use PublicInbox::MID qw(mids);
require_mods(qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test
URI::Escape Plack::Builder));
use_ok($_) for (qw(HTTP::Request::Common Plack::Test));
+use_ok 'PublicInbox::WWW';
use_ok 'PublicInbox::V2Writable';
my ($inboxdir, $for_destroy) = tmpdir();
my $ibx = {
diff --git a/t/solver_git.t b/t/solver_git.t
index 55746994..a9bad860 100644
--- a/t/solver_git.t
+++ b/t/solver_git.t
@@ -7,7 +7,7 @@ use Cwd qw(abs_path);
use PublicInbox::TestCommon;
require_git(2.6);
use PublicInbox::Spawn qw(spawn);
-require_mods(qw(DBD::SQLite Search::Xapian));
+require_mods(qw(DBD::SQLite Search::Xapian Plack::Util));
chomp(my $git_dir = `git rev-parse --git-dir 2>/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 92962b15..38c12fcc 100644
--- a/t/view.t
+++ b/t/view.t
@@ -3,8 +3,9 @@
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 1ea0f559..0c3ad710 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 11bd3a5d..8c9037ee 100644
--- a/xt/perf-msgview.t
+++ b/xt/perf-msgview.t
@@ -18,7 +18,7 @@ if (require_git(2.19, 1)) {
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 4ff57fe7..5307e120 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 {
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] make Filesys::Notify::Simple optional
2020-01-10 8:49 [PATCH 0/2] Plack and Filesys::Notify::Simple are optional Eric Wong
2020-01-10 8:49 ` [PATCH 1/2] make Plack optional for non-WWW and non-httpd users Eric Wong
@ 2020-01-10 8:49 ` Eric Wong
1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2020-01-10 8:49 UTC (permalink / raw)
To: meta
It's only used by us in public-inbox-watch, and maybe not
for long. It's in most installations because Plack pulls it
in though, but Plack is no longer required.
---
Makefile.PL | 2 +-
ci/deps.perl | 5 ++---
lib/PublicInbox/WatchMaildir.pm | 3 ++-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 6b20385a..94ec16c6 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -132,7 +132,7 @@ WriteMakefile(
# Filesys::Notify::Simple is pulled in by Plack, but also
# needed by public-inbox-watch (for now)
- 'Filesys::Notify::Simple' => 0,
+ # 'Filesys::Notify::Simple' => 0,
# TODO: this should really be made optional...
'URI::Escape' => 0,
diff --git a/ci/deps.perl b/ci/deps.perl
index 08722e1c..93cc5d25 100755
--- a/ci/deps.perl
+++ b/ci/deps.perl
@@ -14,8 +14,7 @@ my @test_essential = qw(Test::Simple); # we actually use Test::More
# package profiles
my $profiles = {
# the smallest possible profile for testing
- # TODO: trim this, Plack pulls in Filesys::Notify::Simple,
- # and we don't need that for mda-only installs
+ # TODO: trim URI::Escape from this, maybe
essential => [ qw(
git
perl
@@ -26,7 +25,6 @@ my $profiles = {
Email::MIME::ContentType
Encode
ExtUtils::MakeMaker
- Filesys::Notify::Simple
URI::Escape
), @test_essential ],
@@ -36,6 +34,7 @@ my $profiles = {
BSD::Resource
DBD::SQLite
DBI
+ Filesys::Notify::Simple
IO::Compress::Gzip
Inline::C
Net::Server
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index 8a8c1262..5d0515e0 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -203,7 +203,8 @@ sub watch {
# lazy load here, we may support watching via IMAP IDLE
# in the future...
- require Filesys::Notify::Simple;
+ eval { require Filesys::Notify::Simple } or
+ die "Filesys::Notify::Simple is currently required for $0\n";
my $fsn = Filesys::Notify::Simple->new([@{$self->{mdir}}, $scandir]);
$fsn->wait($cb) until $self->{quit};
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-01-10 8:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 8:49 [PATCH 0/2] Plack and Filesys::Notify::Simple are optional Eric Wong
2020-01-10 8:49 ` [PATCH 1/2] make Plack optional for non-WWW and non-httpd users Eric Wong
2020-01-10 8:49 ` [PATCH 2/2] make Filesys::Notify::Simple optional Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).