blob: ddeb2acc3b7a023d39b5c24cebc91d9485cc1f07 [file]
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
set -ex
: ${R_BIN:=R}
# This is where our docker setup puts things; set this to run outside of docker
: ${ARROW_SOURCE_HOME:=/arrow}
# The Dockerfile should have put this file here
if [ -f "${ARROW_SOURCE_HOME}/ci/etc/rprofile" ]; then
# Ensure parallel R package installation, set CRAN repo mirror,
# and use pre-built binaries where possible
cat ${ARROW_SOURCE_HOME}/ci/etc/rprofile >> $(${R_BIN} RHOME)/etc/Rprofile.site
fi
# Ensure parallel compilation of C/C++ code
echo "MAKEFLAGS=-j$(${R_BIN} -s -e 'cat(parallel::detectCores())')" >> $(R RHOME)/etc/Renviron.site
# Figure out what package manager we have
if [ "`which dnf`" ]; then
PACKAGE_MANAGER=dnf
elif [ "`which yum`" ]; then
PACKAGE_MANAGER=yum
elif [ "`which zypper`" ]; then
PACKAGE_MANAGER=zypper
elif [ "`which apk`" ]; then
PACKAGE_MANAGER=apk
else
PACKAGE_MANAGER=apt-get
apt-get update --allow-releaseinfo-change # flag needed for when debian version changes
fi
# Enable ccache if requested based on http://dirk.eddelbuettel.com/blog/2017/11/27/
: ${R_CUSTOM_CCACHE:=FALSE}
R_CUSTOM_CCACHE=`echo $R_CUSTOM_CCACHE | tr '[:upper:]' '[:lower:]'`
if [ ${R_CUSTOM_CCACHE} = "true" ]; then
# install ccache
if [ "$PACKAGE_MANAGER" = "apk" ]; then
$PACKAGE_MANAGER add ccache
else
$PACKAGE_MANAGER install -y epel-release || true
$PACKAGE_MANAGER install -y ccache
fi
mkdir -p ~/.R
echo "VER=
CCACHE=ccache
CC=\$(CCACHE) gcc\$(VER)
CXX=\$(CCACHE) g++\$(VER)
CXX17=\$(CCACHE) g++\$(VER)" >> ~/.R/Makevars
mkdir -p ~/.ccache/
echo "max_size = 5.0G
# important for R CMD INSTALL *.tar.gz as tarballs are expanded freshly -> fresh ctime
sloppiness = include_file_ctime
# also important as the (temp.) directory name will differ
hash_dir = false" >> ~/.ccache/ccache.conf
fi
if [ -f "${ARROW_SOURCE_HOME}/ci/scripts/r_install_system_dependencies.sh" ]; then
"${ARROW_SOURCE_HOME}/ci/scripts/r_install_system_dependencies.sh"
fi
# Install rsync for bundling cpp source and curl to make sure it is installed on all images,
# cmake is now a listed sys req.
if [ "$PACKAGE_MANAGER" = "apk" ]; then
$PACKAGE_MANAGER add rsync cmake curl
else
$PACKAGE_MANAGER install -y rsync cmake curl
fi
# Workaround for html help install failure; see https://github.com/r-lib/devtools/issues/2084#issuecomment-530912786
Rscript -e 'x <- file.path(R.home("doc"), "html"); if (!file.exists(x)) {dir.create(x, recursive=TRUE); file.copy(system.file("html/R.css", package="stats"), x)}'