From 9294ebca1c6cc28f37986f8064d999f4965c8de3 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 7 Sep 2024 15:22:30 +0200 Subject: improve script to create a distributable zip archive * Only add needed latex code. * Include the License from the BASEDIR --- scripts/lesson-dist | 55 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/lesson-dist b/scripts/lesson-dist index 6d9d136d..15ca2368 100755 --- a/scripts/lesson-dist +++ b/scripts/lesson-dist @@ -1,8 +1,7 @@ #!/bin/sh # Create a distributable archive for my lesson material - ARCHIVE="$(basename "$PWD").zip" -zip "${ARCHIVE}" ./** +zip "${ARCHIVE}" $(find . -mindepth 1 -not -path './.*' -printf '%p ') # TODO: replace hardcoded base dir BASEDIR=/home/muhq/Documents/MyDocuments/Work/Schule/Unterricht @@ -15,8 +14,50 @@ with zipfile.ZipFile("${ARCHIVE}", "a") as zf: EOF } -for path in "${BASEDIR}"/latex/*.cls "${BASEDIR}"/latex/*.tex "${BASEDIR}"/latex/images/**; -do - path_in_arc="$(echo "${path}" | sed -e "s%${BASEDIR}/%%")" - add_to_archive "${path}" "${path_in_arc}" -done +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 + -- cgit v1.2.3