-
Notifications
You must be signed in to change notification settings - Fork 0
/
ubuntu_local_build.sh
executable file
·72 lines (59 loc) · 1.23 KB
/
ubuntu_local_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
69
70
71
72
#!/bin/bash
set -euo pipefail
script_lock=$(dirname "${0}")/"build_lock_dir"
readonly script_lock
declare -r core_name="academic_activities_eng"
declare -r tex_file="${core_name}.tex"
declare -r pdf_file="${core_name}.pdf"
function is_already_running()
{
declare -i return_value=0
test -d "${script_lock}" ||
{
return_value=1
}
return "${return_value}"
}
function create_lock()
{
mkdir "${script_lock}" ||
{
printf "Cannot create lock\n"
exit 2
}
}
function remove_lock()
{
rm -rf "${script_lock}" ||
{
printf "Cannot remove lock\n"
exit 3
}
}
if is_already_running
then
printf "Cannot acquire lock (another instance is running?) - exiting.\n"
exit 1
fi
create_lock
rm -f ${pdf_file} ||
{
remove_lock
printf "Cannot remove the old result file\n"
exit 4
}
pdflatex -interaction=batchmode -draftmode $tex_file || true
pdflatex -interaction=batchmode -draftmode $tex_file || true
pdflatex -interaction=batchmode $tex_file ||
{
remove_lock
printf "Error while building document (LaTeX error)\n"
exit 5
}
if ! [ -e ${pdf_file} ]
then
remove_lock
printf "Error while building document (document not created)\n"
exit 6
fi
remove_lock