From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 4FC7F1F44D for ; Wed, 24 Apr 2024 09:39:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1713951576; bh=AsEva28gtIyRH+iLmRKnNEO36xL5ccd9srwlHv8zHB4=; h=Date:From:To:Subject:References:In-Reply-To:From; b=RsncVmd6YjBQH6Sko5ceCJGUgUveEPGiMm9vyHcHGTkBRRtuLesXO9Sa+EBcLlO/u Sdg57tni/sL4f72gKYSDZJHbCzSvT8c1NEE8smgy7T9moZvTkbGGUE4sk2lCswgFv1 z978jZpHUsxXzJdDaDhJtQEgjQorBDjvi079qzkE= Date: Wed, 24 Apr 2024 09:39:36 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 6/5] xap_helper: PERL_INLINE_DIRECTORY fallback for JAOT build Message-ID: <20240424093936.M163768@dcvr> References: <20240424064447.523799-1-e@80x24.org> <20240424064447.523799-6-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240424064447.523799-6-e@80x24.org> List-Id: 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;