-
Notifications
You must be signed in to change notification settings - Fork 181
/
install_quarto.sh
executable file
·74 lines (59 loc) · 2.43 KB
/
install_quarto.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
#!/bin/bash
## Install quarto cli or symlink quarto cli so they are available system-wide.
##
## In order of preference, first argument of the script, the QUARTO_VERSION variable.
## ex. latest, default, 0.9.16
##
## 'default' means the version bundled with RStudio if RStudio is installed, but 'latest' otherwise.
## 'latest', 'release' means installing the latest release version.
## 'prerelease' means installing the latest prerelease version.
set -e
## build ARGs
NCPUS=${NCPUS:--1}
QUARTO_VERSION=${1:-${QUARTO_VERSION:-"default"}}
# Only amd64 build can be installed now
ARCH=$(dpkg --print-architecture)
# a function to install apt packages only if they are not installed
function apt_install() {
if ! dpkg -s "$@" >/dev/null 2>&1; then
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
apt-get update
fi
apt-get install -y --no-install-recommends "$@"
fi
}
apt_install wget ca-certificates
if [ -x "$(command -v quarto)" ]; then
INSTALLED_QUARTO_VERSION=$(quarto --version)
fi
# Check RStudio bundled quarto cli
if [ -f "/usr/lib/rstudio-server/bin/quarto/bin/quarto" ]; then
BUNDLED_QUARTO="/usr/lib/rstudio-server/bin/quarto/bin/quarto"
fi
if [ -n "$BUNDLED_QUARTO" ]; then
BUNDLED_QUARTO_VERSION="$($BUNDLED_QUARTO --version)"
fi
# Install quarto cli
if [ "$QUARTO_VERSION" != "$INSTALLED_QUARTO_VERSION" ]; then
# Check RStudio bundled quarto cli
if [ "$QUARTO_VERSION" = "default" ] && [ -z "$BUNDLED_QUARTO" ]; then
QUARTO_VERSION="latest"
fi
if [ "$QUARTO_VERSION" = "$BUNDLED_QUARTO_VERSION" ] || [ "$QUARTO_VERSION" = "default" ]; then
ln -fs "$BUNDLED_QUARTO" /usr/local/bin
else
if [ "$QUARTO_VERSION" = "latest" ] || [ "$RSTUDIO_VERSION" = "release" ]; then
QUARTO_DL_URL=$(wget -qO- https://quarto.org/docs/download/_download.json | grep -oP "(?<=\"download_url\":\s\")https.*${ARCH}\.deb")
elif [ "$QUARTO_VERSION" = "prerelease" ]; then
QUARTO_DL_URL=$(wget -qO- https://quarto.org/docs/download/_prerelease.json | grep -oP "(?<=\"download_url\":\s\")https.*${ARCH}\.deb")
else
QUARTO_DL_URL="https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-${ARCH}.deb"
fi
wget "$QUARTO_DL_URL" -O quarto.deb
dpkg -i quarto.deb
rm quarto.deb
fi
quarto check install
fi
# Clean up
rm -rf /var/lib/apt/lists/*