From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id F3A602141A for ; Thu, 10 Jan 2019 06:59:58 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/3] check git version requirements Date: Thu, 10 Jan 2019 06:59:57 +0000 Message-Id: <20190110065957.28265-4-e@80x24.org> In-Reply-To: <20190110065957.28265-1-e@80x24.org> References: <20190110065957.28265-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This allows v1 tests to continue working on git 1.8.0 for now. This allows git 2.1.4 packaged with Debian 8 ("jessie") to run old tests, at least. I suppose it's safe to drop Debian 7 ("wheezy") due to our dependency on git 1.8.0 for "merge-base --is-ancestor". Writing V2 repositories requires git 2.6 for "get-mark" support, so mask out tests for older gits. --- INSTALL | 11 +++++++++-- lib/PublicInbox/SearchIdx.pm | 1 + t/altid_v2.t | 2 ++ t/common.perl | 14 ++++++++++++++ t/convert-compact.t | 2 ++ t/import.t | 6 ++++-- t/init.t | 2 ++ t/mda_filter_rubylang.t | 2 ++ t/nntpd.t | 11 ++++++++--- t/psgi_v2.t | 2 ++ t/v1reindex.t | 2 ++ t/v2-add-remove-add.t | 2 ++ t/v2mda.t | 2 ++ t/v2mirror.t | 1 + t/v2reindex.t | 2 ++ t/v2writable.t | 1 + t/watch_maildir_v2.t | 2 ++ 17 files changed, 58 insertions(+), 7 deletions(-) diff --git a/INSTALL b/INSTALL index ccd9dac..a89c890 100644 --- a/INSTALL +++ b/INSTALL @@ -5,6 +5,13 @@ This is for folks who want to setup their own public-inbox instance. Clients should use normal git-clone/git-fetch, or NNTP clients if they want to import mail into their personal inboxes. +public-inbox is developed on Debian GNU/Linux systems and will +never depend on packages outside of the "main" component of +the "stable" distribution, currently Debian 9.x ("stretch") + +Most packages are available in other GNU/Linux distributions; +and FreeBSD support can happen. + TODO: this still needs to be documented better, also see the scripts/ and sa_config/ directories in the source tree @@ -14,8 +21,8 @@ Requirements public-inbox requires a number of other packages to access its full functionality. The core tools are, of course: -* Git -* Perl +* Git (1.8.0+, 2.6+ for writing v2 repositories) +* Perl 5.8+ * SQLite (needed for Xapian use) To accept incoming mail into a public inbox, you'll likely want: diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index fd48169..cc1ac56 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -646,6 +646,7 @@ sub _git_log { --raw -r --no-abbrev/, $range); } +# --is-ancestor requires git 1.8.0+ sub is_ancestor ($$$) { my ($git, $cur, $tip) = @_; return 0 unless $git->check($cur); diff --git a/t/altid_v2.t b/t/altid_v2.t index 87f1452..e91a644 100644 --- a/t/altid_v2.t +++ b/t/altid_v2.t @@ -4,6 +4,8 @@ use strict; use warnings; use Test::More; use File::Temp qw/tempdir/; +require './t/common.perl'; +require_git(2.6); foreach my $mod (qw(DBD::SQLite Search::Xapian)) { eval "require $mod"; plan skip_all => "$mod missing for altid_v2.t" if $@; diff --git a/t/common.perl b/t/common.perl index 688e30a..e49a596 100644 --- a/t/common.perl +++ b/t/common.perl @@ -39,4 +39,18 @@ sub spawn_listener { $pid; } +sub require_git ($;$) { + my ($req, $maybe) = @_; + my ($req_maj, $req_min) = split(/\./, $req); + my ($cur_maj, $cur_min) = (`git --version` =~ /version (\d+)\.(\d+)/); + + my $req_int = ($req_maj << 24) | ($req_min << 16); + my $cur_int = ($cur_maj << 24) | ($cur_min << 16); + if ($cur_int < $req_int) { + return 0 if $maybe; + plan skip_all => "git $req+ required, have $git_ver"; + } + 1; +} + 1; diff --git a/t/convert-compact.t b/t/convert-compact.t index def0343..491486d 100644 --- a/t/convert-compact.t +++ b/t/convert-compact.t @@ -5,6 +5,8 @@ use warnings; use Test::More; use File::Temp qw/tempdir/; use PublicInbox::MIME; +require './t/common.perl'; +require_git(2.6); my @mods = qw(DBD::SQLite Search::Xapian); foreach my $mod (@mods) { eval "require $mod"; diff --git a/t/import.t b/t/import.t index eee4744..e773363 100644 --- a/t/import.t +++ b/t/import.t @@ -11,6 +11,7 @@ use IO::File; use Fcntl qw(:DEFAULT); use File::Temp qw/tempdir tempfile/; my $dir = tempdir('pi-import-XXXXXX', TMPDIR => 1, CLEANUP => 1); +require './t/common.perl'; is(system(qw(git init -q --bare), $dir), 0, 'git init successful'); my $git = PublicInbox::Git->new($dir); @@ -27,11 +28,12 @@ my $mime = PublicInbox::MIME->create( ], body => "hello world\n", ); +my $v2 = require_git(2.6, 1); -$im->{want_object_info} = 1 if 'v2'; +$im->{want_object_info} = 1 if $v2; like($im->add($mime), qr/\A:\d+\z/, 'added one message'); -if ('v2') { +if ($v2) { my $info = $im->{last_object}; like($info->[0], qr/\A[a-f0-9]{40}\z/, 'got last object_id'); is($mime->as_string, ${$info->[2]}, 'string matches'); diff --git a/t/init.t b/t/init.t index 1551a30..86b4eb5 100644 --- a/t/init.t +++ b/t/init.t @@ -5,6 +5,7 @@ use warnings; use Test::More; use PublicInbox::Config; use File::Temp qw/tempdir/; +require './t/common.perl'; my $tmpdir = tempdir('pi-init-XXXXXX', TMPDIR => 1, CLEANUP => 1); use constant pi_init => 'blib/script/public-inbox-init'; use PublicInbox::Import; @@ -53,6 +54,7 @@ SKIP: { eval "require $mod"; skip "$mod missing for v2", 2 if $@; } + require_git(2.6, 1) or skip "git 2.6+ required", 2; local $ENV{PI_DIR} = "$tmpdir/.public-inbox/"; my $cfgfile = "$ENV{PI_DIR}/config"; my @cmd = (pi_init, '-V2', 'v2list', "$tmpdir/v2list", diff --git a/t/mda_filter_rubylang.t b/t/mda_filter_rubylang.t index 583a139..279afaa 100644 --- a/t/mda_filter_rubylang.t +++ b/t/mda_filter_rubylang.t @@ -6,6 +6,8 @@ use Test::More; use File::Temp qw/tempdir/; use PublicInbox::MIME; use PublicInbox::Config; +require './t/common.perl'; +require_git(2.6); my @mods = qw(DBD::SQLite Search::Xapian IPC::Run); foreach my $mod (@mods) { eval "require $mod"; diff --git a/t/nntpd.t b/t/nntpd.t index d227b74..6b13f81 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -18,6 +18,10 @@ use Net::NNTP; use Sys::Hostname; require './t/common.perl'; +# FIXME: make easier to test both versions +my $version = $ENV{PI_VERSION} || 2; +require_git('2.6') if $version == 2; + my $tmpdir = tempdir('pi-nntpd-XXXXXX', TMPDIR => 1, CLEANUP => 1); my $home = "$tmpdir/pi-home"; my $err = "$tmpdir/stderr.log"; @@ -30,10 +34,11 @@ my $init = 'blib/script/public-inbox-init'; use_ok 'PublicInbox::Import'; use_ok 'PublicInbox::Inbox'; use_ok 'PublicInbox::Git'; -use_ok 'PublicInbox::V2Writable'; +SKIP: { + skip "git 2.6+ required for V2Writable", 1 if $version == 1; + use_ok 'PublicInbox::V2Writable'; +} -# XXX FIXME: make it easier to test both versions -my $version = int($ENV{PI_VERSION} || 1); my %opts = ( LocalAddr => '127.0.0.1', ReuseAddr => 1, diff --git a/t/psgi_v2.t b/t/psgi_v2.t index 65448dc..9811249 100644 --- a/t/psgi_v2.t +++ b/t/psgi_v2.t @@ -3,6 +3,8 @@ use strict; use warnings; use Test::More; +require './t/common.perl'; +require_git(2.6); use File::Temp qw/tempdir/; use PublicInbox::MIME; use PublicInbox::Config; diff --git a/t/v1reindex.t b/t/v1reindex.t index 8be9514..33a36fa 100644 --- a/t/v1reindex.t +++ b/t/v1reindex.t @@ -7,6 +7,8 @@ use PublicInbox::MIME; use PublicInbox::ContentId qw(content_digest); use File::Temp qw/tempdir/; use File::Path qw(remove_tree); +require './t/common.perl'; +require_git(2.6); foreach my $mod (qw(DBD::SQLite Search::Xapian)) { eval "require $mod"; diff --git a/t/v2-add-remove-add.t b/t/v2-add-remove-add.t index c8d12d3..1b700d7 100644 --- a/t/v2-add-remove-add.t +++ b/t/v2-add-remove-add.t @@ -5,6 +5,8 @@ use warnings; use Test::More; use PublicInbox::MIME; use File::Temp qw/tempdir/; +require './t/common.perl'; +require_git(2.6); foreach my $mod (qw(DBD::SQLite Search::Xapian)) { eval "require $mod"; diff --git a/t/v2mda.t b/t/v2mda.t index d041ffd..1c90a5b 100644 --- a/t/v2mda.t +++ b/t/v2mda.t @@ -7,6 +7,8 @@ use PublicInbox::MIME; use File::Temp qw/tempdir/; use Fcntl qw(SEEK_SET); use Cwd; +require './t/common.perl'; +require_git(2.6); my $V = 2; foreach my $mod (qw(DBD::SQLite Search::Xapian)) { diff --git a/t/v2mirror.t b/t/v2mirror.t index 283b2b2..ef9a540 100644 --- a/t/v2mirror.t +++ b/t/v2mirror.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; require './t/common.perl'; +require_git(2.6); # Integration tests for HTTP cloning + mirroring foreach my $mod (qw(Plack::Util Plack::Builder Danga::Socket diff --git a/t/v2reindex.t b/t/v2reindex.t index 2dda80e..8a3071b 100644 --- a/t/v2reindex.t +++ b/t/v2reindex.t @@ -7,6 +7,8 @@ use PublicInbox::MIME; use PublicInbox::ContentId qw(content_digest); use File::Temp qw/tempdir/; use File::Path qw(remove_tree); +require './t/common.perl'; +require_git(2.6); foreach my $mod (qw(DBD::SQLite Search::Xapian)) { eval "require $mod"; diff --git a/t/v2writable.t b/t/v2writable.t index c7eeee9..44156fe 100644 --- a/t/v2writable.t +++ b/t/v2writable.t @@ -7,6 +7,7 @@ use PublicInbox::MIME; use PublicInbox::ContentId qw(content_digest); use File::Temp qw/tempdir/; require './t/common.perl'; +require_git(2.6); foreach my $mod (qw(DBD::SQLite Search::Xapian)) { eval "require $mod"; plan skip_all => "$mod missing for nntpd.t" if $@; diff --git a/t/watch_maildir_v2.t b/t/watch_maildir_v2.t index 3b5d2b8..5f96891 100644 --- a/t/watch_maildir_v2.t +++ b/t/watch_maildir_v2.t @@ -5,6 +5,8 @@ use File::Temp qw/tempdir/; use PublicInbox::MIME; use Cwd; use PublicInbox::Config; +require './t/common.perl'; +require_git(2.6); my @mods = qw(Filesys::Notify::Simple PublicInbox::V2Writable); foreach my $mod (@mods) { eval "require $mod"; -- EW