Commit eef033d0 authored by Seth Kenlon's avatar Seth Kenlon

Finally fixed build script. Thanks Netta.

parent c22d3e0b
......@@ -12,6 +12,8 @@ VILE="true"
BLD=${BLD:-build}
DEST=${DEST:-print}
RES=${RES:-300}
PAGE=${PAGE:-A4}
TIDY=1
help() {
echo "builder.sh [build|docs|clean] /path/to/dir" || $VILE
......@@ -24,7 +26,35 @@ help() {
exit
}
build() {
merge() {
pushd "${ARG}"/"${BLD}"/"${DEST}"
pdf-stapler cat 001.pdf back.pdf \
002.pdf back.pdf \
003.pdf back.pdf \
004.pdf back.pdf \
005.pdf back.pdf \
006.pdf back.pdf \
007.pdf back.pdf \
008.pdf back.pdf \
009.pdf back.pdf \
010.pdf back.pdf \
011.pdf back.pdf \
012.pdf back.pdf \
013.pdf back.pdf \
014.pdf back.pdf \
015.pdf back.pdf \
016.pdf back.pdf \
017.pdf back.pdf \
018.pdf back.pdf \
019.pdf back.pdf \
020.pdf back.pdf \
print-deck.pdf
popd
}
sane() {
# do we have the fonts?
fc-list | grep -i "essays1743" || { exit "Essays1743 font missing. Install from the fonts directory and try again." ; exit; }
......@@ -36,22 +66,25 @@ echo "all fonts accounted for"
PDFNUP=${PDFNUP:-`which pdfnup`} || PDFNUP=""
CONVERT=${CONVERT:-`which convert`} || CONVERT=${CONVERT:-`which gm` convert}
MONTAGE=${MONTAGE:-`which montage`} || MONTAGE=${MONTAGE:-`which gm` montage}
MOGRIFY=${MOGRIFY:-`which mogrify`} || MOGRIFY=${MOGRIFY:-`which gm` mogrify}
if [ X"$CONVERT" = "X" -o X"$MONTAGE" = "X" ]; then
echo "ImageMagick or GraphicsMagick is required, but cannot be found."
exit 1
fi
}
build() {
echo "Working in $ARG"
# convert svg to png
mkdir -p "$ARG"/"${BLD}"/"${DEST}"
cat "${ARG}"/deck/system/back.png > "${ARG}"/"${BLD}"/"${DEST}"/back.png
echo "Using $CONVERT" #debug
"${MOGRIFY}" -verbose -rotate 90 "${ARG}"/"${BLD}"/"${DEST}"/back.png
find "${ARG}"/deck -type f -iname "*.svg" | xargs -I {} "${CONVERT}" {} -density $RES -rotate 90 {}.png
echo "Using $CONVERT" #debug
find "${ARG}"/deck -type f -iname "*.svg" | xargs -I% "${CONVERT}" -verbose % -density $RES -rotate 90 %.png
find "${ARG}"/deck -type f -iname "*.svg.png" | xargs -I {} mv {} "${ARG}"/"${BLD}"/"${DEST}"
find "${ARG}"/deck -type f -iname "*.svg.png" | xargs -I% mv % "${ARG}"/"${BLD}"/"${DEST}"
echo "Rasterisation complete." || $VILE
......@@ -60,27 +93,43 @@ mkdir -p "${ARG}"/"${BLD}"/"${DEST}"/_trash 2> /dev/null
pushd "${ARG}"/"${BLD}"/"${DEST}"
if [ "X$PDFNUP" = "X" ]; then
montage -density 300 -page A4 `ls -1 *.svg.png | head -n9` deck-`date +%s | cut -b 8-`.pdf && mv `ls -1 *.svg.png | head -n9` "${ARG}"/"${BLD}"/"${DEST}"/_trash/
montage -density 300 back.png back.png back.png \
back.png back.png back.png \
back.png back.png back.png -page A4 "${ARG}"/"${BLD}"/"${DEST}"/back.pdf
else
"${PDFNUP}" --nup 3x3 --suffix '3x3' `ls -1 *.svg.png | head -n9` && mv `ls -1 *.svg.png | head -n9` "${ARG}"/"${BLD}"/"${DEST}"/_trash/
"${PDFNUP}" --nup 3x3 --suffix '3x3' \
back.png back.png back.png \
back.png back.png back.png \
back.png back.png back.png
echo "Print-spreads generated as single signature documents in the print folder." || $VILE
fi
#montage to build
#ls *svg.png | xargs --max-args=9 montage -verbose -density 300 -page "${PAGE}" deck-`date +%s | cut -b 8-`.pdf
echo "Using $PDFNUP to build card layout."
ls | xargs --max-args=9 "${PDFNUP}" --nup 3x3 --suffix '3x3'
#renmae
n=1
for i in *pdf; do
mv $i `printf "%03d" $n`.pdf
let n++
done
# gen back
"${PDFNUP}" --nup 3x3 --suffix '3x3' \
back.png back.png back.png \
back.png back.png back.png \
back.png back.png back.png
mv back*pdf back.pdf
echo "Print-spreads generated as single signature documents in the print folder." || $VILE
popd
}
crop() {
#which mogrify are we using
MOGRIFY=${MOGRIFY:-`which mogrify`} || MOGRIFY=${MOGRIFY:-`which gm` mogrify}
tidy() {
#clean up
mv "${ARG}"/"${BLD}"/"${DEST}"/back.png "${ARG}"/"${BLD}"/"${DEST}"/_trash/ 2>/dev/null
mv "${ARG}"/"${BLD}"/"${DEST}"/*png "${ARG}"/"${BLD}"/"${DEST}"/_trash/ 2>/dev/null
mv *_*3x3*pdf "${ARG}"/"${BLD}"/"${DEST}"/_trash/ 2>/dev/null
}
crop() {
find "${ARG}"/"${BLD}"/"${DEST}" -type f -name "*.pdf" | xargs "${MOGRIFY}" -density $RES -draw 'lines 740,0 740,20'
find "${ARG}"/"${BLD}"/"${DEST}" -type f -name "*.pdf" | xargs "${MOGRIFY}" -density $RES -draw 'lines 1480,0 1480,20'
find "${ARG}"/"${BLD}"/"${DEST}" -type f -name "*.pdf" | xargs "${MOGRIFY}" -density $RES -draw 'lines 0,1047 20,1047'
......@@ -89,8 +138,8 @@ crop() {
doc() {
cd "${ARG}"/doc
make html
make pdf || echo "In doc build: PDF failed, but HTML version succeeded and is printable." || $VILE
make html || echo "In doc build: HTML build failed."
make pdf || echo "In doc build: PDF failed." || $VILE
mkdir "${ARG}"/"${BLD}"/"${DEST}" 2>/dev/null || true
mv "${ARG}"/doc/build "${ARG}"/"${BLD}"/"${DEST}"/docs
echo "A fitful slumber brings the nights adventures to an end." || $VILE
......@@ -115,6 +164,12 @@ elif [ "$1" = "build" -o "$1" = "--build" -o "$1" = "bld" -o "$1" = "-b" ]; the
elif [ "$1" = "crop" -o "$1" = "--crop" ]; then
CROP=1
shift 1
elif [ "$1" = "merge" -o "$1" = "--merge" ]; then
MERGE=1
shift 1
elif [ "$1" = "--no-tidy" ]; then
TIDY=0
shift 1
elif [ "$1" = "evil" -o "$1" = "--vile" -o "$1" = "666" -o "$1" = "redrum" ]; then
EVIL=1
shift 1
......@@ -148,7 +203,14 @@ fi
if [ X"$BUILD" = X"1" ]; then
#then build the cards
sane
build "${ARG}"
if [ X"$MERGE" = X"1" ]; then
merge
fi
if [ X"$TIDY" = X"1" ]; then
tidy
fi
fi
if [ X"$CROP" = X"1" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment