blob: 2fd98ea3c575730772fe39d5a90fcb6edfb46699 (
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
64
65
66
67
|
#!/bin/bash
# Create a distributable archive for my lesson material
archive="$(basename "$PWD").zip"
readarray -t files < <(find -L . -mindepth 1 -not -path './.*' -printf '%p\n')
zip "${archive}" "${files[@]}"
# 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
# trim the basedir from the file path
path_in_arc="${path//"$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
# TODO: only include used images
readarray -t images < <(find "${basedir}"/latex/images -printf '%p\n')
add_custom_latex_to_archive "${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
|