Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add override for TeXlive repo #19

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ ENV OUT_DIR="${out_dir}"
# Instead of VOLUME, which breaks multi-stage builds:
RUN mkdir -p "${src_dir}" "${tmp_dir}" "${out_dir}"

ENV TEXLIVE_REPOSITORY=""
COPY entrypoint.sh /bin/entrypoint
# Add "aliases" to align `docker run` and `docker exec` usage.
RUN set -eo noclobber; \
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,33 @@ Place a file called `Texlivefile` with a list of required CTAN packages,
one name per line, in the source directory.
The container will install all packages on that list before running the work command.

---
⚠️ Images will stop working once a new version of TeXlive is released with an error like this:

> tlmgr: Local TeX Live (2023) is older than remote repository (2024).

If you need to keep using an older image for a little while,
you can override the repository by setting environment variable
`TEXLIVE_REPOSITORY` to a value like
```
https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2023/tlnet-final
```
This feature has been available since 2024.1;
see
[reitzig/texlive-docker#18.2022953222](https://github.com/reitzig/texlive-docker/issues/18#issuecomment-2022953222)
for hints on how to backport it to older images.

⚠️ Note that most CTAN mirrors do not maintain historic versions
(cf. [tex.SE#460132](https://tex.stackexchange.com/questions/460132/historic-tex-live-distributions-https-sftp-mirror)),
so keep in mind that widespread use of this workaround _will_ stress those few mirrors that do.
We strongly recommend upgrading to the latest TeXlive version as soon as possible!

<!-- TODO: provide example-->
<!-- ℹ️ That said, an alternative is to maintain custom Docker images with historic package versions;
see [here](TODO) for an example. -->

---

### Parameters

You can adjust some defaults of the
Expand Down
41 changes: 25 additions & 16 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ Commands:

Environment Variables:

OUT_DIR Directory for the relevant output of work commands.
Default: /work/out
SRC_DIR Directory with project sources. Can be read-only.
Default: /work/src
TMP_DIR The working directory for work commands.
Default: /work/tmp
BUILDSCRIPT Script in SRC_DIR that can be run by the work command.
Default: build.sh
TEXLIVEFILE A file in SRC_DIR that contains the TeXlive packages the
project requires, one package name per line.
Default: Texlivefile
OUTPUT Bash glob pattern that defines the relevant output of
work commands.
Default: '*.pdf *.log'
OUT_DIR Directory for the relevant output of work commands.
Default: /work/out
SRC_DIR Directory with project sources. Can be read-only.
Default: /work/src
TMP_DIR The working directory for work commands.
Default: /work/tmp
BUILDSCRIPT Script in SRC_DIR that can be run by the work command.
Default: build.sh
TEXLIVE_REPOSITORY Direct URL to a TeXlive repository;
bypasses use of mirrors.ctan.org and gives access to history versions.
Default: empty (default behaviour of tlmgr)
TEXLIVEFILE A file in SRC_DIR that contains the TeXlive packages the
project requires, one package name per line.
Default: Texlivefile
OUTPUT Bash glob pattern that defines the relevant output of
work commands.
Default: '*.pdf *.log'
HELP
)"

Expand Down Expand Up @@ -94,9 +97,15 @@ case "${command}" in

if [[ -f "${SRC_DIR}/${TEXLIVEFILE}" ]]; then
if ! sha256sum -c "${hashfile}" > /dev/null 2>&1; then
tlrepo=""
if [ -n "${TEXLIVE_REPOSITORY}" ]; then
echo "Will use TeXlive repository ${TEXLIVE_REPOSITORY}"
tlrepo="--repository ${TEXLIVE_REPOSITORY}"
fi

echo "Installing dependencies ..."
tlmgr update --self
xargs tlmgr install < "${SRC_DIR}/${TEXLIVEFILE}"
tlmgr update ${tlrepo} --self
xargs tlmgr install ${tlrepo} < "${SRC_DIR}/${TEXLIVEFILE}"
tlmgr path add
sha256sum "${SRC_DIR}/${TEXLIVEFILE}" > "${hashfile}"
else
Expand Down