Skip to content

Commit

Permalink
perf!: change the default texmf user directories
Browse files Browse the repository at this point in the history
  • Loading branch information
teatimeguest committed Oct 18, 2023
1 parent 472a6dd commit 570b787
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 278 deletions.
47 changes: 34 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ Linux, Windows, and macOS are supported.

- Cache keys.

- Change the default texmf user directories.

As with the [portable installation][portable] of the official installer,
`TEXMFHOME`, `TEXMFCONFIG`, and `TEXMFVAR` are now set by default to be
the same as `TEXMFLOCAL`, `TEXMFSYSCONFIG`, and `TEXMFSYSVAR`, respectively.
To emulate the previous behavior,
use environment variables to explicitly specify the user directories:

```yaml
- name: Setup TeX Live
uses: teatimeguest/setup-texlive-action@v3
env:
TEXLIVE_INSTALL_TEXMFHOME: >-
~/texmf
TEXLIVE_INSTALL_TEXMFCONFIG: >-
~/.local/texlive/<version>/texmf-config
TEXLIVE_INSTALL_TEXMFVAR: >-
~/.local/texlive/<version>/texmf-var
```

## Table of Contents

- [Usage](#usage)
Expand Down Expand Up @@ -146,16 +166,16 @@ because its hash will be used as part of the cache key.

All inputs are optional.

| Name | Type | Description |
| --------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cache` | Bool | <p>Enable caching for [`TEXDIR`][texdir].</p> **Default:**&ensp;`true` |
| `package-file` | String | File containing the names of TeX packages to be installed, delimited by whitespaces. Everything after a `#` is treated as a comment. The [`DEPENDS.txt`][depends-txt] format is also supported. |
| `packages` | String | Whitespace-delimited TeX package names to be installed. Schemes and collections are also acceptable. |
| `prefix` | String | <p>TeX Live installation prefix. This has the same effect as [`TEXLIVE_INSTALL_PREFIX`][install-tl-env].</p> **Default:**&ensp;<code>&#x200B;[$RUNNER_TEMP][actions-env]/setup-texlive-action</code> |
| `texdir` | String | TeX Live system directory. This has the same effect as the installer's [`-texdir`][install-tl-texdir] option and takes precedence over the `prefix` input and related environment variables. |
| `tlcontrib` | Bool | <p>Set up [TLContrib][tlcontrib] as an additional TeX package repository. This input will be ignored for older versions.</p> **Default:**&ensp;`false` |
| `update-all-packages` | Bool | <p>Update all TeX packages when cache restored. Defaults to `false`, and the action will update only `tlmgr`.</p> **Default:**&ensp;`false` |
| `version` | String | <p>TeX Live version to install. Supported values are `2008` to `2023`, and `latest`.</p> **Default:**&ensp;`latest` |
| Name | Type | Description |
| --------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cache` | Bool | <p>Enable caching for [`TEXDIR`][texdir].</p> **Default:**&ensp;`true` |
| `package-file` | String | File containing the names of TeX packages to be installed, delimited by whitespaces. Everything after a `#` is treated as a comment. The [`DEPENDS.txt`][depends-txt] format is also supported. |
| `packages` | String | Whitespace-delimited TeX package names to be installed. Schemes and collections are also acceptable. |
| `prefix` | String | <p>TeX Live installation prefix. This has the same effect as [`TEXLIVE_INSTALL_PREFIX`][install-tl-env].</p> **Default:**&ensp;<code>&#x200B;[$RUNNER_TEMP][actions-env]/setup-texlive-action</code> |
| `texdir` | String | TeX Live system installation directory. This has the same effect as the installer's [`-texdir`][install-tl-texdir] option and takes precedence over the `prefix` input and related environment variables. |
| `tlcontrib` | Bool | <p>Set up [TLContrib][tlcontrib] as an additional TeX package repository. This input will be ignored for older versions.</p> **Default:**&ensp;`false` |
| `update-all-packages` | Bool | <p>Update all TeX packages when cache restored. Defaults to `false`, and the action will update only `tlmgr`.</p> **Default:**&ensp;`false` |
| `version` | String | <p>TeX Live version to install. Supported values are `2008` to `2023`, and `latest`.</p> **Default:**&ensp;`latest` |

## Outputs

Expand Down Expand Up @@ -210,9 +230,9 @@ the following [official environment variables][install-tl-env] are supported:
| `TEXLIVE_INSTALL_PAPER` | |
| `TEXLIVE_INSTALL_PREFIX` | <code>&#x200B;[$RUNNER_TEMP][actions-env]/setup-texlive-action</code> |
| `TEXLIVE_INSTALL_TEXMFLOCAL` | |
| `TEXLIVE_INSTALL_TEXMFHOME` | `~/texmf` |
| `TEXLIVE_INSTALL_TEXMFCONFIG` | `~/.local/texlive/<version>/texmf-config` |
| `TEXLIVE_INSTALL_TEXMFVAR` | `~/.local/texlive/<version>/texmf-var` |
| `TEXLIVE_INSTALL_TEXMFHOME` | Same as `TEXMFLOCAL` |
| `TEXLIVE_INSTALL_TEXMFCONFIG` | Same as `TEXMFSYSCONFIG` |
| `TEXLIVE_INSTALL_TEXMFVAR` | Same as `TEXMFSYSVAR` |
| `NOPERLDOC` | |

If `prefix` and `TEXLIVE_INSTALL_PREFIX` are both set, `prefix` will be used.
Expand Down Expand Up @@ -248,6 +268,7 @@ See the [releases page][releases].
[marketplace-badge]: https://img.shields.io/github/v/release/teatimeguest/setup-texlive-action?label=Marketplace&logo=github
[marketplace]: https://github.com/marketplace/actions/setup-texlive-action
[node16-eol]: https://nodejs.org/en/blog/announcements/nodejs16-eol
[portable]: https://tug.org/texlive/doc/texlive-en/texlive-en.html#tlportable
[releases]: https://github.com/teatimeguest/setup-texlive-action/releases
[texdir]: https://tug.org/texlive/doc/texlive-en/texlive-en.html#x1-250003.2.3
[texlive]: https://tug.org/texlive/
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ inputs:
required: false
texdir:
description: >-
TeX Live system directory.
TeX Live system installation directory.
This has the same effect as the installer's `-texdir` option and
takes precedence
over the `prefix` input and related environment variables.
Expand Down
1 change: 0 additions & 1 deletion src/action/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export namespace Config {
version: await resolveVersion({ version }),
packages: await collectPackages({ packageFile, packages }),
};
env.setDefaultTexmfUserTrees(config.version);

if (!isLatest(config.version)) {
if (config.tlcontrib) {
Expand Down
15 changes: 1 addition & 14 deletions src/action/env.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { homedir, tmpdir } from 'node:os';
import path from 'node:path';
import { tmpdir } from 'node:os';
import { env } from 'node:process';

import * as log from '#/log';
import { Texmf } from '#/tex/texmf';
import type { Env } from '#/texlive/install-tl/env';
import { UserTrees } from '#/texlive/install-tl/texmf';
import type { Version } from '#/texlive/version';

export function init(): void {
if (!('RUNNER_TEMP' in env)) {
Expand All @@ -27,13 +24,3 @@ export function init(): void {
}
}
}

export function setDefaultTexmfUserTrees(version: Version): void {
const TEXUSERDIR = path.join(homedir(), '.local', 'texlive', version);
env.TEXLIVE_INSTALL_TEXMFHOME ??= path.join(homedir(), 'texmf');
const trees = new UserTrees(version, { texdir: TEXUSERDIR });

for (const key of Texmf.USER_TREES) {
env[`TEXLIVE_INSTALL_${key}` satisfies keyof Env] ??= trees[key];
}
}
Loading

0 comments on commit 570b787

Please sign in to comment.