-
Notifications
You must be signed in to change notification settings - Fork 185
/
Copy pathinstall_R.sh
executable file
·165 lines (144 loc) · 4.42 KB
/
install_R.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
set -e
apt-get update && apt-get -y install lsb-release
UBUNTU_VERSION=${UBUNTU_VERSION:-`lsb_release -sc`}
LANG=${LANG:-en_US.UTF-8}
LC_ALL=${LC_ALL:-en_US.UTF-8}
CRAN=${CRAN:-https://cran.r-project.org}
## mechanism to force source installs if we're using RSPM
CRAN_SOURCE=${CRAN/"__linux__/$UBUNTU_VERSION/"/""}
## source install if using RSPM and arm64 image
if [ "$(uname -m)" = "aarch64" ]; then
CRAN=$CRAN_SOURCE
fi
export DEBIAN_FRONTEND=noninteractive
# Set up and install R
R_HOME=${R_HOME:-/usr/local/lib/R}
READLINE_VERSION=8
OPENBLAS=libopenblas-dev
if [ ${UBUNTU_VERSION} == "bionic" ]; then
READLINE_VERSION=7
OPENBLAS=libopenblas-dev
fi
apt-get update \
&& apt-get install -y --no-install-recommends \
bash-completion \
ca-certificates \
devscripts \
file \
fonts-texgyre \
g++ \
gfortran \
gsfonts \
libblas-dev \
libbz2-* \
libcurl4 \
libicu* \
libpcre2* \
libjpeg-turbo* \
${OPENBLAS} \
libpangocairo-* \
libpng16* \
libreadline${READLINE_VERSION} \
libtiff* \
liblzma* \
locales \
make \
unzip \
zip \
zlib1g
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen en_US.utf8
/usr/sbin/update-locale LANG=en_US.UTF-8
BUILDDEPS="curl \
default-jdk \
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"
apt-get install -y --no-install-recommends $BUILDDEPS
if [[ "$R_VERSION" == "devel" ]]; then \
wget https://stat.ethz.ch/R/daily/R-devel.tar.gz; \
elif [[ "$R_VERSION" == "patched" ]]; then \
wget https://stat.ethz.ch/R/daily/R-patched.tar.gz; \
else \
wget https://cran.r-project.org/src/base/R-3/R-${R_VERSION}.tar.gz || \
wget https://cran.r-project.org/src/base/R-4/R-${R_VERSION}.tar.gz; \
fi && \
tar xzf R-${R_VERSION}.tar.gz &&
cd R-${R_VERSION}
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 \
--disable-nls \
--with-recommended-packages
make
make install
make clean
## Add a default CRAN mirror
echo "options(repos = c(CRAN = '${CRAN}'), download.file.method = 'libcurl')" >> ${R_HOME}/etc/Rprofile.site
## Set HTTPUserAgent for RSPM (https://github.com/rocker-org/rocker/issues/400)
echo 'options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(),
paste(getRversion(), R.version$platform,
R.version$arch, R.version$os)))' >> ${R_HOME}/etc/Rprofile.site
## 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
## Use littler installation scripts
Rscript -e "install.packages(c('littler', 'docopt'), repos='${CRAN_SOURCE}')"
ln -s ${R_HOME}/site-library/littler/examples/install2.r /usr/local/bin/install2.r
ln -s ${R_HOME}/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r
ln -s ${R_HOME}/site-library/littler/bin/r /usr/local/bin/r
## Clean up from R source install
cd /
rm -rf /tmp/*
rm -rf R-${R_VERSION}
rm -rf R-${R_VERSION}.tar.gz
apt-get remove --purge -y $BUILDDEPS
apt-get autoremove -y
apt-get autoclean -y
rm -rf /var/lib/apt/lists/*