#!/usr/bin/env bash # usage: build_all.sh -> rebuild all 24 note PDFs (names "NNNN - Title.pdf" in ../) # build_all.sh 0107 0203 -> rebuild only those set -o pipefail source /apps/paper-tools/env.sh >/dev/null 2>&1 cd "$(dirname "$0")" mkdir -p build/all sel=("$@"); fail=0; n=0 for tex in 0[123][0-9][0-9]-*.tex; do id=${tex%%-*} if [ ${#sel[@]} -gt 0 ] && [[ ! " ${sel[*]} " == *" $id "* ]]; then continue; fi slug=${tex%.tex} existing=$(ls ../"$id"\ -\ *.pdf 2>/dev/null | head -1) if [ -z "$existing" ]; then echo "SKIP $id: no existing ../$id - Title.pdf to take the name from"; continue; fi if TEXINPUTS=".:${TEXINPUTS:-}" latexmk -pdf -interaction=nonstopmode -halt-on-error -outdir=build/all "$tex" >build/all/$slug.console.log 2>&1; then cp "build/all/$slug.pdf" "$existing"; n=$((n+1)); echo "built $existing" else echo "FAIL $id (see build/all/$slug.console.log)"; tail -15 build/all/$slug.console.log; fail=$((fail+1)); fi done echo "built=$n failed=$fail"; [ $fail -eq 0 ]