From 0915761e6af8df9db7cb3a54395657a005de3c60 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Tue, 8 Oct 2024 19:24:04 -0700 Subject: [PATCH 1/3] Create install_R_source.sh --- scripts/install_R_source.sh | 174 ++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 scripts/install_R_source.sh diff --git a/scripts/install_R_source.sh b/scripts/install_R_source.sh new file mode 100644 index 0000000..4e5a828 --- /dev/null +++ b/scripts/install_R_source.sh @@ -0,0 +1,174 @@ +#!/bin/bash + +## Install R from source. +## +## In order of preference, first argument of the script, the R_VERSION variable. +## ex. latest, devel, patched, 4.0.0 +## +## 'devel' means the prerelease development version (Latest daily snapshot of development version). +## 'patched' means the prerelease patched version (Latest daily snapshot of patched version). + +set -e + +R_VERSION=${1:-${R_VERSION:-"latest"}} +PURGE_BUILDDEPS=${PURGE_BUILDDEPS:-"true"} + +# shellcheck source=/dev/null +source /etc/os-release + +apt-get update +apt-get -y install locales + +## Configure default locale +LANG=${LANG:-"en_US.UTF-8"} +/usr/sbin/locale-gen --lang "${LANG}" +/usr/sbin/update-locale --reset LANG="${LANG}" + +export DEBIAN_FRONTEND=noninteractive + +R_HOME=${R_HOME:-"/usr/local/lib/R"} + +READLINE_VERSION=8 +if [ "${UBUNTU_CODENAME}" == "bionic" ]; then + READLINE_VERSION=7 +fi + +apt-get install -y --no-install-recommends \ + bash-completion \ + ca-certificates \ + file \ + fonts-texgyre \ + g++ \ + gfortran \ + gsfonts \ + libblas-dev \ + libbz2-* \ + libcurl4 \ + "libicu[0-9][0-9]" \ + liblapack-dev \ + libpcre2* \ + libjpeg-turbo* \ + libpangocairo-* \ + libpng16* \ + "libreadline${READLINE_VERSION}" \ + libtiff* \ + liblzma* \ + libxt6 \ + make \ + tzdata \ + unzip \ + zip \ + zlib1g + +BUILDDEPS="curl \ + default-jdk \ + devscripts \ + libbz2-dev \ + libcairo2-dev \ + libcurl4-openssl-dev \ + libpango1.0-dev \ + libjpeg-dev \ + libicu-dev \ + libpcre2-dev \ + libpng-dev \ + libreadline-dev \ + libtiff5-dev \ + liblzma-dev \ + libx11-dev \ + libxt-dev \ + perl \ + rsync \ + subversion \ + tcl-dev \ + tk-dev \ + texinfo \ + texlive-extra-utils \ + texlive-fonts-recommended \ + texlive-fonts-extra \ + texlive-latex-recommended \ + texlive-latex-extra \ + x11proto-core-dev \ + xauth \ + xfonts-base \ + xvfb \ + wget \ + zlib1g-dev" + +# shellcheck disable=SC2086 +apt-get install -y --no-install-recommends ${BUILDDEPS} + +## Download R from 0-Cloud CRAN mirror or CRAN +function download_r_src() { + wget "https://cloud.r-project.org/src/$1" -O "R.tar.gz" || + wget "https://cran.r-project.org/src/$1" -O "R.tar.gz" +} + +if [ "$R_VERSION" == "devel" ]; then + download_r_src "base-prerelease/R-devel.tar.gz" +elif [ "$R_VERSION" == "patched" ]; then + download_r_src "base-prerelease/R-latest.tar.gz" +elif [ "$R_VERSION" == "latest" ]; then + download_r_src "base/R-latest.tar.gz" +else + download_r_src "base/R-${R_VERSION%%.*}/R-${R_VERSION}.tar.gz" +fi + +tar xzf "R.tar.gz" +cd R-*/ + +R_PAPERSIZE=letter \ + R_BATCHSAVE="--no-save --no-restore" \ + R_BROWSER=xdg-open \ + PAGER=/usr/bin/pager \ + PERL=/usr/bin/perl \ + R_UNZIPCMD=/usr/bin/unzip \ + R_ZIPCMD=/usr/bin/zip \ + R_PRINTCMD=/usr/bin/lpr \ + LIBnn=lib \ + AWK=/usr/bin/awk \ + CFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g" \ + CXXFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g" \ + ./configure --enable-R-shlib \ + --enable-memory-profiling \ + --with-readline \ + --with-blas \ + --with-lapack \ + --with-tcltk \ + --with-recommended-packages + +make +make install +make clean + +## Add a library directory (for user-installed packages) +mkdir -p "${R_HOME}/site-library" +chown root:staff "${R_HOME}/site-library" +chmod g+ws "${R_HOME}/site-library" + +## Fix library path +echo "R_LIBS=\${R_LIBS-'${R_HOME}/site-library:${R_HOME}/library'}" >>"${R_HOME}/etc/Renviron.site" + +## Clean up from R source install +cd .. +rm -rf /tmp/* +rm -rf R-*/ +rm -rf "R.tar.gz" + +## Copy the checkbashisms script to local before remove devscripts package. +## https://github.com/rocker-org/rocker-versioned2/issues/510 +cp /usr/bin/checkbashisms /usr/local/bin/checkbashisms + +# shellcheck disable=SC2086 +if [ "${PURGE_BUILDDEPS}" != "false" ]; then + apt-get remove --purge -y ${BUILDDEPS} +fi +apt-get autoremove -y +apt-get autoclean -y +rm -rf /var/lib/apt/lists/* + +# Check the R info +echo -e "Check the R info...\n" + +R -q -e "sessionInfo()" + +echo -e "\nInstall R from source, done!" From 462b13850380dad1847061544d04c74d6914ca02 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Tue, 8 Oct 2024 19:25:20 -0700 Subject: [PATCH 2/3] Update appendix --- appendix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/appendix b/appendix index b7b0f9e..91f4435 100644 --- a/appendix +++ b/appendix @@ -9,7 +9,12 @@ RUN yes | unminimize ENV MANPATH="${NB_PYTHON_PREFIX}/share/man:${MANPATH}" RUN mandb -RUN chmod +x ${REPO_DIR}/rocker.sh && ${REPO_DIR}/rocker.sh +ENV R_VERSION="4.4.1" +ENV R_HOME="/usr/local/lib/R" +ENV TZ="Etc/UTC" + +COPY scripts/install_R_source.sh /rocker_scripts/install_R_source.sh +RUN /rocker_scripts/install_R_source.sh # Revert to default user USER ${NB_USER} From 5dbc8a08db241acb8d8c257021bbc07c757cb2a3 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Tue, 8 Oct 2024 19:25:58 -0700 Subject: [PATCH 3/3] Update build-dev.yaml --- .github/workflows/build-dev.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-dev.yaml b/.github/workflows/build-dev.yaml index 366e929..1141127 100644 --- a/.github/workflows/build-dev.yaml +++ b/.github/workflows/build-dev.yaml @@ -4,7 +4,7 @@ on: workflow_dispatch: null push: branches: - - dev + - dev2 paths: - 'apt.txt' - 'environment.yml' @@ -12,7 +12,7 @@ on: - 'postBuild' - 'appendix' - 'rocker.sh' - - '.github/workflows/build.yaml' + - '.github/workflows/build-dev.yaml' jobs: build-and-push: