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
@ -154,13 +165,13 @@ case "$TARGET_BUILD" in
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"