2021-03-31 15:12:42 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
dir=$(mktemp -d)
|
2021-04-02 06:31:47 +03:00
|
|
|
src=${1:-mj-msc-full.pdf}
|
2021-04-06 09:40:43 +03:00
|
|
|
|
|
|
|
readonly dst=mj-msc.pdf
|
|
|
|
readonly log="$dir/make.log"
|
2021-04-01 20:44:22 +03:00
|
|
|
echo "Extracting $src to $dir/" && pdfdetach -saveall -o "$dir" "$src"
|
2021-04-02 06:31:47 +03:00
|
|
|
chmod a+x "$dir/db"
|
2021-04-06 09:40:43 +03:00
|
|
|
echo "Generating $dir/$dst, logs in $log ..."
|
|
|
|
make -j "$(nproc)" -C "$dir" "$dst" &> "$log" || {
|
|
|
|
echo "Failed to generate. $log extract:" && tail -20 "$dir/make.log"
|
2021-03-31 15:12:42 +03:00
|
|
|
exit 1
|
2021-04-01 16:13:29 +03:00
|
|
|
}
|
2021-04-01 20:44:22 +03:00
|
|
|
echo "Opening $dir/$dst ..." && xdg-open "$dir/$dst"
|
2021-04-06 09:40:43 +03:00
|
|
|
echo "$dir/$dst was closed. Removing $dir" && rm -fr "$dir"
|