user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 6/5] xap_helper: PERL_INLINE_DIRECTORY fallback for JAOT build
  @ 2024-04-24  9:39  7%   ` Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2024-04-24  9:39 UTC (permalink / raw)
  To: meta

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;

^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2024-04-24  6:44     [PATCH 0/5] www: start using xap_helper process 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  7%   ` [PATCH 6/5] xap_helper: PERL_INLINE_DIRECTORY fallback for JAOT build 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).