Skip to content

Commit 6f7c47a

Browse files
Manage TinyTeX installation with Quarto (#814)
* Manage TinyTeX installation with Quarto Add CLI options to `install_quarto.sh` to install, update, add to path, or uninstall TinyTeX Add an option to use Workbench's preinstalled Quarto for TinyTeX management * Add TinyTeX test to Goss Fix usage error * Auto-detect Workbench installed Quarto and use if present * Update product/base/scripts/ubuntu/install_quarto.sh Co-authored-by: Benjamin R. J. Schwedler <[email protected]> * Move Quarto and TinyTeX install to after workbench install in WGCW --------- Co-authored-by: Benjamin R. J. Schwedler <[email protected]>
1 parent 2a40e4f commit 6f7c47a

File tree

12 files changed

+121
-21
lines changed

12 files changed

+121
-21
lines changed

connect/Dockerfile.ubuntu2204

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ARG QUARTO_VERSION=1.4.557
1212
ARG SCRIPTS_DIR=/opt/positscripts
1313

1414
### Install Quarto ###
15-
RUN QUARTO_VERSION=${QUARTO_VERSION} ${SCRIPTS_DIR}/install_quarto.sh \
15+
RUN QUARTO_VERSION=${QUARTO_VERSION} ${SCRIPTS_DIR}/install_quarto.sh --install-tinytex --add-path-tinytex \
1616
&& ln -s /opt/quarto/${QUARTO_VERSION}/bin/quarto /usr/local/bin/quarto
1717

1818
SHELL [ "/bin/bash", "-o", "pipefail", "-c"]

connect/test/goss.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,10 @@ command:
114114
"/usr/local/bin/quarto check --quiet":
115115
title: quarto_check
116116
exit-status: 0
117+
118+
# Ensure TinyTeX is installed
119+
"quarto list tools":
120+
title: quarto_tinytex_installed
121+
exit-status: 0
122+
stderr:
123+
- "/tinytex\\s+Up to date\\s+v\\d{4}\\.\\d{2}\\.\\d{2}\\s+v\\d{4}\\.\\d{2}\\.\\d{2}/"

product/base/Dockerfile.ubuntu2204

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ RUN gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 595E85A6B1
3030
&& chmod +x /tini \
3131
&& ln -s /tini /usr/local/bin/tini
3232

33-
### Install TinyTeX ###
34-
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
35-
RUN curl -sL "https://yihui.org/tinytex/install-bin-unix.sh" | sh \
36-
&& /root/.TinyTeX/bin/*/tlmgr path remove \
37-
&& mv /root/.TinyTeX/ /opt/TinyTeX \
38-
&& /opt/TinyTeX/bin/*/tlmgr option sys_bin /usr/local/bin \
39-
&& /opt/TinyTeX/bin/*/tlmgr path add
40-
4133
### Install R versions ###
4234
RUN R_VERSION=${R_VERSION} ${SCRIPTS_DIR}/install_r.sh \
4335
&& R_VERSION=${R_VERSION_ALT} ${SCRIPTS_DIR}/install_r.sh \

product/base/scripts/ubuntu/install_quarto.sh

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,34 @@ usage() {
1616
echo " QUARTO_VERSION=1.3.340 $0"
1717
echo ""
1818
echo "Options:"
19-
echo " -d, --debug Enable debug output"
20-
echo " -h, --help Print usage and exit"
21-
echo " --prefix Install Quarto to a custom prefix"
22-
echo " Each version of Quarto will have its own subdirectory"
23-
echo " Default: /opt/quarto"
19+
echo " -d, --debug Enable debug output"
20+
echo " -h, --help Print usage and exit"
21+
echo " --prefix Install Quarto to a custom prefix"
22+
echo " Each version of Quarto will have its own subdirectory"
23+
echo " Default: /opt/quarto"
24+
echo " --install-tinytex Install TinyTeX using Quarto"
25+
echo " --add-path-tinytex Add TinyTeX to PATH using Quarto"
26+
echo " --update-tinytex Update TinyTeX using Quarto"
27+
echo " --uninstall-tinytex Uninstall TinyTeX from Quarto"
2428
}
2529

2630

2731
# Set defaults
2832
PREFIX="/opt/quarto"
33+
QUARTO_PATH="${PREFIX}/${QUARTO_VERSION}/bin/quarto"
34+
ADD_PATH_TINYTEX=0
35+
INSTALL_TINYTEX=0
36+
UPDATE_TINYTEX=0
37+
UNINSTALL_TINYTEX=0
38+
IS_WORKBENCH_INSTALLATION=0
2939

30-
OPTIONS=$(getopt -o hdr: --long help,debug,prefix: -- "$@")
40+
# Set Quarto Path to the bundled version in Workbench if it exists
41+
if [ -f "/lib/rstudio-server/bin/quarto/bin/quarto" ]; then
42+
QUARTO_PATH="/lib/rstudio-server/bin/quarto/bin/quarto"
43+
IS_WORKBENCH_INSTALLATION=1
44+
fi
45+
46+
OPTIONS=$(getopt -o hd --long help,debug,prefix:,install-tinytex,add-path-tinytex,update-tinytex,uninstall-tinytex -- "$@")
3147
# shellcheck disable=SC2181
3248
if [[ $? -ne 0 ]]; then
3349
exit 1;
@@ -49,21 +65,37 @@ while true; do
4965
PREFIX="$2"
5066
shift 2
5167
;;
68+
--install-tinytex)
69+
INSTALL_TINYTEX=1
70+
shift
71+
;;
72+
--add-path-tinytex)
73+
ADD_PATH_TINYTEX=1
74+
shift
75+
;;
76+
--update-tinytex)
77+
UPDATE_TINYTEX=1
78+
shift
79+
;;
80+
--uninstall-tinytex)
81+
UNINSTALL_TINYTEX=1
82+
shift
83+
;;
5284
--) shift;
5385
break
5486
;;
5587
esac
5688
done
5789

58-
if [ -z "$QUARTO_VERSION" ]; then
90+
if [ -z "$QUARTO_VERSION" ] && [[ "$IS_WORKBENCH_INSTALLATION" -eq 0 ]]; then
5991
usage
6092
exit 1
6193
fi
6294

6395
install_quarto() {
6496
# Check if Quarto is already installed
6597
# shellcheck disable=SC2086
66-
if ${PREFIX}/${QUARTO_VERSION}/bin/quarto --version | grep -qE "^${QUARTO_VERSION}" ; then
98+
if $QUARTO_PATH --version | grep -qE "^${QUARTO_VERSION}" ; then
6799
echo "$d Quarto $QUARTO_VERSION is already installed in $PREFIX/$QUARTO_VERSION $d"
68100
return
69101
fi
@@ -72,4 +104,33 @@ install_quarto() {
72104
wget -q -O - "https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.tar.gz" | tar xzf - -C "/opt/quarto/${QUARTO_VERSION}" --strip-components=1
73105
}
74106

75-
install_quarto
107+
update_tinytex() {
108+
$QUARTO_PATH update tinytex --no-prompt
109+
}
110+
111+
uninstall_tinytex() {
112+
$QUARTO_PATH uninstall tinytex --no-prompt
113+
}
114+
115+
install_tinytex() {
116+
uninstall_tinytex
117+
if [[ "$ADD_PATH_TINYTEX" -eq 1 ]]; then
118+
$QUARTO_PATH install tinytex --update-path --no-prompt
119+
else
120+
$QUARTO_PATH install tinytex --no-prompt
121+
fi
122+
}
123+
124+
if [[ "$IS_WORKBENCH_INSTALLATION" -eq 0 ]]; then
125+
# Skip installation if Quarto is bundled with Workbench
126+
install_quarto
127+
fi
128+
if [[ "$INSTALL_TINYTEX" -eq 1 ]]; then
129+
install_tinytex
130+
fi
131+
if [[ "$UPDATE_TINYTEX" -eq 1 ]]; then
132+
update_tinytex
133+
fi
134+
if [[ "$UNINSTALL_TINYTEX" -eq 1 ]]; then
135+
uninstall_tinytex
136+
fi

r-session-complete/Dockerfile.ubuntu2204

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ RUN apt-get update \
4040
### Install Quarto to PATH ###
4141
RUN ln -s /lib/rstudio-server/bin/quarto/bin/quarto /usr/local/bin/quarto
4242

43+
### Install TinyTeX using Quarto ###
44+
RUN $SCRIPTS_DIR/install_quarto.sh --install-tinytex --add-path-tinytex
45+
4346
COPY maybe_install_vs_code.sh /tmp/maybe_install_vs_code.sh
4447
RUN /tmp/maybe_install_vs_code.sh \
4548
&& rm /tmp/maybe_install_vs_code.sh

r-session-complete/test/goss.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,10 @@ command:
6060
"/usr/local/bin/quarto check --quiet":
6161
title: quarto_check
6262
exit-status: 0
63+
64+
# Ensure TinyTeX is installed
65+
"quarto list tools":
66+
title: quarto_tinytex_installed
67+
exit-status: 0
68+
stderr:
69+
- "/tinytex\\s+Up to date\\s+v\\d{4}\\.\\d{2}\\.\\d{2}\\s+v\\d{4}\\.\\d{2}\\.\\d{2}/"

workbench-for-google-cloud-workstations/Dockerfile.ubuntu2204

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ ENV LANG en_US.UTF-8
6969
ENV LANGUAGE en_US:en
7070
ENV LC_ALL en_US.UTF-8
7171

72-
### Install Quarto to PATH ###
73-
RUN ln -s /lib/rstudio-server/bin/quarto/bin/quarto /usr/local/bin/quarto
74-
7572
### Install Pro Drivers ###
7673
RUN ${SCRIPTS_DIR}/apt.sh --update upgrade \
7774
&& ${SCRIPTS_DIR}/apt.sh install unixodbc unixodbc-dev \
@@ -99,6 +96,12 @@ RUN curl -o rstudio-workbench.deb "${RSW_DOWNLOAD_URL}/${RSW_NAME}-${RSW_VERSION
9996
&& rm -rf /var/lib/apt/lists/* \
10097
&& rm -rf /var/lib/rstudio-server/r-versions
10198

99+
### Install Quarto to PATH ###
100+
RUN ln -s /lib/rstudio-server/bin/quarto/bin/quarto /usr/local/bin/quarto
101+
102+
### Install TinyTeX using Quarto ###
103+
RUN $SCRIPTS_DIR/install_quarto.sh --install-tinytex --add-path-tinytex
104+
102105
# Workaround to ensure no pre-generated certificates are included in image distributions.
103106
# This happens in the step immediately following Workbench installation in case the certificates are generated.
104107
RUN rm -f /etc/rstudio/launcher.pem /etc/rstudio/launcher.pub

workbench-for-google-cloud-workstations/test/goss.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,10 @@ command:
233233
"/usr/local/bin/quarto check --quiet":
234234
title: quarto_check
235235
exit-status: 0
236+
237+
# Ensure TinyTeX is installed
238+
"quarto list tools":
239+
title: quarto_tinytex_installed
240+
exit-status: 0
241+
stderr:
242+
- "/tinytex\\s+Up to date\\s+v\\d{4}\\.\\d{2}\\.\\d{2}\\s+v\\d{4}\\.\\d{2}\\.\\d{2}/"

workbench-for-microsoft-azure-ml/Dockerfile.ubuntu2204

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ RUN rm -f /etc/rstudio/launcher.pem /etc/rstudio/launcher.pub
6868
### Install Quarto to PATH ###
6969
RUN ln -s /lib/rstudio-server/bin/quarto/bin/quarto /usr/local/bin/quarto
7070

71+
### Install TinyTeX using Quarto ###
72+
RUN $SCRIPTS_DIR/install_quarto.sh --install-tinytex --add-path-tinytex
73+
7174
COPY --chmod=0755 license-manager-shim /opt/rstudio-license/license-manager
7275
COPY --chmod=0775 startup.sh /usr/local/bin/startup.sh
7376
COPY startup/* /startup/base/

workbench-for-microsoft-azure-ml/test/goss.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,10 @@ command:
151151
"/usr/local/bin/quarto check --quiet":
152152
title: quarto_check
153153
exit-status: 0
154+
155+
# Ensure TinyTeX is installed
156+
"quarto list tools":
157+
title: quarto_tinytex_installed
158+
exit-status: 0
159+
stderr:
160+
- "/tinytex\\s+Up to date\\s+v\\d{4}\\.\\d{2}\\.\\d{2}\\s+v\\d{4}\\.\\d{2}\\.\\d{2}/"

workbench/Dockerfile.ubuntu2204

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ RUN rm -f /etc/rstudio/launcher.pem /etc/rstudio/launcher.pub
7070
### Install Quarto to PATH ###
7171
RUN ln -s /lib/rstudio-server/bin/quarto/bin/quarto /usr/local/bin/quarto
7272

73+
### Install TinyTeX using Quarto ###
74+
RUN $SCRIPTS_DIR/install_quarto.sh --install-tinytex --add-path-tinytex
75+
7376
COPY maybe_install_vs_code.sh /tmp/maybe_install_vs_code.sh
7477
RUN /tmp/maybe_install_vs_code.sh \
7578
&& rm /tmp/maybe_install_vs_code.sh

workbench/test/goss.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,10 @@ command:
148148
"/usr/local/bin/quarto check --quiet":
149149
title: quarto_check
150150
exit-status: 0
151+
152+
# Ensure TinyTeX is installed
153+
"quarto list tools":
154+
title: quarto_tinytex_installed
155+
exit-status: 0
156+
stderr:
157+
- "/tinytex\\s+Up to date\\s+v\\d{4}\\.\\d{2}\\.\\d{2}\\s+v\\d{4}\\.\\d{2}\\.\\d{2}/"

0 commit comments

Comments
 (0)