aboutsummaryrefslogtreecommitdiff
path: root/scripts/lesson-dist
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-11-01 12:51:43 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2024-11-01 12:51:43 +0100
commitd9be4a8be6689643c4bb6ae9fb1f9e3194a68b1d (patch)
tree2d69e6bdf2558a4b57bb52a2da0240c1ed44454e /scripts/lesson-dist
parentd7ffab7a327c28fac3a93522744ba67019035993 (diff)
downloadunterricht-d9be4a8be6689643c4bb6ae9fb1f9e3194a68b1d.tar.gz
unterricht-d9be4a8be6689643c4bb6ae9fb1f9e3194a68b1d.zip
fix file word splitting in lesson-dist script
Diffstat (limited to 'scripts/lesson-dist')
-rwxr-xr-xscripts/lesson-dist37
1 files changed, 19 insertions, 18 deletions
diff --git a/scripts/lesson-dist b/scripts/lesson-dist
index 15ca2368..52184484 100755
--- a/scripts/lesson-dist
+++ b/scripts/lesson-dist
@@ -1,15 +1,16 @@
-#!/bin/sh
+#!/bin/bash
# Create a distributable archive for my lesson material
-ARCHIVE="$(basename "$PWD").zip"
-zip "${ARCHIVE}" $(find . -mindepth 1 -not -path './.*' -printf '%p ')
+archive="$(basename "$PWD").zip"
+readarray -t files < <(find . -mindepth 1 -not -path './.*' -printf '%p\n')
+zip "${archive}" "${files[@]}"
# TODO: replace hardcoded base dir
-BASEDIR=/home/muhq/Documents/MyDocuments/Work/Schule/Unterricht
+basedir=/home/muhq/Documents/MyDocuments/Work/Schule/Unterricht
add_to_archive() {
python3 <<EOF
import zipfile
-with zipfile.ZipFile("${ARCHIVE}", "a") as zf:
+with zipfile.ZipFile("${archive}", "a") as zf:
zf.write("$1", "$2")
EOF
}
@@ -17,47 +18,47 @@ EOF
add_custom_latex_to_archive() {
for path in "$@"
do
- path_in_arc="$(echo "${path}" | sed -e "s%${BASEDIR}/%%")"
+ # 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
+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
+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/**
+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
+ 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
+ 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
+ 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
+ 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
+ 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
+ add_custom_latex_to_archive "${basedir}"/latex/common_planning*.tex
fi
-