-
Notifications
You must be signed in to change notification settings - Fork 5
/
build
executable file
·119 lines (94 loc) · 3.13 KB
/
build
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
set -x
function buildSlides(){
cat ../template/default.properties > slides-1.md
# move readme content
cp README.md slides.md.2
sed -i "1s/.*/$var/" slides.md.2
cat slides.md.2 >> slides-1.md
# move exercise content
#for file in $EXERCISE_FILES ; do
# cat $file >> slides-1.md
# echo "" >> slides-1.md
#done
# move solution content (if exists)
#if [ -f solution.md ]; then
# cp solution.md slides.md.3
# sed -i "1,4s/.*/$var/" slides.md.3
# cat slides.md.3 >> slides-1.md
#fi
pandoc slides-1.md -t beamer -o slides.pdf --template ../template/beamer.latex
rm -f slides-1.md slides.md.2 slides.md.3
}
function buildSolution(){
cat ../template/default.properties > solution-1.md
cp solution.md solution-2.md
sed -i "1s/.*/$var/" solution-2.md
cat solution-2.md >> solution-1.md
pandoc --pdf-engine=xelatex solution-1.md -t latex -o solution.pdf --template ../template/eisvogel.latex
rm solution-1.md solution-2.md
}
function buildExercise(){
cat README.md > exercise.md
echo "\newpage" >> exercise.md
echo "" >> exercise.md
sed -i "1s/.*/$var/" exercise.md
mv exercise.md exercise.md.1
cat ../template/default.properties >> exercise.md
cat exercise.md.1 >> exercise.md
rm exercise.md.1
for file in $EXERCISE_FILES ; do
cat $file >> exercise.md
echo "\newpage" >> exercise.md
echo "" >> exercise.md
done
pandoc --pdf-engine=xelatex exercise.md -t latex -o exercise.pdf --template ../template/eisvogel.latex
rm exercise.md
}
function buildAll(){
exportArtifacts=$1; shift
if [[ $exportArtifacts == "export" ]]; then
mkdir -p artifacts
fi
export artefactList=""
# build overview
buildSlides
# build each exercise
for ex in $(ls | grep ex-); do
echo "build exercise $ex ..."
p=$(pwd) ; cd $ex
source ./build
if [[ $exportArtifacts == "export" ]]; then
mkdir -p ../artifacts/$ex
if [ -f slides.pdf ]; then
cp slides.pdf ../artifacts/$ex/
export artefactList="$artefactList artifacts/$ex/slides.pdf"
fi
if [ -f exercise.pdf ]; then
cp exercise.pdf ../artifacts/$ex/
export artefactList="$artefactList artifacts/$ex/exercise.pdf"
fi
if [ -f solution.pdf ]; then
cp solution.pdf ../artifacts/$ex/
export artefactList="$artefactList artifacts/$ex/solution.pdf"
fi
echo "EXTRA_ARTIFACTS: $EXTRA_ARTIFACTS"
for artifact in $EXTRA_ARTIFACTS; do
cp $artifact ../artifacts/$ex/
done
fi
cd $p
done
# final build tasks
if [[ $exportArtifacts == "export" ]]; then
# merge pdfs to one script file
echo "merge pdfs to one script file"
pdftk $artefactList cat output artifacts/fullscript.pdf
fi
}
if [[ ${BASH_SOURCE[0]} != $0 ]]; then
export -f buildSolution buildExercise buildSlides
else
buildAll "${@}"
exit $?
fi