]> Sergey Matveev's repositories - public-inbox.git/commitdiff
cleanup pure Perl use
authorEric Wong <e@80x24.org>
Fri, 23 Dec 2022 22:11:01 +0000 (22:11 +0000)
committerEric Wong <e@80x24.org>
Sat, 24 Dec 2022 06:40:33 +0000 (06:40 +0000)
This quiets down tests when the optional Inline::C is missing.

We do not currently have a hard dependency on Inline::C; and we
should not leave PERL_INLINE_DIRECTORY set in PublicInbox::Spawn
if Inline fails to build.

Leaving PERL_INLINE_DIRECTORY set by Spawn after it fails (due
to missing Inline::C) would cause downstream failures in Gcf2
builds for the same reason.  So we should bail out of the Gcf2
build early if Spawn already failed due to missing Inline::C.

The only time we want to be noisy is if a user explicitly sets
PERL_INLINE_DIRECTORY and Inline::C is missing.

This reverts commit ad8acf7d6484d0a489499742cadadbd4f890ab53.
ad8acf7d6484d0a4 (Gcf2: Create cache folder if missing, 2022-09-08)

lib/PublicInbox/Gcf2.pm
lib/PublicInbox/Spawn.pm

index 54b3d6aa17aa6487f6e42ff98f59627338e5bccd..d13e6b1a2a6cc1a11582a90c1931ab1016a8e281 100644 (file)
@@ -10,16 +10,14 @@ use PublicInbox::Spawn qw(which popen_rd); # may set PERL_INLINE_DIRECTORY
 use Fcntl qw(LOCK_EX SEEK_SET);
 use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
 use IO::Handle; # autoflush
-use File::Path qw(make_path);
 use PublicInbox::Git;
 
 BEGIN {
        my (%CFG, $c_src);
        # PublicInbox::Spawn will set PERL_INLINE_DIRECTORY
-       # to ~/.cache/public-inbox/inline-c if it exists
+       # to ~/.cache/public-inbox/inline-c if it exists and Inline::C works
        my $inline_dir = $ENV{PERL_INLINE_DIRECTORY} //
                die 'PERL_INLINE_DIRECTORY not defined';
-       make_path($inline_dir);
        my $f = "$inline_dir/.public-inbox.lock";
        open my $fh, '+>', $f or die "open($f): $!";
 
index 3f69108a094d3dc1e61aa667927edbdf232ec7f9..7f61d8db54cf6bec9daa1cd83b38eeade23f96b3 100644 (file)
@@ -268,13 +268,14 @@ void recv_cmd4(PerlIO *s, SV *buf, STRLEN n)
 #endif /* defined(CMSG_SPACE) && defined(CMSG_LEN) */
 ALL_LIBC
 
-       my $inline_dir = $ENV{PERL_INLINE_DIRECTORY} //= (
+       my $inline_dir = $ENV{PERL_INLINE_DIRECTORY} // (
                        $ENV{XDG_CACHE_HOME} //
                        ( ($ENV{HOME} // '/nonexistent').'/.cache' )
                ).'/public-inbox/inline-c';
        warn "$inline_dir exists, not writable\n" if -e $inline_dir && !-w _;
        $all_libc = undef unless -d _ && -w _;
        if (defined $all_libc) {
+               local $ENV{PERL_INLINE_DIRECTORY} = $inline_dir;
                my $f = "$inline_dir/.public-inbox.lock";
                open my $oldout, '>&', \*STDOUT or die "dup(1): $!";
                open my $olderr, '>&', \*STDERR or die "dup(2): $!";
@@ -302,7 +303,9 @@ EOM
                        $all_libc = undef;
                }
        }
-       unless ($all_libc) {
+       if (defined $all_libc) { # set for Gcf2
+               $ENV{PERL_INLINE_DIRECTORY} = $inline_dir;
+       } else {
                require PublicInbox::SpawnPP;
                *pi_fork_exec = \&PublicInbox::SpawnPP::pi_fork_exec
        }