songs/bin/build.sh

49 lines
919 B
Bash
Raw Permalink Normal View History

2020-07-08 03:45:43 +00:00
#!/bin/zsh
2019-09-09 02:43:57 +00:00
2022-04-15 04:38:39 +00:00
set -x
2020-07-14 17:06:42 +00:00
export max_print_line=1000
export error_line=254
export half_error_line=238
2019-09-15 05:16:45 +00:00
TEXML_HOME=$HOME/Library/texmf/tex/latex
2020-07-08 03:45:43 +00:00
SONGS_HOME=`pwd`
2019-09-15 05:16:45 +00:00
function setup_pdflatex {
if [ ! -d $TEXML_HOME ]; then
mkdir -p $TEXML_HOME
fi
if [ ! -d $TEXML_HOME/tex ]; then
2020-07-08 03:45:43 +00:00
ln -s $SONGS_HOME/tex $TEXML_HOME
2019-09-15 05:16:45 +00:00
fi
}
function make_pdf {
2020-07-08 03:45:43 +00:00
infile="$SONGS_HOME/$1"
2019-09-15 05:16:45 +00:00
indir=$(dirname "$1")
2020-07-08 03:45:43 +00:00
pdf_outdir="$SONGS_HOME/build/pdf/${indir#songs/}"
2019-09-15 05:16:45 +00:00
mkdir -p "$pdf_outdir"
2020-09-02 04:31:34 +00:00
TEXINPUTS=$indir: pdflatex \
2019-09-15 05:16:45 +00:00
-output-directory="$pdf_outdir" \
"$infile"
}
function make_packet {
pdfs=""
while read p; do
make_pdf "songs/$p.tex"
2019-10-06 04:43:47 +00:00
done < <(grep includepdf $1 | grep build/pdf | sed -E 's/.*{build\/pdf\/([^}]*)\.pdf}.*/\1/')
2019-09-15 05:16:45 +00:00
mkdir -p "build/packets"
pdflatex \
2019-09-17 05:12:54 +00:00
-output-directory="build/packets" \
"$1"
2019-09-15 05:16:45 +00:00
}
setup_pdflatex
2021-11-12 07:44:02 +00:00
make_packet "$1"