Skip to content

Commit

Permalink
fix(whitepaper): build fails on Ubuntu 18 due to glibc 2.29 hyperledg…
Browse files Browse the repository at this point in the history
…er#703

Refactored the whitepaper build toolchain to be based on
entirely just containers so that it is easier to set up the build
which now only requires a working docker installation and
make (for the Makefile).

Also refactored the generated files to be placed under the
./whitepaper/build/ directory instead of being dumped
straight into the ./whitepaper/ directory so that it is
easier to differentiate between what are build files and
what are not.

There are 3 different pdf generation tasks in order to provide
contributors with a way of comparing the differnet pdfs rendring
issues (since we have a few bugs active in that sense still).
The supposedly "best" pdf render is produced by the make
target called "pdf-wk-with-flags" which is exported to the
build directory with a similar suffix in the filename as well.

The new way to do a full build is by issuing the `make` command
from the ./whitepaper/ directory of the project.

A Dockerfile was added accordingly and is tagged for the current
revision on DockerHub as:
petermetz/cactus-whitepaper-builder:2021-03-22-fix-703

Fixes hyperledger#703

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Mar 23, 2021
1 parent edb8eac commit ab21451
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 28 deletions.
3 changes: 1 addition & 2 deletions whitepaper/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
hyperledger-cactus-whitepaper.pdf
hyperledger-cactus-whitepaper.html
build/
27 changes: 27 additions & 0 deletions whitepaper/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM pandoc/latex:2.12

RUN tlmgr list

RUN tlmgr update --self && \
tlmgr install \
enumitem \
merriweather \
fontaxes \
mweights \
mdframed \
needspace \
sourcesanspro \
sourcecodepro \
titling \
ly1 \
pagecolor \
adjustbox \
collectbox \
titlesec \
fvextra \
pdftexcmds \
footnotebackref \
zref \
fontawesome5 \
footmisc \
sectsty
55 changes: 29 additions & 26 deletions whitepaper/Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
PD_DEB_URL = https://github.com/jgm/pandoc/releases/download/2.9.2/pandoc-2.9.2-1-amd64.deb
PD_DEB_FILE = pandoc-2.9.2-1-amd64.deb
PD = pandoc
PDFLAGS = --from=markdown_mmd+yaml_metadata_block+smart+grid_tables+pipe_tables --standalone --self-contained --to=html --metadata title="" whitepaper.md
WK_DEB_FILE = wkhtmltox_0.12.5-1.bionic_amd64.deb
WK_DEB_URL = https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
WK = wkhtmltopdf
WKFLAGS = --dpi 150 --disable-smart-shrinking hyperledger-cactus-whitepaper.html --allow $(pwd)

CURRENT_UID := $(shell id -u)
CURRENT_GID := $(shell id -g)
MAKEFILE_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
WKFLAGS = --log-level info --dpi 150 --disable-smart-shrinking
WKMARGINS = --margin-bottom 1mm --margin-top 1mm --margin-left 1mm --margin-right 1mm


.PHONY: all
all: clean configure pdf


.PHONY: clean
clean:
rm -rf $(MAKEFILE_DIR)/build/*

.PHONY: pdf
pdf: html
$(WK) $(WKFLAGS) - hyperledger-cactus-whitepaper.pdf
pdf: html pdf-wk-with-flags pdf-wk-no-flags pdf-pandoc

.PHONY: html
html:
$(PD) $(PDFLAGS) > hyperledger-cactus-whitepaper.html
.PHONY: pdf-wk-no-flags
pdf-wk-no-flags:
docker run --rm --volume $(MAKEFILE_DIR):/whitepaper --user ${CURRENT_UID}:${CURRENT_UID} --workdir /whitepaper/ --entrypoint wkhtmltopdf icalialabs/wkhtmltopdf --allow /whitepaper $(WKMARGINS) /whitepaper/build/hyperledger-cactus-whitepaper.html - /whitepaper/build/hyperledger-cactus-whitepaper-wk-no-flags.pdf

install-wkhtmltox:
wget $(WK_DEB_URL)
sudo gdebi --non-interactive $(WK_DEB_FILE)
rm $(WK_DEB_FILE)
.PHONY: pdf-wk-with-flags
pdf-wk-with-flags:
docker run --rm --volume $(MAKEFILE_DIR):/whitepaper --user ${CURRENT_UID}:${CURRENT_UID} --workdir /whitepaper/ --entrypoint wkhtmltopdf icalialabs/wkhtmltopdf --allow /whitepaper $(WKMARGINS) $(WKFLAGS) /whitepaper/build/hyperledger-cactus-whitepaper.html - /whitepaper/build/hyperledger-cactus-whitepaper-wk-with-flags.pdf

install-pandoc:
wget $(PD_DEB_URL)
sudo gdebi --non-interactive $(PD_DEB_FILE)
rm $(PD_DEB_FILE)
.PHONY: pdf-pandoc
pdf-pandoc:
docker run --rm --volume $(MAKEFILE_DIR):/whitepaper --user ${CURRENT_UID}:${CURRENT_UID} --workdir /whitepaper/ petermetz/cactus-whitepaper-builder:2021-03-22-fix-703 -H deeplists.tex -V geometry:margin=1cm --standalone --output /whitepaper/build/hyperledger-cactus-whitepaper-pandoc.pdf /whitepaper/whitepaper.md

install-gdebi-core:
sudo apt-get update
sudo apt-get install -y gdebi-core
.PHONY: html
html:
docker run --rm --volume $(MAKEFILE_DIR):/whitepaper --user ${CURRENT_UID}:${CURRENT_UID} --workdir /whitepaper petermetz/cactus-whitepaper-builder:2021-03-22-fix-703 --verbose -V fontsize=12pt -V geometry:margin=1cm -H pandoc.css --from=gfm --standalone --self-contained --to=html --metadata title="" --output=build/hyperledger-cactus-whitepaper.html --to=html /whitepaper/whitepaper.md

# Tested on Ubuntu 18.04 and 20.04 only
configure: install-gdebi-core install-pandoc install-wkhtmltox
configure:
docker build $(MAKEFILE_DIR) -t cactus-whitepaper-builder
24 changes: 24 additions & 0 deletions whitepaper/deeplists.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
\usepackage{enumitem}
\setlistdepth{9}

\setlist[itemize,1]{label=$\bullet$}
\setlist[itemize,2]{label=$\bullet$}
\setlist[itemize,3]{label=$\bullet$}
\setlist[itemize,4]{label=$\bullet$}
\setlist[itemize,5]{label=$\bullet$}
\setlist[itemize,6]{label=$\bullet$}
\setlist[itemize,7]{label=$\bullet$}
\setlist[itemize,8]{label=$\bullet$}
\setlist[itemize,9]{label=$\bullet$}
\renewlist{itemize}{itemize}{9}

\setlist[enumerate,1]{label=$\arabic*.$}
\setlist[enumerate,2]{label=$\alph*.$}
\setlist[enumerate,3]{label=$\roman*.$}
\setlist[enumerate,4]{label=$\arabic*.$}
\setlist[enumerate,5]{label=$\alpha*$}
\setlist[enumerate,6]{label=$\roman*.$}
\setlist[enumerate,7]{label=$\arabic*.$}
\setlist[enumerate,8]{label=$\alph*.$}
\setlist[enumerate,9]{label=$\roman*.$}
\renewlist{enumerate}{enumerate}{9}
8 changes: 8 additions & 0 deletions whitepaper/pandoc.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<style type="text/css">
body {
margin: auto;
padding-right: 1em;
padding-left: 1em;
max-width: 54em;
}
</style>

0 comments on commit ab21451

Please sign in to comment.