ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Thangalin <thangalin@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Set luatex cache directory path
Date: Sun, 11 Apr 2021 14:13:34 -0700	[thread overview]
Message-ID: <CAANrE7pmC7udCEeWGVhNWh-M9EcK1S+cRwFaWgO9kgA3wzXLPg@mail.gmail.com> (raw)
In-Reply-To: <bd6c7221-c2ae-98ec-ada3-bc543f315417@xs4all.nl>


[-- Attachment #1.1: Type: text/plain, Size: 3085 bytes --]

$ 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!

[-- Attachment #1.2: Type: text/html, Size: 4477 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2021-04-11 21:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-05 22:19 Thangalin
2021-04-06  7:31 ` Aditya Mahajan
2021-04-06 18:59   ` Thangalin
2021-04-06 19:24     ` Aditya Mahajan
2021-04-06 21:06       ` Thangalin
2021-04-10 23:30       ` Thangalin
2021-04-11  9:16         ` Hans Hagen
2021-04-11 21:13           ` Thangalin [this message]
2021-04-06 21:38     ` Hans Hagen

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

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

  git send-email \
    --in-reply-to=CAANrE7pmC7udCEeWGVhNWh-M9EcK1S+cRwFaWgO9kgA3wzXLPg@mail.gmail.com \
    --to=thangalin@gmail.com \
    --cc=ntg-context@ntg.nl \
    /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 NNTP newsgroup(s).