]> Sergey Matveev's repositories - public-inbox.git/commitdiff
make zlib-related modules a hard dependency
authorEric Wong <e@yhbt.net>
Tue, 21 Apr 2020 06:57:34 +0000 (06:57 +0000)
committerEric Wong <e@yhbt.net>
Wed, 22 Apr 2020 07:04:45 +0000 (07:04 +0000)
This allows us to simplify some of our existing code and make
future changes easier.

I doubt anybody goes through the trouble to have a Perl
installation without zlib support.  The zlib source code is even
bundled with Perl since 5.9.3 for systems without existing zlib
development headers and libraries.

Of course, zlib is also a requirement of git, too; and we're not
going to stop using git :)

[squashed: "wwwaltid: use gzipfilter up front"]

Makefile.PL
ci/deps.perl
lib/PublicInbox/Mbox.pm
lib/PublicInbox/NNTP.pm
lib/PublicInbox/WwwAltId.pm
lib/PublicInbox/WwwListing.pm
script/public-inbox-nntpd

index ab24b9cf1ae20387846fd4434ce480e7981a4b48..27bb112c31649ec00879f25b08d81bffebdfd7fa 100644 (file)
@@ -132,6 +132,11 @@ WriteMakefile(
                # `perl5' on FreeBSD
                'Encode' => 0,
 
+               # libperl$PERL_VERSION + perl-modules-$PERL_VERSION
+               'Compress::Raw::Zlib' => 0,
+               'Compress::Zlib' => 0,
+               'IO::Compress::Gzip' => 0,
+
                # Plack is needed for public-inbox-httpd and PublicInbox::WWW
                # 'Plack' => 0,
 
index b960089f415366a8f6acaac95451701047f7ee2f..06b4fbe0f2f3a0be7a939a94405fcf272528f9c1 100755 (executable)
@@ -25,6 +25,7 @@ my $profiles = {
                Email::MIME::ContentType
                Encode
                ExtUtils::MakeMaker
+               IO::Compress::Gzip
                URI::Escape
                ), @test_essential ],
 
@@ -35,7 +36,6 @@ my $profiles = {
                DBD::SQLite
                DBI
                Filesys::Notify::Simple
-               IO::Compress::Gzip
                Inline::C
                Net::Server
                Plack
index 9995140cd8228db8b26313927d04e432a3007cf2..97bec5e79a3b468b88faa0b2e8ac72bbf198552f 100644 (file)
@@ -152,8 +152,7 @@ sub thread_cb {
 
 sub thread_mbox {
        my ($ctx, $over, $sfx) = @_;
-       eval { require PublicInbox::MboxGz };
-       return need_gzip($ctx) if $@;
+       require PublicInbox::MboxGz;
        my $msgs = $ctx->{msgs} = $over->get_thread($ctx->{mid}, {});
        return [404, [qw(Content-Type text/plain)], []] if !@$msgs;
        $ctx->{prev} = $msgs->[-1];
@@ -221,8 +220,7 @@ sub results_cb {
 sub mbox_all {
        my ($ctx, $query) = @_;
 
-       eval { require PublicInbox::MboxGz };
-       return need_gzip($ctx) if $@;
+       require PublicInbox::MboxGz;
        return mbox_all_ids($ctx) if $query eq '';
        my $qopts = $ctx->{qopts} = { mset => 2 };
        my $srch = $ctx->{srch} = $ctx->{-inbox}->search or
@@ -236,15 +234,4 @@ sub mbox_all {
        PublicInbox::MboxGz->response($ctx, \&results_cb, 'results-'.$query);
 }
 
-sub need_gzip {
-       html_oneshot($_[0], 501, \<<EOF);
-<pre>gzipped mbox not available
-
-The administrator needs to install the Compress::Raw::Zlib Perl module
-to support gzipped mboxes.
-
-<a href="../">Return to index</a></pre>
-EOF
-}
-
 1;
index c79f198beb186f00c441d31e1ca122cad77a58eb..e9c66cd1c7038251ff8081925ad452441333b8a6 100644 (file)
@@ -38,8 +38,7 @@ NEWNEWS\r
 LIST ACTIVE ACTIVE.TIMES NEWSGROUPS OVERVIEW.FMT\r
 HDR\r
 OVER\r
-
-my $have_deflate;
+COMPRESS DEFLATE\r
 
 sub greet ($) { $_[0]->write($_[0]->{nntpd}->{greet}) };
 
@@ -903,7 +902,7 @@ sub cmd_starttls ($) {
 sub cmd_compress ($$) {
        my ($self, $alg) = @_;
        return '503 Only DEFLATE is supported' if uc($alg) ne 'DEFLATE';
-       return r502 if $self->compressed || !$have_deflate;
+       return r502 if $self->compressed;
        PublicInbox::NNTPdeflate->enable($self);
        $self->requeue;
        undef
@@ -990,10 +989,4 @@ sub busy {
        ($self->{rbuf} || $self->{wbuf} || $self->not_idle_long($now));
 }
 
-# this is an import to prevent "perl -c" from complaining about fields
-sub import {
-       $have_deflate = eval { require PublicInbox::NNTPdeflate } and
-               $CAPABILITIES .= "COMPRESS DEFLATE\r\n";
-}
-
 1;
index 630ed6861cfc8d6ff21a167dfbd9a14ea95bca5b..e5476d1f50aeedf467feac6c0af56e57ce4baba7 100644 (file)
@@ -8,6 +8,7 @@ use PublicInbox::Qspawn;
 use PublicInbox::WwwStream qw(html_oneshot);
 use PublicInbox::AltId;
 use PublicInbox::Spawn qw(which);
+use PublicInbox::GzipFilter;
 our $sqlite3 = $ENV{SQLITE3};
 
 sub sqlite3_missing ($) {
@@ -64,13 +65,6 @@ or
 EOF
        }
 
-       eval { require PublicInbox::GzipFilter } or
-               return html_oneshot($ctx, 501, \<<EOF);
-<pre>gzip output not available
-
-The administrator needs to install the Compress::Raw::Zlib Perl module
-to support gzipped sqlite3 dumps.</pre>
-EOF
        $sqlite3 //= which('sqlite3');
        if (!defined($sqlite3)) {
                return html_oneshot($ctx, 501, \<<EOF);
index 42a0c0d801a60c652b476b61060a8e9a76043260..38a37ddaae977f129081f4b054f4ac9a1076385b 100644 (file)
@@ -14,14 +14,13 @@ use bytes (); # bytes::length
 use HTTP::Date qw(time2str);
 use Digest::SHA ();
 use File::Spec ();
+use IO::Compress::Gzip qw(gzip);
 *try_cat = \&PublicInbox::Inbox::try_cat;
 our $json;
-if (eval { require IO::Compress::Gzip }) {
-       for my $mod (qw(JSON::MaybeXS JSON JSON::PP)) {
-               eval "require $mod" or next;
-               # ->ascii encodes non-ASCII to "\uXXXX"
-               $json = $mod->new->ascii(1) and last;
-       }
+for my $mod (qw(JSON::MaybeXS JSON JSON::PP)) {
+       eval "require $mod" or next;
+       # ->ascii encodes non-ASCII to "\uXXXX"
+       $json = $mod->new->ascii(1) and last;
 }
 
 sub list_all_i {
@@ -220,7 +219,7 @@ sub js ($$) {
                $repo->{reference} = $abs2urlpath->{$abs};
        }
        my $out;
-       IO::Compress::Gzip::gzip(\($json->encode($manifest)) => \$out);
+       gzip(\($json->encode($manifest)) => \$out);
        $manifest = undef;
        [ 200, [ qw(Content-Type application/gzip),
                 'Last-Modified', time2str($mtime),
index ce42de2d57c254104bf2eaa234bcf3128291ffa5..f42db6fe03e618458ea0d9faefdd42a3dbb6cebf 100755 (executable)
@@ -6,7 +6,7 @@
 use strict;
 use warnings;
 use PublicInbox::Daemon;
-use PublicInbox::NNTP; # need to call import
+use PublicInbox::NNTPdeflate; # loads PublicInbox::NNTP
 use PublicInbox::NNTPD;
 my $nntpd = PublicInbox::NNTPD->new;
 PublicInbox::Daemon::run('0.0.0.0:119',