X-Git-Url: http://git.projectaon.org/?p=project-aon.git;a=blobdiff_plain;f=common%2Fepub%2Fbuild-epubs.sh;fp=common%2Fepub%2Fbuild-epubs.sh;h=075da1bfae4a45d5753ae81d72b1323e2106095a;hp=0000000000000000000000000000000000000000;hb=f4bdee5083ca9a72713637e1e979aa183e06faea;hpb=97545603aea8298f1eceb604ff65085cc7adfced diff --git a/common/epub/build-epubs.sh b/common/epub/build-epubs.sh new file mode 100644 index 0000000..075da1b --- /dev/null +++ b/common/epub/build-epubs.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# +# Build all the ePub files for Project Aon in a single run +# +# (c) 2011 Javier Fernandez-Sanguino +# +# This script is provided with the same license as that one +# used in the Aon Project + +set -e + +CURDIR=`pwd` +AONDIR="../../" +LOGDIR="$CURDIR/logs/" +[ ! -e "$LOGDIR" ] && mkdir $LOGDIR +LANGS="en es" +FONTDIR=fontfiles/ + +if [ ! -e "${AONDIR}${FONTDIR}" ] ; then + echo "The font directory (${AONDIR}${FONTDIR}) does not exist." + echo "Please create it and copy the Souvenir font to it " + echo "(or adjust the script to use an alternative directory)" + exit 1 +fi + +generate_files() { + ls ${AONDIR}/${lang}/xml/*.xml | + while read file ; do + if [ -r "$file" ]; then + xml=`basename $file | sed -e 's/\.xml//'` + # Look for the XML name in the ePub metadata + if grep -q ^$xml $EPUBDATA; then + echo -n "Generating ePub file for $xml ('$lang' language)..." + LOGFILE=$LOGDIR/$xml.epub.log + cd $AONDIR + set +e + perl common/scripts/gbtoepub.pl --language=$lang --font-files=$FONTDIR $xml >$LOGFILE 2>&1 + if [ $? -ne 0 ]; then + echo " ERROR building file (review $LOGFILE)" + fi + set -e + cd $CURDIR + echo "...done" + fi + else + echo "ERROR: Cannot generate ePub file for $xml (not readable)" + fi + done + +} + + +for lang in $LANGS; do + EPUBDATA=${AONDIR}/${lang}/.publisher/rules/epub + if [ -e "$EPUBDATA" ] ; then + generate_files + else + echo "ERROR: Cannot find the publisher rules at $EPUBDATA for $lang" + fi +done + +exit 0