Update build script to output more error and code cleanup

This commit is contained in:
Thomas Schwery 2015-12-27 22:53:20 +01:00
parent c01a1d3dcd
commit 803eb727ba

View file

@ -97,26 +97,37 @@ syntax_check() {
}
operate_replacements() {
# We check that the replacement script is there, otherwise we just
# ignore this step.
if [ -f "$REPLACEMENT_SCRIPT" -a -x "$REPLACEMENT_SCRIPT" ]; then
# We check that the replacement script is there, otherwise we just
# ignore this step.
if [ -f "$REPLACEMENT_SCRIPT" -a -x "$REPLACEMENT_SCRIPT" ]; then
echo "Processing replacement rules"
$REPLACEMENT_SCRIPT $(find $@ -name '*.tex')
else
echo "'$REPLACEMENT_SCRIPT' not found. No automatic word substitution will occur" >&2
fi
$REPLACEMENT_SCRIPT $(find $@ -name '*.tex')
else
echo "'$REPLACEMENT_SCRIPT' not found. No automatic word substitution will occur" >&2
fi
}
build_pdf_book() {
if which "rubber" > /dev/null; then
rubber -d $1 > /dev/null 2> /dev/null
else
pdflatex -halt-on-error "$1".tex > /dev/null && makeindex "$1".idx > /dev/null 2> /dev/null && pdflatex -halt-on-error "$1".tex >/dev/null
fi
pdflatex -halt-on-error "$1".tex > /dev/null
if [ $? -ne 0 ]; then
echo "Error while compiling the LaTeX file for $1"
exit 5
fi
makeindex "$1".idx > /dev/null 2> /dev/null
if [ $? -ne 0 ]; then
echo "Error while generating the index file for $1"
exit 6
fi
pdflatex -halt-on-error "$1".tex >/dev/null
if [ $? -ne 0 ]; then
echo "Error while compiling the LaTeX file for $1"
exit 5
fi
}
build_pdf_page() {
pdflatex "$1" -output-directory "$2" > /dev/null
pdflatex "$1" -output-directory "$2" > /dev/null
}
if [ $# -eq 0 ]; then
@ -127,13 +138,13 @@ fi
# We have to garantee that the destination folders will be there ...
if [ ! -d $INDIVID_FOLDER ]; then
makedir $INDIVID_FOLDER
mkdir $INDIVID_FOLDER
fi
if [ ! -d $INDIVID_FOLDER_PDF ]; then
makedir $INDIVID_FOLDER_PDF
mkdir $INDIVID_FOLDER_PDF
fi
if [ ! -d $MERGE ]; then
makedir $MERGE
mkdir $MERGE
fi
@ -141,26 +152,26 @@ case "$TARGET_BUILD" in
all)
echo "Building the whole book"
rm -f "$CHAPTERS"/*.tex "$CHAPTERS2"/*.tex
operate_replacements "$CHAPTERS" "$CHAPTERS2"
echo "Preparing build files"
for chapter in $(find "$CHAPTERS"/* "$CHAPTERS2"/* -prune -type d); do
perl tri.pl "$chapter".tex "$chapter"
done;
for chapter in $(find "$CHAPTERS"/* "$CHAPTERS2"/* -prune -type d | awk -F'/' '{print $2;}' | sort | uniq); do
perl tri.pl "$MERGE"/"$chapter".tex "$CHAPTERS"/"$chapter" "$CHAPTERS2"/"$chapter"
done;
echo "Building book I"
build_pdf_book "recettes"
build_pdf_book "recettes"
echo "Building book II"
build_pdf_book "recettes2"
build_pdf_book "recettes2"
echo "Building complete book"
build_pdf_book "recettes_merge"
build_pdf_book "recettes_merge"
;;
clean)
echo "Cleaning the build files"
@ -169,9 +180,9 @@ case "$TARGET_BUILD" in
;;
individ)
echo "Building individual recipes";
operate_replacements "$CHAPTERS" "$CHAPTERS2"
for chapter in $(find "$CHAPTERS"/* "$CHAPTERS2"/* -prune -type d); do
for recette in $(find "$chapter"/ -name '*.tex'); do
recette_base=$(basename "$recette")