This repository has been archived by the owner on May 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.sh
executable file
·84 lines (64 loc) · 1.97 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
set -e
FILENAME='bigchaindb-whitepaper.pdf'
FILENAME_PRIMER='bigchaindb-primer.pdf'
# # Either of those would be sooooo great, and would replace this whole file
# #pandoc -o $FILENAME src/index.tex
# #rubber --pdf --texpath=src/img src/index.tex
# check that pdflatex is installed and available
if ! pdflatex_loc="$(type -p "pdflatex")" || [ -z "$pdflatex_loc" ]; then
echo "FATAL ERROR: pdflatex not available, please check LaTeX installation and environment"
exit
fi
function pdfs {
pdflatex -interaction=nonstopmode index.tex
pdflatex -interaction=nonstopmode addendum.tex
pdflatex -interaction=nonstopmode primer.tex
}
function pdfs_combine {
if [[ "$OSTYPE" == "darwin"* ]]; then
# use Apple's builtin tool
"/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" -o $FILENAME index.pdf addendum.pdf
else
pdftk index.pdf addendum.pdf cat output $FILENAME
fi
}
# create or empty the build tmp folder
if ! [ -d "tmp" ]; then
mkdir tmp
else
rm -R -f tmp/*
fi
# remove whitepaper in root
rm -R -f $FILENAME
# copy src to build dir and go in
cp src/*.* tmp/
cp -R src/img tmp/
cd tmp
# build, first pass
pdfs
# bibtext the output
bibtex index
bibtex primer
# build, second pass, needed for page numbering
pdfs
# build, third pass, needed for bibliography
pdfs
# check the intermediate PDFs were built and exist
if ! [ -f "index.pdf" ] || ! [ -f "addendum.pdf" ] || ! [ -f "primer.pdf" ]; then
echo "FATAL ERROR: could not construct PDF files, check tex sources for errors"
exit
fi
# combine pdflatex output files
pdfs_combine
# check for final pdf file being there
if ! [ -f $FILENAME ]; then
echo "FATAL ERROR: could not construct final PDF file, check tex sources or pdftk output for errors"
exit
fi
# copy bigchaindb-whitepaper.pdf to root directory
cp $FILENAME ../$FILENAME
# copy bigchaindb-whitepaper-primer.pdf to root directory
cp primer.pdf ../$FILENAME_PRIMER
echo "PDFs successfully generated. Whoop whoop."
exit