From d36bf79ee5c70680d85631d612654a70153805c0 Mon Sep 17 00:00:00 2001 From: KenwoodFox Date: Sat, 8 Feb 2025 17:15:05 -0500 Subject: [PATCH] Include packaging tool by default --- Homework {{ cookiecutter.number }}/package.sh | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 Homework {{ cookiecutter.number }}/package.sh diff --git a/Homework {{ cookiecutter.number }}/package.sh b/Homework {{ cookiecutter.number }}/package.sh new file mode 100755 index 0000000..da14a48 --- /dev/null +++ b/Homework {{ cookiecutter.number }}/package.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Output File +ZIPFILE="Homework {{cookiecutter.number}}.zip" + +# List of known LaTeX build artifacts to exclude +EXCLUDE_EXTENSIONS="*.aux *.log *.synctex.gz *.out *.toc *.bbl *.blg *.fls *.fdb_latexmk *.lof *.lot *.nav *.snm *.vrb" + +# Generate list of files to include +find . -type f > all_files.txt + +# Generate exclude list based on LaTeX build files +touch exclude_list.txt +for ext in $EXCLUDE_EXTENSIONS; do + find . -type f -name "$ext" >> exclude_list.txt +done + +# Find PDFs that match a .tex filename and exclude them +while read -r texfile; do + base="${texfile%.tex}" + if [ -f "$base.pdf" ]; then + echo "$base.pdf" >> exclude_list.txt + fi +done < <(find . -type f -name "*.tex") + +# Create the final list of files to include by filtering out excluded files +grep -vxFf exclude_list.txt all_files.txt > include_list.txt + +# Create the zip archive +zip -@ "$ZIPFILE" < include_list.txt + +# Clean up temporary files +rm -f all_files.txt include_list.txt exclude_list.txt + +echo "Packaged files into $ZIPFILE"