ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Michal Vlasák via ntg-context" <ntg-context@ntg.nl>
To: "amano.kenji" <amano.kenji@proton.me>,
	"mailing list for ConTeXt users" <ntg-context@ntg.nl>
Cc: "Michal Vlasák" <lahcim8@gmail.com>
Subject: Re: How can I make a Gentoo Linux package for ConTeXt LMTX?
Date: Sun, 21 Aug 2022 21:13:45 +0200	[thread overview]
Message-ID: <CMBY2RE03DVN.3A5GUH6S3OD19@phobos> (raw)
In-Reply-To: <LqhRuAnTa26RFKgkdhA43mQJnbqum1-t4mAyyJ2fWmK4FTOaZIJmkbGlW4n6TEv0odqq6oEJU7BQfNhtyGff1EDTxeoxtDjSLqM5chgt26A=@proton.me>

On Mon Aug 15, 2022 at 2:03 PM CEST, amano.kenji via ntg-context wrote:
> TexLive has texmfcnf.lua that doesn't really work with texlive-context installed by linux distributions.
>
> Arch Linux has its own patched version of texmfcnf.lua.
>
> It seems I'd be better off with a linux package for ConTeXt LMTX.
>
> How can I build and install ConTeXt LMTX on Gentoo Linux or any linux distribution?
>
> I wish it was as simple as ./configure, make, and make install.

Some of the problems were mentioned in previous discussions. Like:

 - you would need to maintain your own "snapshots" of the current
   ConTeXt (or make use of the public git mirror)
 - you currently can't build luametatex binary from source, you would
   have to download it prebuilt (and also keep snapshots of it)
 - different directory structure expected by Linux distributions (FHS,
   "file hierarchy standard") vs TeX (TDS, "TeX directory structure")

In addition, there are still many uncertain things, like how you want to
handle fonts:

 - install some with ConTeXt? (In that case you might distribute fonts
   already available in your Linux distribution)
 - use system ones? (Then your documents may be subject to breakages
   from uncoordinated updates - ConTeXt has goodie files tuned to
   particular versions of fonts)

Also, AFAIK, packages are diligent with keeping license information and
documentation, you would have to decide how that information would be
kept (this is mostly the directory structure problem).

With that said, taking Hans' instructions as a start:

On Fri Aug 19, 2022 at 3:11 PM CEST, Hans Hagen via ntg-context wrote:
> Not sure what you mean here but basically a (future) installation is:
>
> - unzip the main zip file
> - goto the source subtree
> - run build.sh (assumes compiler and cmake installed)
> - move the binary file to the relevant bin location
> - set symlinks from luametatex to mtsrun and context
> - copy mtxrun.lua and context.lue there too
> - adapt your path
> - maybe add texmf-fonts and texmf-projects
> - and you're done

You need two things from ConTeXt: texmf directories (there are two
provided by ConTeXt "texmf-context" - what you really need, "texmf" -
mostly fonts) and the luametatex binary.

For simplicity let's only include "texmf-context":

In that case you need to extract "mtxrun" (rename to "luametatex") from
http://lmtx.pragma-ade.nl/install-lmtx/context-linux-64.zip and download
the "texmf-context" texmf tree from
http://lmtx.pragma-ade.nl/install-lmtx/texmf-context.zip.

This is how you get luametatex to execute script like mtxrun or context:

 - luametatex binary gets executed with name (argv[0]) <script>
 - <script>.lua from the same directory gets executed

If you setup paths correctly, you can run all ConTeXt scripts with

    mtxrun --script <script>

E.g.

    mtxrun --script context

Is equivalent to `context`. So having mtxrun is enough.

But you need to tell it how to find the files from texmf. `texmfcnf.lua`
configuration file is used for that. ConTeXt has a few hardcoded
directories where it looks for these files [1], but you can use the
`TEXMFCNF` environment variable to override this (usually variables can
be also looked up from config files, but there is a bit of bootstrapping
problem here - ConTeXt allows setting of TEXMFCNF also in config files,
but then it gets a bit hairy and I didn't investigate that). I may have
got the wrong impression, but I didn't get multiple configuration files
working. In the config file, you can see the settings of some special
variables like TEXINPUTS (this one tells TeX where to look for .tex
files). You should keep them like they are, since they implement
the TDS. They all refer to the TEXMF variable, where I advise changing
things. You can structure TEXMF trees in any way you like and would
probably have to decide what is the best way for Gentoo.

[1]: https://github.com/vlasakm/context/blob/419cacd966ab0adcb9451b60c9fd98790cce77b7/texmf/scripts/context/lua/mtxrun.lua#L22280-L22285

It seems that getting file finding to work is everything you need.
ConTeXt automatically generates the file finding caches, format files,
etc.

I prepared a proof of concept, that I am ready to take down immediately
at Hans' request, since I don't handle license information properly, and
texmf-context is stripped down (just so that the downloads are not too
big for proof of concept).

    https://github.com/vlasakm/context

There is documentation about how it can be used. I hope its obvious how
I got "texmf" (texmf-context.zip, unzip, delete some files I didn't want
to take up space), "luametatex" (copy the binary from installation zip or
download from build farm) and texmcnf.lua (copy of the fallback
contextcnf.lua where I made modifications to leverage TEXMFDOTDIR and
TEXMF even as a user interface).

The rest is the `mtxrun` shell script which is what the user runs. This
is what runs luametatex with the name `mtxrun` (using "exec -a").
Normally you would just symlink mtxrun to luametatex, but I also had
some trouble setting TEXMFCNF otherwise, so I just put both things in
this one script. After this, mtxrun.lua is executed, which is symlinked
by the Makefile - the last thing in the repository.

This is essentially what you wanted, a possibility to `make install`
ConTeXt. I didn't script the downloading and unzipping part. The install
target just copies things to /bin and /share and symlinks mtxrun.lua
from /bin to /share. Standard `PREFIX` and `DESTDIR` variables are used (I
believe they originate from the "GNU coding standards", if you are not
familiar with them).

I pushed a release, so you can download a tarball from a convenient
address:

   https://github.com/vlasakm/context/releases/tag/v20220821

I am not really familiar with ebuild, but I am sure you can get it
working. Though the crucial parts for you mtxrun, and partly
texmfcnf.lua, you still have to do (and mainly decide) things yourself.

I got it working with Debian, RPM and Arch Linux packaging tools /
formats:

    https://build.opensuse.org/package/show/home:lahcim8/context

Essentially the following needs to run somewhere in the build scripts:

    make DESTDIR=... PREFIX=... install

Downloads for a couple of distros are available here:

    https://software.opensuse.org/download.html?project=home%3Alahcim8&package=context

Although from brief testing only Arch Linux works correctly, Debian
can't find system fonts and on Fedora even file finding doesn't work.

A bit of a disclaimer: I don't really recommend pursuing this further.
Some time ago I was also that foolish to try to package TeX for Linux
distributions. Unfortunately I think that the result will never by
optimal - as demonstrated by the previous discussions, the usual
purposes of packages (to integrate software into the system) don't apply
much to TeX / ConTeXt - there one wants something more or less self
contained (so that updates are under control, no random non-essential
libraries brake things, etc.).

Good luck.

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

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

  parent reply	other threads:[~2022-08-21 19:13 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 12:03 amano.kenji via ntg-context
2022-08-15 12:12 ` Bruce Horrocks via ntg-context
2022-08-15 12:19   ` amano.kenji via ntg-context
2022-08-15 17:00     ` Bruce Horrocks via ntg-context
2022-08-16 11:43       ` amano.kenji via ntg-context
2022-08-16 16:02         ` Hans Hagen via ntg-context
2022-08-17 13:09           ` amano.kenji via ntg-context
2022-08-17 15:42             ` Hans Hagen via ntg-context
2022-08-18 12:32               ` amano.kenji via ntg-context
2022-08-18 12:56               ` amano.kenji via ntg-context
2022-08-18 13:16               ` Alan via ntg-context
2022-08-18 13:44                 ` amano.kenji via ntg-context
2022-08-18 13:53                 ` amano.kenji via ntg-context
2022-08-22 22:52                   ` Alan via ntg-context
2022-08-18 14:08                 ` amano.kenji via ntg-context
2022-08-18 17:16                   ` Hans Hagen via ntg-context
2022-08-19 12:51                     ` amano.kenji via ntg-context
2022-08-19 13:06                       ` Hans Hagen via ntg-context
2022-08-19 13:03                     ` amano.kenji via ntg-context
2022-08-19 13:11                       ` Hans Hagen via ntg-context
2022-08-19 13:18                         ` amano.kenji via ntg-context
2022-08-20  7:31                           ` Hans Hagen via ntg-context
2022-08-15 13:54   ` amano.kenji via ntg-context
2022-08-15 18:46     ` Alan Braslau via ntg-context
2022-08-16 11:35       ` amano.kenji via ntg-context
2022-08-21 19:13 ` Michal Vlasák via ntg-context [this message]
2022-08-22  9:41   ` amano.kenji via ntg-context
2022-08-23  1:11     ` Max Chernoff via ntg-context
2022-08-23 10:15       ` amano.kenji via ntg-context
2022-08-23 10:25       ` amano.kenji via ntg-context
2022-08-24 20:21       ` Michal Vlasák via ntg-context
2022-08-24 21:32         ` Hans Hagen via ntg-context
2022-08-25  0:00           ` Michal Vlasák via ntg-context
2022-08-23 19:13     ` Aditya Mahajan via ntg-context
2022-08-24 12:30       ` amano.kenji via ntg-context
2022-08-15 21:56 Max Chernoff via ntg-context
2022-08-16 11:28 ` amano.kenji via ntg-context
2022-08-18  0:51 Max Chernoff via ntg-context
2022-08-18  7:31 ` Hans Hagen via ntg-context
2022-08-18 12:00 ` Henning Hraban Ramm via ntg-context

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=CMBY2RE03DVN.3A5GUH6S3OD19@phobos \
    --to=ntg-context@ntg.nl \
    --cc=amano.kenji@proton.me \
    --cc=lahcim8@gmail.com \
    /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).