aboutsummaryrefslogtreecommitdiff
path: root/bin/provision
blob: 25816f1a0f7166f03bcd63e63e608e5e36571dc3 (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
#
# Provisioner
#

# Parameters
DIRNAME="`dirname $0`"
BASEDIR="$DIRNAME/.."

# Load optional customizations
#
# Search in multiple levels to account when this repository is vendorized.
[ -f "$BASEDIR/.env" ] && source $BASEDIR/.env
[ -f "$BASEDIR/../.env" ] && source $BASEDIR/../.env
[ -f "$BASEDIR/../../.env" ] && source $BASEDIR/../../.env

# Bookdown packaging approach
BOOKDOWN_PACKAGING="${BOOKDOWN_PACKAGING:-DEB}"

# Dependencies
DEPENDENCIES="make"

# LaTeX dependencies
DEPENDENCIES="$DEPENDENCIES texlive-latex-base texlive-latex-recommended texlive-science"
DEPENDENCIES="$DEPENDENCIES texlive-latex-extra texlive-fonts-extra texlive-extra-utils"
DEPENDENCIES="$DEPENDENCIES texlive-xetex texlive-lang-portuguese vim-latexsuite"

# Pandoc dependencies
DEPENDENCIES="$DEPENDENCIES pandoc"
#DEPENDENCIES="$DEPENDENCIES python3-pandocfilters"

# May be unavailable on Debian bookworm onwards
#DEPENDENCIES="$DEPENDENCIES pandoc-citeproc"

# Tufte CSS
# Needed by Tufte HTML output
# https://github.com/jez/pandoc-sidenote
#
# Not available on Debian trixie:
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087153
#DEPENDENCIES="$DEPENDENCIES pandoc-sidenote"
#
# Install using cabal instead
#$SUDO apt install cabal-install
#$SUDO cabal update
#$SUDO cabal install pandoc-sidenote
#$SUDO apt install -y libghc-pandoc-sidenote-dev \
#                     libghc-pandoc-sidenote-doc libghc-pandoc-sidenote-prof

# R dependencies
DEPENDENCIES="$DEPENDENCIES r-cran-rmarkdown r-cran-magick"

# Libraries
DEPENDENCIES="$DEPENDENCIES libpoppler-cpp-dev"
DEPENDENCIES="$DEPENDENCIES libfontconfig1-dev libharfbuzz-dev libfribidi-dev"
DEPENDENCIES="$DEPENDENCIES libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev"

# Fonts
DEPENDENCIES="$DEPENDENCIES fonts-liberation fonts-linuxlibertine"

# Graphviz
DEPENDENCIES="$DEPENDENCIES graphviz"

# Additional BibTeX dependencies
#DEPENDENCIES="$DEPENDENCIES texlive-bibtex-extra"
DEPENDENCIES="$DEPENDENCIES biber pybtex"

# For pdfcrop support
DEPENDENCIES="$DEPENDENCIES texlive-extra-utils"

# Old dependencies
#DEPENDENCIES="$DEPENDENCIES python-yaml python-cheetah python-unidecode python-pycurl python-shortuuid"
#DEPENDNECIES="$DEPENDENCIES python-sphinx python-sphinx-bootstrap-theme python-sphinx-paramlinks"
#DEPENDENCIES="$DEPENDENCIES python-sphinx-patchqueue python-sphinx-rtd-theme python-sphinx-gallery"
#DEPENDENCIES="$DEPENDENCIES python-sphinxcontrib.bibtex-doc"
#DEPENDENCIES="$DEPENDENCIES pelican hugo jekyll"

# Check for sudo
if [ "`whoami`" != "root" ]; then
  SUDO="sudo"
fi

# Configure Debian backports
#if which trashman &> /dev/null; then
#  trashman install debian-backports
#fi

# Ensure an up-to-date system
$SUDO apt-get update && $SUDO apt-get dist-upgrade -y && \
  $SUDO apt-get autoremove -y && $SUDO apt-get clean

# Install dependencies
$SUDO apt install -y $DEPENDENCIES

# Bookdown dependencies
$SUDO apt install -y libcurl4-openssl-dev libssl-dev

if [ "$BOOKDOWN_PACKAGING" == "CRAN" ]; then
  $SUDO $DIRNAME/provision.R
else
  $SUDO apt install -y r-cran-bookdown
  $SUDO apt install -y r-cran-pdftools

  # As of 2024-08-16, this package is not available on Debian bookworm
  $SUDO Rscript -e 'install.packages("eulerr")'

  # As of 2024-08-16, ggplot2 from Debian bookworm version is 3.4.1, whereas
  # some downstreams need functionality from 3.5.0 (specifically, the ability
  # to use 'theme(legend.position = "inside"' constructs.
  #
  # Therefore we're currently installing a ggplot2 version from CRAN.
  $SUDO Rscript -e 'install.packages("ggplot2")'
fi