-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·95 lines (71 loc) · 1.6 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/bash
set -o errexit
set -o nounset
set -o pipefail
error()
{
local MESSAGE="${1}"
local STATUS="${2}"
echo "${MESSAGE}" >> "/dev/stderr"
exit "${STATUS}"
}
setup()
{
local BUILDDIR="${1}"
local BUILDTYPE="${2}"
local ARCHIVE="${3}"
unzip -o -qq -d "${BUILDDIR}" "${ARCHIVE}"
cp -t "${BUILDDIR}" "kody.tex" "makra-kody.tex"
local PROBLEM_FILES
case "${BUILDTYPE}" in
"MAMUT")
PROBLEM_FILES=(lahke.tex stredne.tex tazke.tex)
;;
"LOMIHLAV")
PROBLEM_FILES=(ulohy.tex hadanky.tex hlavolamy.tex)
;;
*)
error "Unknown build type: ${BUILDTYPE}" 1
;;
esac
utils/partition.py \
-o "${BUILDDIR}/zadania" \
"${PROBLEM_FILES[@]/#/${BUILDDIR}/}"
}
build()
{
local BUILDDIR="$1"
pushd "${BUILDDIR}"
latex "kody.tex"
# shellcheck source=/dev/null
source kody+mp.sh
latex "kody.tex"
dvips -q "kody.dvi"
ps2pdf "kody.ps"
popd
}
main()
{
if [[ "${#}" -lt 2 ]]; then
error "Usage: ${0} <MAMUT|LOMIHLAV> ARCHIVE [SILENT]" 1
fi
local BUILDTYPE="${1}"
local ARCHIVE="${2}"
local SILENT
if [[ "${#}" -eq 3 ]] && [[ "${3}" == "SILENT" ]]; then
SILENT=true
else
SILENT=false
fi
local BUILDDIR
BUILDDIR="$( mktemp -d )"
setup "${BUILDDIR}" "${BUILDTYPE}" "${ARCHIVE}"
if "${SILENT}"; then
build "${BUILDDIR}" > "/dev/null"
else
build "${BUILDDIR}"
fi
cp -t "." "${BUILDDIR}/kody.pdf"
rm -r -f "${BUILDDIR}"
}
main "${@}"