forked from UCL-RITS/rcps-buildscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
R-package_install
executable file
·65 lines (52 loc) · 1.67 KB
/
R-package_install
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
#!/usr/bin/env bash
###############################################
# Installing a single R additional package
#
# by Brian Alston, October 2016 V1.1
# Updated Dec 2016 to use https://cloud.r-project.org/ as defult repro.
# Updated May 2017 to default to R 3.4.0
# Updated March 2018 to default to R 3.4.2
# Updated October 2018 to default to R 3.5.1
# Updated June 2019 to defULT TO R 3.6.0
#
# usage: R-package_install <R package name>
#
# Will need modules: r/recommended or possibly r/new
set -e
VERSION=${VERSION:-3.6.0}
INSTALL_PREFIX=${INSTALL_PREFIX:-/shared/ucl/apps/R/R-${VERSION}-OpenBLAS}
export RLIB_MAIN=${RLIB_MAIN:-${INSTALL_PREFIX}/lib64/R/library}
export RLIB_DB=${RLIB_DB:-/home/ccspapp/Scratch/R/R-${VERSION}-OpenBLAS/library}
export REPROS=${REPROS:-https://cloud.r-project.org/}
LOCALDIR=${LOCALDIR:-/shared/ucl/apps/build_scripts/files/R_UCL}
export PATH=$INSTALL_PREFIX/bin:$PATH
dirname=$(dirname $0 2>/dev/null || pwd)
INCLUDES_DIR=${INCLUDES_DIR:-${dirname}/includes}
source ${INCLUDES_DIR}/module_maker_inc.sh
source ${INCLUDES_DIR}/require_inc.sh
# require r/recommended
# require r/new
require r/r-3.6.0_bc-3.9
if [ $# -ne 1 ]; then
echo "usage: R-package_install <R package name>"
exit 1
fi
PACKAGE=$1
temp_dir=`mktemp -d -p /dev/shm`
# temp_dir='/home/ccspapp/Software/R'
echo "Building in $temp_dir ..."
cd $temp_dir
module list
read -p "Press [Enter] key to start ..."
cat > R_script <<EOF
mainLib <- Sys.getenv ("RLIB_MAIN");
dbLib <- Sys.getenv ("RLIB_DB");
repros <- Sys.getenv ("REPROS");
mainLib;
dbLib;
repros;
install.packages ("$PACKAGE", lib=mainLib, repos=repros);
EOF
echo "Installing $PACKAGE and dependencies ..."
R --no-save < R_script
echo "Done."