annotate makeBooke.sh @ 710:e99a1b0ad869

Handle slows as per Banks of the Dee.
author Jim Hague <jim.hague@acm.org>
date Sun, 08 Oct 2017 20:34:07 +0100
parents b45a87f4ccdb
children ce5c7214f9aa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
1 #!/bin/bash
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
2 #
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
3 # Build the Booke. Move subfiles into place and build the Booke into a PDF.
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
4 #
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
5 # The Booke tune content and all EPS and PDF tune graphics must be
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
6 # present already. Run makeGraphics.sh first and then
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
7 # makeBookeTunePages.sh.
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
8 #
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
9
603
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
10 if [ $# -lt 2 ]; then
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
11 echo "Usage: makeBooke.sh <A4|A5> <book dir name> [<book dir name>...]"
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
12 exit 1
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
13 fi
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
14
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
15 dir=`pwd`
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
16
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
17 builddir=$dir/build
603
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
18 booketex=$builddir/dottes.tex
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
19 bookepdf=$builddir/dottes.pdf
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
20
603
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
21 papersize=$1
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
22 shift
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
23
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
24 mkdir -p $builddir
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
25
603
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
26 if [ $# -eq 1 ]; then
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
27 bookename=$1
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
28 for item in title subtitle instrument
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
29 do
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
30 rm -f $builddir/$item.txt
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
31 if [ -r $1/$item.txt ]; then
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
32 cp $dir/$1/$item.txt $builddir/$item.txt
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
33 else
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
34 touch $builddir/$item.txt
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
35 fi
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
36 done
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
37 else
606
d5357ee6b4b2 Rework makeAll.sh to make multiple Bookes and a Bumper Booke too.
Jim Hague <jim.hague@acm.org>
parents: 603
diff changeset
38 bookename="Bumper"
603
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
39 echo "The Bumper Booke" > $builddir/title.txt
606
d5357ee6b4b2 Rework makeAll.sh to make multiple Bookes and a Bumper Booke too.
Jim Hague <jim.hague@acm.org>
parents: 603
diff changeset
40 echo "The collected Bookes of Dottes" > $builddir/subtitle.txt
603
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
41 rm -f $builddir/instrument.txt
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
42 if [ -r $1/instrument.txt ]; then
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
43 cp $1/instrument.txt $builddir/instrument.txt
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
44 else
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
45 touch $builddir/instrument.txt
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
46 fi
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
47 fi
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
48
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
49 cp dottes.tex $builddir
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
50 cp buildno.txt $builddir
304
9c5cabaabbec Replace buzzard EPS with cropped PDF.
Jim Hague <jim.hague@acm.org>
parents: 266
diff changeset
51 cp buzzard.pdf $builddir
603
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
52
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
53 rm -f $builddir/tunes.tex
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
54 rm -f $builddir/firstlines.tex
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
55
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
56 while [ $# -gt 0 ]
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
57 do
603
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
58 section=$dir/$1
675
7ad6c0aa958d Strip any '-<instrument>' from section name for booke text.
Jim Hague <jim.hague@acm.org>
parents: 606
diff changeset
59 # Section name - strip any instrument name off the end.
7ad6c0aa958d Strip any '-<instrument>' from section name for booke text.
Jim Hague <jim.hague@acm.org>
parents: 606
diff changeset
60 sectionname=${1/-*/}
603
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
61
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
62 for item in title subtitle instrument
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
63 do
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
64 rm -f $builddir/$1-$item.txt
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
65 if [ -r $section/$item.txt ]; then
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
66 cp $section/$item.txt $builddir/$1-$item.txt
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
67 else
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
68 touch $builddir/$1-$item.txt
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
69 fi
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
70 done
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
71 for item in intro
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
72 do
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
73 rm -f $builddir/$1-$item.tex
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
74 if [ -r $section/$item.md ]; then
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
75 pandoc --from=markdown --to=latex --output=$builddir/$1-$item.tex $section/$item.md
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
76 else
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
77 touch $builddir/$1-$item.tex
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
78 fi
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
79 done
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
80
677
b45a87f4ccdb Make sure section names strip any '-<instrument>' filename decoration.
Jim Hague <jim.hague@acm.org>
parents: 675
diff changeset
81 sed -e "s/@SECTION@/$1/" -e "s/@SECTIONNAME@/$sectionname/" dottes.tex.section-tunes >> $builddir/tunes.tex
b45a87f4ccdb Make sure section names strip any '-<instrument>' filename decoration.
Jim Hague <jim.hague@acm.org>
parents: 675
diff changeset
82 sed -e "s/@SECTION@/$1/" -e "s/@SECTIONNAME@/$sectionname/" dottes.tex.section-firstlines >> $builddir/firstlines.tex
603
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
83
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
84 shift
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
85 done
601
507d853433ef Create a section title page in the print version.
Jim Hague <jim.hague@acm.org>
parents: 582
diff changeset
86
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
87 for filename in $dir/*.${papersize}.tex
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
88 do
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
89 name=`basename $filename .${papersize}.tex`
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
90 cp $filename $builddir/$name.tex
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
91 done
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
92
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
93 cd $builddir
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
94
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
95 xelatex $booketex
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
96 xelatex $booketex
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
97 xelatex $booketex
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
98
603
ef0d66742e01 Revise build to allow multi-section books.
Jim Hague <jim.hague@acm.org>
parents: 602
diff changeset
99 mv $bookepdf $dir/$bookename-${papersize}.pdf
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
100
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
101 cd $dir