forked from CryHavoc/dottes
125 lines
3.5 KiB
Bash
Executable File
125 lines
3.5 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Build the Booke. First assemble the book LaTeX, then build it
|
|
# into a PDF.
|
|
#
|
|
# All EPS and PDF tune graphics must be present already. Run
|
|
# makeGraphics.sh to make these.
|
|
#
|
|
|
|
# Restore titles like 'Exploding Potato, The' to the
|
|
# expected 'The Exploding Potato'.
|
|
fixtitle()
|
|
{
|
|
retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"`
|
|
}
|
|
|
|
if [ $# != 1 ]; then
|
|
echo "Usage: makeBookeA5.sh <book dir name>"
|
|
exit 1
|
|
fi
|
|
|
|
dir=`pwd`
|
|
|
|
booke=$dir/$1
|
|
builddir=$dir/build
|
|
graphicsdir=$dir/graphics/$1
|
|
output=dottesA5.tex
|
|
outputxdv=${output/%.tex/.xdv}
|
|
outputpdf=${output/%.tex/.pdf}
|
|
outputa4=dottesA5onA4booklet.tex
|
|
outputa4pdf=dottesA5onA4booklet.pdf
|
|
|
|
mkdir -p $builddir
|
|
|
|
cp buildno.txt $builddir
|
|
cp buzzard.eps $builddir
|
|
if [ -r $booke/title.txt ]; then
|
|
cp $booke/title.txt $builddir
|
|
else
|
|
touch $builddir/title.txt
|
|
fi
|
|
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.a5header $builddir/$output
|
|
cat dottes.tex.intro >> $builddir/$output
|
|
|
|
# Now, for each tune, make the tune graphic and add it, inside a
|
|
# centre section, so the document. Then add a TOC entry.
|
|
find $booke -name "*.abc" | sort |
|
|
while read filename
|
|
do
|
|
name=`basename $filename .abc`
|
|
title=`$dir/abcfield.py --field T --latex $filename`
|
|
fixtitle "$title"
|
|
title=$retval
|
|
|
|
echo -E "\newpage" >> $builddir/$output
|
|
echo -E "\begin{center}" >> $builddir/$output
|
|
echo -E "\phantomsection" >> $builddir/$output
|
|
echo -E "\hypertarget{$name}{\includegraphics[width=\textwidth,height=0.85\textheight,keepaspectratio]{$graphicsdir/$name}}" >> $builddir/$output
|
|
echo -E "\addcontentsline{toc}{subsection}{$title}" >> $builddir/$output
|
|
echo -E "\end{center}" >> $builddir/$output
|
|
|
|
changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"`
|
|
changetitle=""
|
|
if [ -n "$changefile" ]; then
|
|
changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile`
|
|
fixtitle "$changetitle"
|
|
changetitle=$retval
|
|
changename=`basename $changefile .abc`
|
|
echo -E "Change: \hyperlink{$changename}{$changetitle}" >> $builddir/$output
|
|
fi
|
|
done
|
|
|
|
cat dottes.tex.firstlines >> $builddir/$output
|
|
|
|
find $booke -name "*.abc" | sort |
|
|
while read filename
|
|
do
|
|
name=`basename $filename .abc`
|
|
title=`$dir/abcfield.py --field T --latex $filename`
|
|
fixtitle "$title"
|
|
title=$retval
|
|
echo -E "\hyperlink{$name}{$title} & \raisebox{-.25\height}{\includegraphics[width=0.6\textwidth]{$graphicsdir/firstline-$name}} \\\\" >> $builddir/$output
|
|
done
|
|
|
|
cat dottes.tex.footer >> $builddir/$output
|
|
|
|
cp $outputa4 $builddir
|
|
|
|
cd $builddir
|
|
|
|
# The version of xetex on Squeeze doesn't do pass the A5 landscape instruction
|
|
# down to the PDF generator. So split out and do manually.
|
|
#
|
|
# And, sigh, this fails on Sid. The first page comes out as A4 portrait.
|
|
# So try to work out which we are using and run the appropriate command.
|
|
ver=`xetex -version | head -n 1`
|
|
ver=${ver/*TeX Live /}
|
|
ver=${ver/\/*/}
|
|
if [ "$ver" == "2009" ]; then
|
|
xelatex -no-pdf $output
|
|
xelatex -no-pdf $output
|
|
xelatex -no-pdf $output
|
|
xdvipdfmx -p a5 -l $outputxdv
|
|
else
|
|
xelatex $output
|
|
xelatex $output
|
|
xelatex $output
|
|
fi
|
|
xelatex $outputa4
|
|
|
|
mv $outputpdf $dir/$1-A5.pdf
|
|
mv $outputa4pdf $dir/${1}-A5bookletA4.pdf
|
|
|
|
cd $dir
|