wm/extract-and-generate

12 lines
381 B
Plaintext
Raw Normal View History

2021-05-19 22:57:48 +03:00
#!/bin/bash -eu
2021-05-19 22:57:48 +03:00
s=${1:-mj-msc-full.pdf}
d=$(mktemp -d)
2021-05-19 22:57:48 +03:00
f=mj-msc.pdf
l="$d/make.log"
2021-05-19 22:57:48 +03:00
echo "Extracting $s to workdir $d/"; pdfdetach -saveall -o "$d" "$s"
echo "Logs in $l ..."; make -j "$(nproc)" -C "$d" "$f" &> "$l" || {
2021-05-19 22:57:48 +03:00
echo "Failed to generate. $l extract:"; tail -20 "$l"; 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"
2021-05-19 22:57:48 +03:00
echo "$d/$f was closed. Removing $d"; rm -r "$d"