Skip to content

Commit

Permalink
release.sh: cleaner output, handle files with whitespace in names
Browse files Browse the repository at this point in the history
  • Loading branch information
xqms committed Aug 23, 2023
1 parent de6b8ba commit 96cac3f
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function yes_or_no {
err_report() {
echo
echo
echo "release.sh:$1: ERROR: Some command failed (see above)"
echo "release.sh:$1: ERROR: Some command failed (see above and in release.log)"
exit 1
}

Expand All @@ -36,40 +36,44 @@ echo "1) Running latexpand to strip comments and unify your .tex file..."
latexpand --empty-comments $1 > submission.tex

echo
echo "2) Running pdflatex..."
pdflatex -shell-escape -interaction nonstopmode submission.tex
pdflatex -shell-escape -interaction nonstopmode submission.tex
echo "2) Running pdflatex (log in release.log)..."
pdflatex -shell-escape -interaction nonstopmode submission.tex &>> release.log
pdflatex -shell-escape -interaction nonstopmode submission.tex &>> release.log
bibtex submission
pdflatex -shell-escape -interaction nonstopmode submission.tex
pdflatex -shell-escape -interaction nonstopmode submission.tex
pdflatex -shell-escape -interaction nonstopmode submission.tex &>> release.log
pdflatex -shell-escape -interaction nonstopmode submission.tex &>> release.log

echo
echo "3) Running pdflatex with render=false to determine needed files..."
mv submission.tex submission.tex.orig
echo '\makeatletter\def\graphicscache@inhibit{true}\makeatother' > submission.tex
cat submission.tex.orig >> submission.tex
pdflatex -interaction nonstopmode -recorder submission.tex
pdflatex -interaction nonstopmode -recorder submission.tex &>> release.log

FILES=$(grep "^INPUT" submission.fls | cut -d ' ' --complement -f 1 | grep -v '^/' | grep -v 'submission\..*' | sort | uniq)
FILES="$FILES submission.tex"
grep "^INPUT" submission.fls \
| cut -d ' ' --complement -f 1 \
| grep -v '^/' \
| grep -v 'submission\..*' \
| while read f; do echo $(realpath --relative-to=. "$f"); done \
| sort | uniq > submission.fls.clean

if [[ -e submission.bbl ]]; then
FILES="$FILES submission.bbl"
fi
FILES=()

while read file; do
FILES+=("$file")
done < submission.fls.clean

# Some of the files are ./XYZ, some are XYZ
CLEAN_FILES=""
for file in $FILES; do
CLEAN_FILES="$CLEAN_FILES $(realpath --relative-to=. $file)"
done
FILES+=("submission.tex")

FILES=$(echo $CLEAN_FILES | tr ' ' '\n' | sort -u)
if [[ -e submission.bbl ]]; then
FILES+=("submission.bbl")
fi

echo "Files to be included:"
echo $FILES
echo ${FILES[@]}

echo "4) Creating archive release.tar..."
tar cf release.tar $FILES
tar cf release.tar "${FILES[@]}"

echo "5) Testing compilation..."
if [[ -e test_release ]]; then
Expand All @@ -84,9 +88,9 @@ fi
mkdir test_release
cd test_release
tar xf ../release.tar
pdflatex -interaction nonstopmode submission.tex
pdflatex -interaction nonstopmode submission.tex
pdflatex -interaction nonstopmode submission.tex
pdflatex -interaction nonstopmode submission.tex &>> release.log
pdflatex -interaction nonstopmode submission.tex &>> release.log
pdflatex -interaction nonstopmode submission.tex &>> release.log
)

echo
Expand Down

0 comments on commit 96cac3f

Please sign in to comment.