forked from apuntes-uam-infomat/apuntes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·68 lines (52 loc) · 1.34 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
cat > /tmp/uptodatecheck.latexmkrc << EOF
\$pdflatex = \$latex = 'internal die_pdflatex %S';
sub die_pdflatex {
# Stop now, otherwise latexmk will update its knowledge of the
# source files and not realize files are out-of-date on the next run.
die "I won't do anything, but just note that '\$_[0]' is out of date\n";
}
EOF
tbold=$(tput bold)
treset=$(tput sgr0)
tred=$(tput setaf 1)
tgreen=$(tput setaf 2)
tyellow=$(tput setaf 3)
packages_dir="Cosas guays LaTeX"
packages_changed=false
failed=""
function packages_install() {
cd "$packages_dir"
sudo ./install
}
function prebuild() {
mkdir -p tikzgen
}
function build() {
latexmk -pdf -silent -shell-escape "$1"
}
function echob() {
echo $tbold$@$treset
}
cd "$(dirname ${BASH_SOURCE[0]})"
IFS=$'\n'
for texfile in $(ls */*.tex); do
cwd=$(pwd)
cd "$(dirname $texfile)"
echob "[ Checking $texfile... ]"
texfile="$(basename $texfile)"
prebuild
if ! latexmk -pdf -r "/tmp/uptodatecheck.latexmkrc" "$texfile" &>/dev/null ; then
echo "$tyellow$texfile out of date. Compiling...$treset"
if ! build "$texfile" ; then
echo "Compilation failed for $texfile."
failed="$failed $texfile"
fi
else
echo "$tgreen$texfile up to date.$treset"
fi
cd "$cwd"
done
[[ -z "$failed" ]] || echo "Compilation failed for $failed "
echo "done"
rm /tmp/uptodatecheck.latexmkrc