forked from void-linux/void-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·77 lines (58 loc) · 1.65 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
#!/bin/sh
# uses PREFIX from environment
: "${PREFIX:=/usr/local}"
set -e
PATH="$PWD/res:$PATH"
# Build HTML mdbook
echo "Building mdBook"
mdbook build
# Build mandoc version
echo "Building man pages"
mkdir -p mandoc
cd src
fd -t d "" ./ -x mkdir -p "../mandoc/{}"
fd "\.md" ./ -x pandoc \
-V "title={/.}" -V "section=7" -V "header=Void Docs" -s \
-o "../mandoc/{.}.7" "{}"
cd -
# Build script
echo "Building void-docs script and man page"
sed -e "s,@PREFIX@,$PREFIX," res/void-docs.in > res/void-docs
sed -e "s,@PREFIX@,$PREFIX," res/void-docs.1.in > res/void-docs.1
# Build PDF
echo "Building PDF"
## Temporarily add OpenType version of Latin Modern to font cache.
mkdir -p ~/.fonts
TMP_FONTDIR=$(mktemp -d -p ~/.fonts)
cp /usr/share/texmf-dist/fonts/opentype/public/lm/* $TMP_FONTDIR
fc-cache
## Create cover page using Latin Modern text.
rsvg-convert \
--dpi-x 300 \
--dpi-y 300 \
res/handbook-cover.svg > res/handbook-cover.png
## Letter version
pdflatex \
-output-directory=book/latex/ \
-jobname=handbook-letter \
book/latex/handbook.tex \
>/dev/null
pdflatex \
-output-directory=book/latex/ \
-jobname=handbook-letter \
book/latex/handbook.tex \
>/dev/null
## A4 version
sed -ie "s/\\documentclass\[letterpaper\]{article}/\\documentclass[a4paper]{article}/" \
book/latex/handbook.tex
pdflatex -output-directory=book/latex/ \
-jobname=handbook-a4 \
book/latex/handbook.tex \
>/dev/null
pdflatex -output-directory=book/latex/ \
-jobname=handbook-a4 \
book/latex/handbook.tex \
>/dev/null
## Remove temporary font directory
rm -rf $TMP_FONTDIR
fc-cache