|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# This script sets up the openai/codex-universal docker image |
| 4 | +# with everything needed to run quickr tests. |
| 5 | +# Run this script as the "Setup script" when configuring an environment in |
| 6 | +# https://chatgpt.com/codex/settings/environments, |
| 7 | +# ./scripts/setup_codex.sh |
| 8 | +# |
| 9 | +# More info: |
| 10 | +# https://platform.openai.com/docs/codex/overview#default-universal-image |
| 11 | + |
| 12 | +set -eo pipefail |
| 13 | + |
| 14 | + |
| 15 | +if ! grep -q 'NOT_CRAN=true' ~/.bashrc; then |
| 16 | + echo 'export NOT_CRAN=true' >> ~/.bashrc |
| 17 | +fi |
| 18 | + |
| 19 | +export DEBIAN_FRONTEND=noninteractive |
| 20 | + |
| 21 | +### --- setup instructions from https://cran.r-project.org/bin/linux/ubuntu/#root ---- |
| 22 | +# update indices |
| 23 | +apt update -qq |
| 24 | +# install two helper packages we need |
| 25 | +apt install -y --no-install-recommends software-properties-common dirmngr |
| 26 | +# add the signing key (by Michael Rutter) for these repos |
| 27 | +# To verify key, run gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc |
| 28 | +# Fingerprint: E298A3A825C0D65DFD57CBB651716619E084DAB9 |
| 29 | +wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc |
| 30 | +# add the repo from CRAN -- lsb_release adjusts to 'noble' or 'jammy' or ... as needed |
| 31 | +add-apt-repository -y "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" |
| 32 | +# install R itself |
| 33 | +sudo apt install -y --no-install-recommends r-base |
| 34 | +### --- end setup instructions from https://cran.r-project.org/bin/linux/ubuntu/#root ---- |
| 35 | + |
| 36 | + |
| 37 | +### --- https://raw.githubusercontent.com/eddelbuettel/r2u/master/inst/scripts/add_cranapt_noble.sh --- |
| 38 | +### lightly modified to avoid using gpg, which doesn't use up the codex proxy correctly and errors |
| 39 | +#!/bin/bash |
| 40 | + |
| 41 | +## See the README.md of 'r2u' for details on these steps |
| 42 | +## |
| 43 | +## This script has been tested on a plain and minimal ubuntu:24.04 |
| 44 | +## |
| 45 | +## On a well-connected machine this script should take well under one minute |
| 46 | +## |
| 47 | +## Note that you need to run this as root, or run the whole script via sudo |
| 48 | +## To run individual commands as root, prefix each command with sudo and use |
| 49 | +## 'echo | sudo tee file' as the command before the EOF redirect statement |
| 50 | + |
| 51 | +set -eu |
| 52 | + |
| 53 | +## First: update apt and get keys |
| 54 | +apt update -qq && apt install --yes --no-install-recommends ca-certificates gnupg |
| 55 | +## use gpg directly instead of the now-deprecated apt-key command |
| 56 | +# gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/r2u.gpg --keyserver keyserver.ubuntu.com --recv-keys A1489FE2AB99A21A 67C2D66C4B1D4339 51716619E084DAB9 |
| 57 | +wget -q -O- https://eddelbuettel.github.io/r2u/assets/dirk_eddelbuettel_key.asc \ |
| 58 | + | tee -a /etc/apt/trusted.gpg.d/cranapt_key.asc |
| 59 | + |
| 60 | +## Second: add the repo -- here we use the well-connected mirror |
| 61 | +echo > /etc/apt/sources.list.d/r2u.sources <<EOF |
| 62 | +Types: deb |
| 63 | +URIs: https://r2u.stat.illinois.edu/ubuntu |
| 64 | +Suites: noble |
| 65 | +Components: main |
| 66 | +Arch: amd64, arm64 |
| 67 | +Signed-By: /usr/share/keyrings/r2u.gpg |
| 68 | +EOF |
| 69 | + |
| 70 | +## Third: ensure current R is used |
| 71 | +echo > /etc/apt/sources.list.d/cran.sources <<EOF |
| 72 | +Types: deb |
| 73 | +URIs: https://cloud.r-project.org/bin/linux/ubuntu |
| 74 | +Suites: noble-cran40/ |
| 75 | +Components: |
| 76 | +Arch: amd64, arm64 |
| 77 | +Signed-By: /usr/share/keyrings/r2u.gpg |
| 78 | +EOF |
| 79 | +apt update -qq |
| 80 | +DEBIAN_FRONTEND=noninteractive apt install --yes --no-install-recommends r-base-core |
| 81 | + |
| 82 | +## Fourth: add pinning to ensure package sorting |
| 83 | +echo > /etc/apt/preferences.d/99cranapt <<EOF |
| 84 | +Package: * |
| 85 | +Pin: release o=CRAN-Apt Project |
| 86 | +Pin: release l=CRAN-Apt Packages |
| 87 | +Pin-Priority: 700 |
| 88 | +EOF |
| 89 | + |
| 90 | +## Fifth: install bspm (and its Python requirements) and enable it |
| 91 | +## If needed (in bare container, say) install python tools for bspm and R itself |
| 92 | +apt install --yes --no-install-recommends python3-{dbus,gi,apt} make |
| 93 | +## Then install bspm (as root) and enable it, and enable a speed optimization |
| 94 | +Rscript -e 'install.packages("bspm")' |
| 95 | +echo >> /etc/R/Rprofile.site <<EOF |
| 96 | +suppressMessages(bspm::enable()) |
| 97 | +options(bspm.version.check=FALSE) |
| 98 | +EOF |
| 99 | + |
| 100 | +# Done! |
| 101 | + |
| 102 | +### ---- END https://raw.githubusercontent.com/eddelbuettel/r2u/master/inst/scripts/add_cranapt_noble.sh --- |
| 103 | + |
| 104 | +### Now setup the actual dependencies for the quirckr package |
| 105 | + |
| 106 | +apt-get install -y gfortran gcc |
| 107 | +apt-get install -y --no-install-recommends r-cran-{glue,testthat} |
| 108 | +# apt-get install -y --no-install-recommends r-cran-{dotty,s7} ## not available on r2u noble ?? |
| 109 | +R -q -e 'install.packages(c("dotty", "S7"))' |
| 110 | +apt-get install -y --no-install-recommends r-cran-devtools # not strictly necessary, but pulls in load_all(), cli, ... |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +echo >> ~/.Rprofile <<'EOF' |
| 115 | +options( |
| 116 | + testthat.use_colours = FALSE, Should the output be coloured? (Default: TRUE). |
| 117 | + # testthat.summary.max_reports: The maximum number of detailed test reports printed for the summary reporter (default: 10). |
| 118 | + testthat.summary.omit_dots = TRUE |
| 119 | +) |
| 120 | +EOF |
| 121 | + |
| 122 | +# R -e 'devtools::test()' |
0 commit comments