Merge pull request #151 from rstudio/custom-install-path
Support custom installation paths for R
This commit is contained in:
commit
b67a78e39e
14 changed files with 109 additions and 46 deletions
45
README.md
45
README.md
|
|
@ -184,6 +184,51 @@ This repository orchestrates builds using a variety of tools. The
|
|||
instructions below outline the components in the stack and describe how to add a
|
||||
new platform or inspect an existing platform.
|
||||
|
||||
## Building from source
|
||||
|
||||
To build the R binaries from source, you will need to have [Git](https://git-scm.com/),
|
||||
[Docker](https://docs.docker.com/get-docker/), and `make` installed.
|
||||
|
||||
First, clone the Git repository locally and navigate to it.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/rstudio/R-builds
|
||||
cd R-builds
|
||||
```
|
||||
|
||||
Then, run the `build-r-$PLATFORM` Make target with the `R_VERSION` environment variable
|
||||
set to your desired R version, where `$PLATFORM` is one of the supported platform
|
||||
identifiers, such as `ubuntu-2204` or `rhel-9`.
|
||||
|
||||
```bash
|
||||
export PLATFORM=ubuntu-2204
|
||||
export R_VERSION=4.1.3
|
||||
|
||||
make build-r-$PLATFORM
|
||||
```
|
||||
|
||||
The built DEB or RPM package will be available in the `builder/integration/tmp/$PLATFORM`
|
||||
directory.
|
||||
|
||||
```bash
|
||||
$ ls builder/integration/tmp/$PLATFORM
|
||||
r-4.1.3_1_amd64.deb
|
||||
```
|
||||
|
||||
### Custom installation path
|
||||
|
||||
R is installed to `/opt/R/${R_VERSION}` by default. If you want to customize the
|
||||
installation path, set the optional `R_INSTALL_PATH` environment variable to a
|
||||
custom location such as `/opt/custom/R-4.1.3`.
|
||||
|
||||
```bash
|
||||
export PLATFORM=rhel-9
|
||||
export R_VERSION=4.1.3
|
||||
export R_INSTALL_PATH=/opt/custom/R-4.1.3
|
||||
|
||||
make build-r-$PLATFORM
|
||||
```
|
||||
|
||||
## Adding a new platform.
|
||||
|
||||
### Dockerfile
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ export CRAN=${CRAN-"https://cran.rstudio.com"}
|
|||
export S3_BUCKET_PREFIX=${S3_BUCKET_PREFIX-""}
|
||||
export OS_IDENTIFIER=${OS_IDENTIFIER-"unknown"}
|
||||
export TARBALL_NAME="R-${R_VERSION}-${OS_IDENTIFIER}.tar.gz"
|
||||
export R_INSTALL_PATH=${R_INSTALL_PATH:-"/opt/R/${R_VERSION}"}
|
||||
|
||||
# Some Dockerfiles may copy a `/env.sh` to set up environment variables
|
||||
# that require command substitution. If this file exists, source it.
|
||||
|
|
@ -33,9 +34,11 @@ upload_r() {
|
|||
fi
|
||||
}
|
||||
|
||||
# archive_r() - $1 as r version
|
||||
# archive_r()
|
||||
archive_r() {
|
||||
tar czf /tmp/${TARBALL_NAME} --directory=/opt/R ${1} --owner=0 --group=0
|
||||
dir=$(dirname "$R_INSTALL_PATH")
|
||||
base=$(basename "$R_INSTALL_PATH")
|
||||
tar czf "/tmp/${TARBALL_NAME}" --directory="$dir" "$base" --owner=0 --group=0
|
||||
}
|
||||
|
||||
fetch_r_source() {
|
||||
|
|
@ -130,7 +133,7 @@ compile_r() {
|
|||
R_UNZIPCMD=/usr/bin/unzip \
|
||||
R_ZIPCMD=/usr/bin/zip \
|
||||
./configure \
|
||||
--prefix=/opt/R/${1} \
|
||||
--prefix="${R_INSTALL_PATH}" \
|
||||
${CONFIGURE_OPTIONS} \
|
||||
${build_flag}
|
||||
make clean
|
||||
|
|
@ -139,7 +142,7 @@ compile_r() {
|
|||
|
||||
# Add OS identifier to the default HTTP user agent.
|
||||
# Set this in the system Rprofile so it works when R is run with --vanilla.
|
||||
cat <<EOF >> /opt/R/${1}/lib/R/library/base/R/Rprofile
|
||||
cat <<EOF >> "${R_INSTALL_PATH}"/lib/R/library/base/R/Rprofile
|
||||
## Set the default HTTP user agent
|
||||
local({
|
||||
os_identifier <- if (file.exists("/etc/os-release")) {
|
||||
|
|
@ -167,7 +170,7 @@ package_r() {
|
|||
}
|
||||
|
||||
set_up_environment() {
|
||||
mkdir -p /opt/R
|
||||
mkdir -p "$R_INSTALL_PATH"
|
||||
}
|
||||
|
||||
_version_is_greater_than() {
|
||||
|
|
@ -183,5 +186,5 @@ set_up_environment
|
|||
fetch_r_source $R_VERSION
|
||||
compile_r $R_VERSION
|
||||
package_r $R_VERSION
|
||||
archive_r $R_VERSION
|
||||
archive_r
|
||||
upload_r $R_VERSION
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ services:
|
|||
command: ./build.sh
|
||||
environment:
|
||||
- R_VERSION=${R_VERSION}
|
||||
- R_INSTALL_PATH=${R_INSTALL_PATH}
|
||||
- LOCAL_STORE=/tmp/output
|
||||
build:
|
||||
context: .
|
||||
|
|
@ -14,6 +15,7 @@ services:
|
|||
command: ./build.sh
|
||||
environment:
|
||||
- R_VERSION=${R_VERSION}
|
||||
- R_INSTALL_PATH=${R_INSTALL_PATH}
|
||||
- LOCAL_STORE=/tmp/output
|
||||
build:
|
||||
context: .
|
||||
|
|
@ -25,6 +27,7 @@ services:
|
|||
command: ./build.sh
|
||||
environment:
|
||||
- R_VERSION=${R_VERSION}
|
||||
- R_INSTALL_PATH=${R_INSTALL_PATH}
|
||||
- LOCAL_STORE=/tmp/output
|
||||
build:
|
||||
context: .
|
||||
|
|
@ -36,6 +39,7 @@ services:
|
|||
command: ./build.sh
|
||||
environment:
|
||||
- R_VERSION=${R_VERSION}
|
||||
- R_INSTALL_PATH=${R_INSTALL_PATH}
|
||||
- LOCAL_STORE=/tmp/output
|
||||
build:
|
||||
context: .
|
||||
|
|
@ -47,6 +51,7 @@ services:
|
|||
command: ./build.sh
|
||||
environment:
|
||||
- R_VERSION=${R_VERSION}
|
||||
- R_INSTALL_PATH=${R_INSTALL_PATH}
|
||||
- LOCAL_STORE=/tmp/output
|
||||
build:
|
||||
context: .
|
||||
|
|
@ -58,6 +63,7 @@ services:
|
|||
command: ./build.sh
|
||||
environment:
|
||||
- R_VERSION=${R_VERSION}
|
||||
- R_INSTALL_PATH=${R_INSTALL_PATH}
|
||||
- LOCAL_STORE=/tmp/output
|
||||
build:
|
||||
context: .
|
||||
|
|
@ -69,6 +75,7 @@ services:
|
|||
command: ./build.sh
|
||||
environment:
|
||||
- R_VERSION=${R_VERSION}
|
||||
- R_INSTALL_PATH=${R_INSTALL_PATH}
|
||||
- LOCAL_STORE=/tmp/output
|
||||
build:
|
||||
context: .
|
||||
|
|
@ -80,6 +87,7 @@ services:
|
|||
command: ./build.sh
|
||||
environment:
|
||||
- R_VERSION=${R_VERSION}
|
||||
- R_INSTALL_PATH=${R_INSTALL_PATH}
|
||||
- LOCAL_STORE=/tmp/output
|
||||
build:
|
||||
context: .
|
||||
|
|
@ -91,6 +99,7 @@ services:
|
|||
command: ./build.sh
|
||||
environment:
|
||||
- R_VERSION=${R_VERSION}
|
||||
- R_INSTALL_PATH=${R_INSTALL_PATH}
|
||||
- LOCAL_STORE=/tmp/output
|
||||
build:
|
||||
context: .
|
||||
|
|
@ -102,6 +111,7 @@ services:
|
|||
command: ./build.sh
|
||||
environment:
|
||||
- R_VERSION=${R_VERSION}
|
||||
- R_INSTALL_PATH=${R_INSTALL_PATH}
|
||||
- LOCAL_STORE=/tmp/output
|
||||
build:
|
||||
context: .
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ fi
|
|||
|
||||
# create post-install script required for openblas
|
||||
cat <<EOF >> /post-install.sh
|
||||
mv /opt/R/${R_VERSION}/lib/R/lib/libRblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so.keep
|
||||
ln -s /usr/lib64/libopenblasp.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so
|
||||
mv ${R_INSTALL_PATH}/lib/R/lib/libRblas.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so.keep
|
||||
ln -s /usr/lib64/libopenblasp.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so
|
||||
EOF
|
||||
|
||||
# create after-remove script to remove internal blas
|
||||
cat <<EOF >> /after-remove.sh
|
||||
if [ -d /opt/R/${R_VERSION} ]; then
|
||||
rm -r /opt/R/${R_VERSION}
|
||||
if [ -d ${R_INSTALL_PATH} ]; then
|
||||
rm -r ${R_INSTALL_PATH}
|
||||
fi
|
||||
EOF
|
||||
|
||||
|
|
@ -60,8 +60,8 @@ depends:
|
|||
- zip
|
||||
- zlib-devel
|
||||
contents:
|
||||
- src: /opt/R/${R_VERSION}
|
||||
dst: /opt/R/${R_VERSION}
|
||||
- src: ${R_INSTALL_PATH}
|
||||
dst: ${R_INSTALL_PATH}
|
||||
scripts:
|
||||
postinstall: /post-install.sh
|
||||
postremove: /after-remove.sh
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ fi
|
|||
|
||||
# create post-install script required for openblas
|
||||
cat <<EOF >> /post-install.sh
|
||||
mv /opt/R/${R_VERSION}/lib/R/lib/libRblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so.keep
|
||||
ln -s /usr/lib64/libopenblasp.so.0 /opt/R/${R_VERSION}/lib/R/lib/libRblas.so
|
||||
mv ${R_INSTALL_PATH}/lib/R/lib/libRblas.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so.keep
|
||||
ln -s /usr/lib64/libopenblasp.so.0 ${R_INSTALL_PATH}/lib/R/lib/libRblas.so
|
||||
EOF
|
||||
|
||||
# create after-remove script to remove internal blas
|
||||
cat <<EOF >> /after-remove.sh
|
||||
if [ -d /opt/R/${R_VERSION} ]; then
|
||||
rm -r /opt/R/${R_VERSION}
|
||||
if [ -d ${R_INSTALL_PATH} ]; then
|
||||
rm -r ${R_INSTALL_PATH}
|
||||
fi
|
||||
EOF
|
||||
|
||||
|
|
@ -60,8 +60,8 @@ depends:
|
|||
- zip
|
||||
- zlib-devel
|
||||
contents:
|
||||
- src: /opt/R/${R_VERSION}
|
||||
dst: /opt/R/${R_VERSION}
|
||||
- src: ${R_INSTALL_PATH}
|
||||
dst: ${R_INSTALL_PATH}
|
||||
scripts:
|
||||
postinstall: /post-install.sh
|
||||
postremove: /after-remove.sh
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ depends:
|
|||
- zip
|
||||
- zlib1g-dev
|
||||
contents:
|
||||
- src: /opt/R/${R_VERSION}
|
||||
dst: /opt/R/${R_VERSION}
|
||||
- src: ${R_INSTALL_PATH}
|
||||
dst: ${R_INSTALL_PATH}
|
||||
EOF
|
||||
|
||||
nfpm package \
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ ${pcre_libs}
|
|||
- zip
|
||||
- zlib1g-dev
|
||||
contents:
|
||||
- src: /opt/R/${R_VERSION}
|
||||
dst: /opt/R/${R_VERSION}
|
||||
- src: ${R_INSTALL_PATH}
|
||||
dst: ${R_INSTALL_PATH}
|
||||
EOF
|
||||
|
||||
nfpm package \
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ fi
|
|||
|
||||
# create post-install script required for openblas
|
||||
cat <<EOF >> /post-install.sh
|
||||
mv /opt/R/${R_VERSION}/lib/R/lib/libRblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so.keep
|
||||
ln -s /usr/lib64/libopenblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so
|
||||
mv ${R_INSTALL_PATH}/lib/R/lib/libRblas.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so.keep
|
||||
ln -s /usr/lib64/libopenblas.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so
|
||||
EOF
|
||||
|
||||
# create after-remove script to remove internal blas
|
||||
cat <<EOF >> /after-remove.sh
|
||||
if [ -d /opt/R/${R_VERSION} ]; then
|
||||
rm -r /opt/R/${R_VERSION}
|
||||
if [ -d ${R_INSTALL_PATH} ]; then
|
||||
rm -r ${R_INSTALL_PATH}
|
||||
fi
|
||||
EOF
|
||||
|
||||
|
|
@ -69,8 +69,8 @@ depends:
|
|||
- zip
|
||||
- zlib-devel
|
||||
contents:
|
||||
- src: /opt/R/${R_VERSION}
|
||||
dst: /opt/R/${R_VERSION}
|
||||
- src: ${R_INSTALL_PATH}
|
||||
dst: ${R_INSTALL_PATH}
|
||||
scripts:
|
||||
postinstall: /post-install.sh
|
||||
postremove: /after-remove.sh
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ fi
|
|||
#
|
||||
# https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Shared-BLAS
|
||||
cat <<EOF >> /post-install.sh
|
||||
mv /opt/R/${R_VERSION}/lib/R/lib/libRblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so.keep
|
||||
ln -s /usr/lib64/libopenblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so
|
||||
mv ${R_INSTALL_PATH}/lib/R/lib/libRblas.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so.keep
|
||||
ln -s /usr/lib64/libopenblas.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so
|
||||
EOF
|
||||
|
||||
# Create after-remove script to remove internal BLAS, which won't be cleaned up automatically.
|
||||
cat <<EOF >> /after-remove.sh
|
||||
if [ -d /opt/R/${R_VERSION} ]; then
|
||||
rm -r /opt/R/${R_VERSION}
|
||||
if [ -d ${R_INSTALL_PATH} ]; then
|
||||
rm -r ${R_INSTALL_PATH}
|
||||
fi
|
||||
EOF
|
||||
|
||||
|
|
@ -85,8 +85,8 @@ depends:
|
|||
- zip
|
||||
- zlib-devel
|
||||
contents:
|
||||
- src: /opt/R/${R_VERSION}
|
||||
dst: /opt/R/${R_VERSION}
|
||||
- src: ${R_INSTALL_PATH}
|
||||
dst: ${R_INSTALL_PATH}
|
||||
scripts:
|
||||
postinstall: /post-install.sh
|
||||
postremove: /after-remove.sh
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@ fi
|
|||
#
|
||||
# https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Shared-BLAS
|
||||
cat <<EOF >> /post-install.sh
|
||||
mv /opt/R/${R_VERSION}/lib/R/lib/libRblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so.keep
|
||||
ln -s /usr/lib64/libopenblasp.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so
|
||||
mv ${R_INSTALL_PATH}/lib/R/lib/libRblas.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so.keep
|
||||
ln -s /usr/lib64/libopenblasp.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so
|
||||
EOF
|
||||
|
||||
# Create after-remove script to remove internal BLAS, which won't be cleaned up automatically.
|
||||
cat <<EOF >> /after-remove.sh
|
||||
if [ -d /opt/R/${R_VERSION} ]; then
|
||||
rm -r /opt/R/${R_VERSION}
|
||||
if [ -d ${R_INSTALL_PATH} ]; then
|
||||
rm -r ${R_INSTALL_PATH}
|
||||
fi
|
||||
EOF
|
||||
|
||||
|
|
@ -77,8 +77,8 @@ ${pcre_libs}
|
|||
- zip
|
||||
- zlib-devel
|
||||
contents:
|
||||
- src: /opt/R/${R_VERSION}
|
||||
dst: /opt/R/${R_VERSION}
|
||||
- src: ${R_INSTALL_PATH}
|
||||
dst: ${R_INSTALL_PATH}
|
||||
scripts:
|
||||
postinstall: /post-install.sh
|
||||
postremove: /after-remove.sh
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ depends:
|
|||
- zip
|
||||
- zlib1g-dev
|
||||
contents:
|
||||
- src: /opt/R/${R_VERSION}
|
||||
dst: /opt/R/${R_VERSION}
|
||||
- src: ${R_INSTALL_PATH}
|
||||
dst: ${R_INSTALL_PATH}
|
||||
EOF
|
||||
|
||||
nfpm package \
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ depends:
|
|||
- zip
|
||||
- zlib1g-dev
|
||||
contents:
|
||||
- src: /opt/R/${R_VERSION}
|
||||
dst: /opt/R/${R_VERSION}
|
||||
- src: ${R_INSTALL_PATH}
|
||||
dst: ${R_INSTALL_PATH}
|
||||
EOF
|
||||
|
||||
nfpm package \
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ ${pcre_libs}
|
|||
- zip
|
||||
- zlib1g-dev
|
||||
contents:
|
||||
- src: /opt/R/${R_VERSION}
|
||||
dst: /opt/R/${R_VERSION}
|
||||
- src: ${R_INSTALL_PATH}
|
||||
dst: ${R_INSTALL_PATH}
|
||||
EOF
|
||||
|
||||
nfpm package \
|
||||
|
|
|
|||
|
|
@ -101,3 +101,8 @@ if (getRversion() >= "3.5.0" && getRversion() < "4.0.0") {
|
|||
} else if (getRversion() >= "4.0.0") {
|
||||
stopifnot(has_pcre2 && !has_pcre1)
|
||||
}
|
||||
|
||||
# Check that the custom HTTP user agent was configured
|
||||
if (!grepl(sprintf("^R/%s", getRversion()), getOption("HTTPUserAgent"))) {
|
||||
stop("unexpected HTTPUserAgent")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue