From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/111059 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thangalin Newsgroups: gmane.comp.tex.context Subject: Re: Set luatex cache directory path Date: Sun, 11 Apr 2021 14:13:34 -0700 Message-ID: References: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6422076792028286551==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15527"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Apr 11 23:14:16 2021 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVhPM-0003x8-2v for gctc-ntg-context-518@m.gmane-mx.org; Sun, 11 Apr 2021 23:14:16 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 21D36280C9D; Sun, 11 Apr 2021 23:13:51 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VBz9V_TgY1T9; Sun, 11 Apr 2021 23:13:49 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 608BE282578; Sun, 11 Apr 2021 23:13:49 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 3ED5028256E for ; Sun, 11 Apr 2021 23:13:48 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IbizXZmJXSlc for ; Sun, 11 Apr 2021 23:13:47 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.210.44; helo=mail-ot1-f44.google.com; envelope-from=thangalin@gmail.com; receiver= Original-Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 3E398280C9D for ; Sun, 11 Apr 2021 23:13:47 +0200 (CEST) Original-Received: by mail-ot1-f44.google.com with SMTP id i16-20020a9d68d00000b0290286edfdfe9eso358020oto.3 for ; Sun, 11 Apr 2021 14:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=VXGGnyw+J/X6ahMvLvAtgeCQ42Gre5KRk5kPw+dSPbo=; b=R+gto1EL3f1GU1mz6CxnKay9Z/RAvVW4TC9FiWY0wUsjHExAvkgxGzejS35CHywy5R 4DYFqZkXnDUeCHOltGwg06/Kf7/SBqEchkaRfV2/xsFE4B1pZQvI7Fc4Zr+cTJ6bKTdB wEJzT55bvNPCAsANp1MBbBCQASk2dgy6PPO1HzTlZsArla0O53lwW/GmyEz9jNEajrY0 8k5BeW10wCz4a0KsEdMvv3l6wF7sLRf+yR5mi3aYAp5LIMTcVjE3oWV3/ABG88qrXYA9 FxsAo/V87wlJUrdNt3A82jv0rfhH9bty2SY0ucgqkohTrE5prd4ttaHL8DH6ujivipN+ 8q9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=VXGGnyw+J/X6ahMvLvAtgeCQ42Gre5KRk5kPw+dSPbo=; b=DC0xUAU9c7R3kEZEk92HLmlVFJ0Melx3ckqKoUFiCl7z6YdBwuv2TQuGL3tr414mJ7 IFGGdPYxc/WyUZRVR+wCA+abQ2CaYFJdQQIVdjtVByXA2vsIsh15x/a+UVWvyFyJlW0t T8MJgUtR6uEH8nx5HJfopP5hSRzCnuRIOQfmAro/Re29q0n0SQnhfLruaLDhYh1jyWXb 4oUd64DcJp81GU0f0DZ6A6rmDoyfaTjwsCSJWTR9nwKnfwQFXaMTmMDktCQ0BEu2UQkW ekyILr91FgBfuZIOLsT6Z2k8ngF4eWf1h66uvz4tKoqtvaMtKDzBPAJqSxmAVdwiVei3 pf1w== X-Gm-Message-State: AOAM532JK83vYxWLuvtzsfqDwsOUlmpKkupdr0H+GaTrfMSu4lHZ/3HS a94H8amLlGbH/OhvDI2Zz/4C2cJpAIg8gpzq7pOVLkkyGy6HxA== X-Google-Smtp-Source: ABdhPJzAqfV6RVBq/AH/00qSPA5ewk6zzljN8hVM3EAYoqOWhHm1hEuzgqw2y5BZVXdqpq+zdPn4DbXPIjPAUlAgy0Q= X-Received: by 2002:a9d:ec4:: with SMTP id 62mr21520924otj.277.1618175625259; Sun, 11 Apr 2021 14:13:45 -0700 (PDT) In-Reply-To: X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:111059 Archived-At: --===============6422076792028286551== Content-Type: multipart/alternative; boundary="00000000000053ef6f05bfb8df4d" --00000000000053ef6f05bfb8df4d Content-Type: text/plain; charset="UTF-8" $ sudo su - $ rm -rf /opt/context $ mkdir -p /opt/context $ cd /opt/context $ wget http://lmtx.pragma-ade.nl/install-lmtx/context-linux-64.zip $ unzip *zip $ export TEXMFCACHE=/tmp $ sh install.sh $ exit $ cat test.tex \starttext Test \stoptext $ export TEXMFCACHE=/tmp $ sudo rm -rf /tmp/luatex-cache $ /opt/context/tex/texmf-linux-64/bin/mtxrun --autogenerate --script mtx-context --autopdf test.tex resolvers | resolving | remembered file 'mtx-context.lua' resolvers | resolving | remembered file 'mtx-contexts.lua' resolvers | resolving | remembered file 'mtx-context.lua' resolvers | resolving | remembered file 'mtx-t-mtx-context.lua' resolvers | resolving | remembered file 'mtx-t-mtx-contexts.lua' resolvers | resolving | remembered file 'mtx-t-mtx-context.lua' resolvers | resolving | remembered file 'mtx-context.lua' mtxrun | unknown script 'mtx-context.lua' or 'mtx-mtx-context.lua' If the cache directory isn't deleted, the PDF is generated. However, as soon as the computer reboots, or the temporary directory is otherwise erased, two runs are required. I've addressed this in my code, but it's a little awkward and somewhat brittle because the code cannot know what makes for a valid luatex-cache directory: private boolean reinitialize() { // variable assignments ... exists = check for luatex-cache directory mArgs.clear(); mArgs.add( TYPESETTER.getName() ); if( exists ) { mArgs.add( "--autogenerate" ); mArgs.add( "--script" ); mArgs.add( "mtx-context" ); mArgs.add( ... remaining args ... ); } else { mArgs.add( "--generate" ); } return exists; } private boolean typeset() throws Exception { return reinitialize() ? call() : call() && reinitialize() && call(); } // Invoke ConTeXt to either typeset the document or generate the cache directory public Boolean call() throws Exception { final var builder = new ProcessBuilder( mArgs ); builder.directory( mDirectory.toFile() ); final var cacheDir = getCacheDir(); final var env = builder.environment(); env.put( "TEXMFCACHE", cacheDir.toString() ); builder.redirectOutput( DISCARD ); builder.redirectError( DISCARD ); final var process = builder.start(); process.waitFor(); final var exit = process.exitValue(); process.destroy(); return exit == 0; } Also, unless my application installs ConTeXt, setting the TEXMFCACHE directory before the installation begins will require asking users to do this. Ideally, using the software would take the following steps: 1. Download text editor 2. Download and install ConTeXt (e.g., click link, extract archive, run install.sh) 3. Run text editor 4. Export PDF (editor configures ConTeXt as required, reducing the number of steps for end users) At some point in the future, the editor may prompt the user for permission to install ConTeXt on their behalf---to simplify step 2---but that's much more effort. Stay safe! --00000000000053ef6f05bfb8df4d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
$ sudo su -
$ rm -rf /opt/context
$ mkdir -p /opt/context
$ cd /opt/context
$ = wget http://lmtx.pragma-ade.nl/install-lmtx/context-linux-64= .zip
$ unzip *zip
$ export TEXMFCACHE=3D/tmp
$ sh install.sh
$ exit
$ cat test.tex
\starttext=
Test
\stoptext
$ export TEXMFCACHE=3D/tmp
$ sudo rm -rf= /tmp/luatex-cache
$ /opt/context/tex/texmf-lin= ux-64/bin/mtxrun --autogenerate --script
mtx-context --autopdf test.tex=
resolvers =C2=A0 =C2=A0 =C2=A0 | resolving | remembered file 'mtx-c= ontext.lua'
resolvers =C2=A0 =C2=A0 =C2=A0 | resolving | remembered = file 'mtx-contexts.lua'
resolvers =C2=A0 =C2=A0 =C2=A0 | resolvi= ng | remembered file 'mtx-context.lua'
resolvers =C2=A0 =C2=A0 = =C2=A0 | resolving | remembered file 'mtx-t-mtx-context.lua'
res= olvers =C2=A0 =C2=A0 =C2=A0 | resolving | remembered file 'mtx-t-mtx-co= ntexts.lua'
resolvers =C2=A0 =C2=A0 =C2=A0 | resolving | remembered = file 'mtx-t-mtx-context.lua'
resolvers =C2=A0 =C2=A0 =C2=A0 | re= solving | remembered file 'mtx-context.lua'
mtxrun =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0| unknown script 'mtx-context.lua' or 'mtx= -mtx-context.lua'

If the cache directory isn't deleted, the PDF is generated. However, as= =20 soon as the computer reboots, or the temporary directory is otherwise=20 erased, two runs are required.

I've addressed this in my code, but it's a little awkward and somewhat=20 brittle because the code cannot know what makes for a valid luatex-cache directory:

=C2=A0 =C2=A0 private boolean reinitialize() {
=C2=A0 =C2=A0 =C2=A0 // variable assignments ... exists =3D check= for luatex-cache directory

=C2=A0 =C2=A0 =C2=A0 mArgs.clear();
=C2=A0 =C2=A0 = =C2=A0 mArgs.add( TYPESETTER.getName() );

=C2=A0 =C2=A0 =C2=A0 if( e= xists ) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 mArgs.add( "--autogenerate&qu= ot; );
=C2=A0 =C2=A0 =C2=A0 =C2=A0 mArgs.add( "--script" );=C2=A0 =C2=A0 =C2=A0 =C2=A0 mArgs.add( "mtx-context" );
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 mArgs.add( ... remaining args ... );
=C2=A0 =C2= =A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 else {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = mArgs.add( "--generate" );
=C2=A0 =C2=A0 =C2=A0 }

=C2= =A0 =C2=A0 =C2=A0 return exists;
=C2=A0 =C2=A0 }

=C2=A0 =C2=A0 pr= ivate boolean typeset() throws Exception {
=C2=A0 =C2=A0 =C2=A0 return r= einitialize() ? call() : call() && reinitialize() && call()= ;
=C2=A0 =C2=A0 }

=C2=A0=C2=A0=C2=A0 // Invoke ConTeXt to either typeset the= document or generate the cache directory
=C2=A0 =C2=A0 public Boolean call() throws Exception {
=C2=A0 =C2=A0 = =C2=A0 final var builder =3D new ProcessBuilder( mArgs );
=C2=A0 =C2=A0 = =C2=A0 builder.directory( mDirectory.toFile() );

=C2=A0 =C2=A0 =C2= =A0 final var cacheDir =3D getCacheDir();
=C2=A0 =C2=A0 =C2=A0 final var= env =3D builder.environment();
=C2=A0 =C2=A0 =C2=A0 env.put( "TEXM= FCACHE", cacheDir.toString() );

=C2=A0 =C2=A0 =C2=A0 builder.re= directOutput( DISCARD );
=C2=A0 =C2=A0 =C2=A0 builder.redirectError( DIS= CARD );

=C2=A0 =C2=A0 =C2=A0 final var process =3D builder.start();<= br>=C2=A0 =C2=A0 =C2=A0 process.waitFor();
=C2=A0 =C2=A0 =C2=A0 final va= r exit =3D process.exitValue();
=C2=A0 =C2=A0 =C2=A0 process.destroy();<= br>=C2=A0 =C2=A0 =C2=A0 return exit =3D=3D 0;
=C2=A0 =C2=A0 }

Also, unless my application installs ConTeXt, setting the TEXMFCACHE=20 directory before the installation begins will require asking users to do this. Ideally, using the software would take the following steps:

1. Download te= xt editor
2. Download and install ConTeXt (= e.g., click link, extract archive, run install.sh)
3. Run text editor
4. Expor= t PDF (editor configures ConTeXt as required, reducing the number of steps = for end users)

At some point in the future, the editor may prompt the user for permission to install ConTeXt on their behalf---to simplify step 2---but that's= =20 much more effort.

Stay safe!
--00000000000053ef6f05bfb8df4d-- --===============6422076792028286551== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============6422076792028286551==--