wm/extract-and-generate

15 lines
420 B
Plaintext
Raw Normal View History

2021-05-19 22:57:46 +03:00
#!/bin/bash
set -euo pipefail
2021-05-19 22:57:48 +03:00
s=${1:-mj-msc-full.pdf}
d=$(mktemp -d)
2021-05-19 22:57:47 +03:00
2021-05-19 22:57:48 +03:00
readonly f=mj-msc.pdf
readonly l="$d/make.log"
echo "Extracting $s to workdir $d/"; pdfdetach -saveall -o "$d" "$s"
echo "Logs in $l ..."; make -j "$(nproc)" -C "$d" "$f" &> "$l" || {
echo "Failed to generate. $l extract:" && tail -20 "$l"
2021-05-19 22:57:46 +03:00
exit 1
2021-05-19 22:57:46 +03:00
}
2021-05-19 22:57:48 +03:00
echo "Opening $d/$f ..."; xdg-open "$d/$f"
echo "$d/$f was closed. Removing $d"; rm -fr "$d"