dottes/makeBooke.sh

68 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/bash
2012-02-27 08:50:45 +00:00
#
# Build the Booke. First assemble the book LaTeX, then build it
# into a PDF.
#
2012-02-25 14:32:23 +00:00
if [ $# != 1 ]; then
echo "Usage: makeBooke.sh <book dir name>"
2012-02-25 14:32:23 +00:00
exit 1
fi
dir=`pwd`
booke=$dir/$1
builddir=$dir/build
2012-02-27 08:50:45 +00:00
output=dottes.tex
outputpdf=dottes.pdf
outputa4=dottesona4.tex
outputa4pdf=dottesona4.pdf
2012-02-25 14:32:23 +00:00
mkdir -p $builddir
cp buildno.txt $builddir
if [ -r $booke/subtitle.txt ]; then
cp $booke/subtitle.txt $builddir
else
touch $builddir/subtitle.txt
fi
if [ -r $booke/intro.txt ]; then
cp $booke/intro.txt $builddir
else
touch $builddir/intro.txt
fi
cp dottes.tex.header $builddir/$output
2012-02-27 08:50:45 +00:00
# Now, for each tune, make the tune graphic and add it, inside a
# centre section, so the document. Then add a TOC entry.
2012-02-27 08:50:45 +00:00
find $booke -name "*.abc" | sort |
while read filename
do
title=`grep "^T:" $filename | head -1 | sed -e "s/^T: *//"`
2012-02-27 08:50:45 +00:00
name=`basename $filename .abc`
abcm2ps -j0 +c -n -E -O $builddir/$name.eps $filename
# Make $name.eps so we can build with LaTeX.
mv $builddir/${name}001.eps $builddir/${name}.eps
# And make the corresponding PDF for pdflatex.
epstopdf --outfile=$builddir/$name.pdf $builddir/${name}.eps
echo -E "\begin{center}" >> $builddir/$output
echo -E "\includegraphics[width=\textwidth]{$name}" >> $builddir/$output
echo -E "\addcontentsline{toc}{subsection}{$title}" >> $builddir/$output
echo -E "\end{center}" >> $builddir/$output
2012-02-27 08:50:45 +00:00
done
cat dottes.tex.footer >> $builddir/$output
2012-02-27 08:50:45 +00:00
cp $outputa4 $builddir
cd $builddir
pdflatex $output
pdflatex $output
pdflatex $outputa4
mv $outputpdf $dir/$1.pdf
mv $outputa4 $dir/${1}-booklet.pdf
cd $dir