blob: 15ca2368a4e6a3ee9e570fb9ecbf0fdd03d0e4d6 (
plain)
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
|
#!/bin/sh
# Create a distributable archive for my lesson material
ARCHIVE="$(basename "$PWD").zip"
zip "${ARCHIVE}" $(find . -mindepth 1 -not -path './.*' -printf '%p ')
# TODO: replace hardcoded base dir
BASEDIR=/home/muhq/Documents/MyDocuments/Work/Schule/Unterricht
add_to_archive() {
python3 <<EOF
import zipfile
with zipfile.ZipFile("${ARCHIVE}", "a") as zf:
zf.write("$1", "$2")
EOF
}
add_custom_latex_to_archive() {
for path in "$@"
do
path_in_arc="$(echo "${path}" | sed -e "s%${BASEDIR}/%%")"
add_to_archive "${path}" "${path_in_arc}"
done
}
# Include license
add_custom_latex_to_archive "${BASEDIR}"/COPYING
# Include common latex code
add_custom_latex_to_archive "${BASEDIR}"/latex/common.tex \
"${BASEDIR}"/latex/common_packages.tex \
"${BASEDIR}"/latex/common_options.tex
# Include common images
add_custom_latex_to_archive "${BASEDIR}"/latex/images/**
# Include the needed latex classes
if grep -Pzrq '(?s)documentclass.+test\}' .; then
add_custom_latex_to_archive "${BASEDIR}"/latex/test.cls
fi
if grep -Pzrq '(?s)documentclass.+arbeitsauftrag\}' .; then
add_custom_latex_to_archive "${BASEDIR}"/latex/arbeitsauftrag.cls
fi
if grep -Pzrq '(?s)documentclass.+handout\}' .; then
add_custom_latex_to_archive "${BASEDIR}"/latex/handout.cls
fi
include_planning=
if grep -Pzrq '(?s)documentclass.+map\}' .; then
add_custom_latex_to_archive "${BASEDIR}"/latex/map.cls
include_planning=true
fi
if grep -Pzrq '(?s)documentclass.+sequence\}' .; then
add_custom_latex_to_archive "${BASEDIR}"/latex/sequence.cls
include_planning=true
fi
if [ -n "${include_planning}" ]; then
add_custom_latex_to_archive "${BASEDIR}"/latex/common_planning*.tex
fi
|