unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 6/5] xap_helper: PERL_INLINE_DIRECTORY fallback for JAOT build
Date: Wed, 24 Apr 2024 09:39:36 +0000	[thread overview]
Message-ID: <20240424093936.M163768@dcvr> (raw)
In-Reply-To: <20240424064447.523799-6-e@80x24.org>

systemd setups may use role accounts (e.g. `news') with
XDG_CACHE_HOME unset and a non-existent HOME directory
which the user has no permission to create.

In those cases, fallback to using PERL_INLINE_DIRECTORY if
available for building the just-ahead-of-time C++ binary.
---
 lib/PublicInbox/XapHelperCxx.pm | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/XapHelperCxx.pm b/lib/PublicInbox/XapHelperCxx.pm
index eafe61a8..74852ad1 100644
--- a/lib/PublicInbox/XapHelperCxx.pm
+++ b/lib/PublicInbox/XapHelperCxx.pm
@@ -16,8 +16,15 @@ use autodie;
 my $cxx = which($ENV{CXX} // 'c++') // which('clang') // die 'no C++ compiler';
 my $dir = substr("$cxx-$Config{archname}", 1); # drop leading '/'
 $dir =~ tr!/!-!;
-my $idir = ($ENV{XDG_CACHE_HOME} //
-	(($ENV{HOME} // die('HOME unset')).'/.cache')).'/public-inbox/jaot';
+my $idir;
+if ((defined($ENV{XDG_CACHE_HOME}) && -d $ENV{XDG_CACHE_HOME}) ||
+			(defined($ENV{HOME}) && -d $ENV{HOME})) {
+	$idir = ($ENV{XDG_CACHE_HOME} //
+			(($ENV{HOME} // die('HOME unset')).'/.cache')
+		).'/public-inbox/jaot';
+}
+$idir //= $ENV{PERL_INLINE_DIRECTORY} //
+	die 'HOME and PERL_INLINE_DIRECTORY unset';
 substr($dir, 0, 0) = "$idir/";
 my $bin = "$dir/xap_helper";
 my ($srcpfx) = (__FILE__ =~ m!\A(.+/)[^/]+\z!);
@@ -58,7 +65,11 @@ sub needs_rebuild () {
 sub build () {
 	if (!-d $dir) {
 		require File::Path;
-		File::Path::make_path($dir);
+		eval { File::Path::make_path($dir) };
+		if (!-d $dir && defined($ENV{PERL_INLINE_DIRECTORY})) {
+			$dir = $ENV{PERL_INLINE_DIRECTORY};
+			File::Path::make_path($dir);
+		}
 	}
 	require PublicInbox::CodeSearch;
 	require PublicInbox::Lock;

  reply	other threads:[~2024-04-24  9:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-24  6:44 [PATCH 0/5] www: start using xap_helper process Eric Wong
2024-04-24  6:44 ` [PATCH 1/5] searchview: get rid of unused adump callback arg Eric Wong
2024-04-24  6:44 ` [PATCH 2/5] xap_helper.h: remove _SC_NPROCESSORS_ONLN default Eric Wong
2024-04-24  6:44 ` [PATCH 3/5] xap_helper: drop terms+data from `mset' command Eric Wong
2024-04-24  6:44 ` [PATCH 4/5] mbox: hoist out refill_result_ids Eric Wong
2024-04-24  6:44 ` [PATCH 5/5] www: wire up search to use async xap_helper Eric Wong
2024-04-24  9:39   ` Eric Wong [this message]
2024-04-25  8:11   ` BSD make problem [was: [PATCH 5/5] www: wire up search ...] Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240424093936.M163768@dcvr \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).