From ec22a0fc94929ae0fe8b44f93ce20f44847ec176 Mon Sep 17 00:00:00 2001 From: Peter Somogyvari Date: Mon, 5 Apr 2021 11:28:59 -0700 Subject: [PATCH] fix(whitepaper): build fails on Ubuntu 18 due to glibc 2.29 #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 #703 Signed-off-by: Peter Somogyvari --- whitepaper/.gitignore | 3 +-- whitepaper/Dockerfile | 27 ++++++++++++++++++++ whitepaper/Makefile | 55 +++++++++++++++++++++------------------- whitepaper/deeplists.tex | 24 ++++++++++++++++++ whitepaper/pandoc.css | 8 ++++++ 5 files changed, 89 insertions(+), 28 deletions(-) create mode 100644 whitepaper/Dockerfile create mode 100644 whitepaper/deeplists.tex create mode 100644 whitepaper/pandoc.css diff --git a/whitepaper/.gitignore b/whitepaper/.gitignore index cb66d6d03f..d16386367f 100644 --- a/whitepaper/.gitignore +++ b/whitepaper/.gitignore @@ -1,2 +1 @@ -hyperledger-cactus-whitepaper.pdf -hyperledger-cactus-whitepaper.html \ No newline at end of file +build/ \ No newline at end of file diff --git a/whitepaper/Dockerfile b/whitepaper/Dockerfile new file mode 100644 index 0000000000..d84863da59 --- /dev/null +++ b/whitepaper/Dockerfile @@ -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 diff --git a/whitepaper/Makefile b/whitepaper/Makefile index 0caf46fbf4..7f0a142292 100644 --- a/whitepaper/Makefile +++ b/whitepaper/Makefile @@ -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 diff --git a/whitepaper/deeplists.tex b/whitepaper/deeplists.tex new file mode 100644 index 0000000000..3776db45b8 --- /dev/null +++ b/whitepaper/deeplists.tex @@ -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} diff --git a/whitepaper/pandoc.css b/whitepaper/pandoc.css new file mode 100644 index 0000000000..cfc5f70d0d --- /dev/null +++ b/whitepaper/pandoc.css @@ -0,0 +1,8 @@ + \ No newline at end of file