45 lines
1.1 KiB
Bash
45 lines
1.1 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
# This script is a complete replacement for latexmk,
|
||
|
# using this docker container.
|
||
|
|
||
|
|
||
|
# All arguments are passed to latexmk,
|
||
|
# so options are provided via envvars.
|
||
|
|
||
|
# These options should never be changed,
|
||
|
# use LATEX_OUT_DIR.
|
||
|
if [[ $@ == *"-outdir"* ]] || [[ $@ == *"-output-directory"* ]] ; then
|
||
|
echo "Do not set output dir while using this script." 1>&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# What directory we should bind to /work.
|
||
|
if [[ -z "$LATEXMK_WORK_DIR" ]] ; then
|
||
|
LATEXMK_WORK_DIR="/"
|
||
|
fi
|
||
|
|
||
|
# CD to this path inside LATEXMK_WORK_DIR.
|
||
|
# Must be relative.
|
||
|
if [[ -z "$LATEXMK_CD_DIR" ]] ; then
|
||
|
LATEXMK_CD_DIR="$(realpath --relative-to="$LATEXMK_WORK_DIR" "$(pwd)")"
|
||
|
fi
|
||
|
|
||
|
# Default path for output
|
||
|
if [[ -z "$LATEX_OUT_DIR" ]] ; then
|
||
|
LATEX_OUT_DIR="./build"
|
||
|
fi
|
||
|
|
||
|
# Docker wants relative paths
|
||
|
# mkdir here so we don't have permission problems
|
||
|
LATEX_OUT_DIR=$(realpath "$LATEX_OUT_DIR")
|
||
|
mkdir -p "$LATEX_OUT_DIR"
|
||
|
|
||
|
docker run --rm \
|
||
|
--user $(id -u):$(id -g) \
|
||
|
-v "$LATEXMK_WORK_DIR:/work:ro" \
|
||
|
-v "$LATEX_OUT_DIR:/build" \
|
||
|
-e "LATEXMK_CD_DIR=$LATEXMK_CD_DIR" \
|
||
|
git.betalupi.com/mark/latex \
|
||
|
bash /run.sh $@
|