forked from rocker-org/rocker-versioned2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_julia.sh
executable file
·62 lines (49 loc) · 1.72 KB
/
install_julia.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
#!/bin/bash
set -e
## build ARGs
NCPUS=${NCPUS:--1}
JULIA_VERSION=${1:-${JULIA_VERSION:-latest}}
# a function to install apt packages only if they are not installed
function apt_install() {
if ! dpkg -s "$@" >/dev/null 2>&1; then
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
apt-get update
fi
apt-get install -y --no-install-recommends "$@"
fi
}
ARCH_LONG=$(uname -p)
ARCH_SHORT=$ARCH_LONG
if [ "$ARCH_LONG" = "x86_64" ]; then
ARCH_SHORT="x64"
fi
apt_install wget ca-certificates
install2.r --error --skipmissing --skipinstalled -n "$NCPUS" \
yaml \
JuliaCall \
JuliaConnectoR
# Get the latest Julia version by using R and the R yaml package.
if [ "$JULIA_VERSION" = "latest" ]; then
# shellcheck disable=SC2016
JULIA_VERSION=$(Rscript -e '
js <- yaml::read_yaml("https://julialang-s3.julialang.org/bin/versions.json")
versions <- names(js)
is_stable <- unlist(Map(function(x) x$stable, js))
latest_version <- sort(versions[is_stable], decreasing = TRUE)[1]
cat(latest_version)
')
fi
JULIA_MINOR_VERSION=${JULIA_VERSION%.*}
# Download Julia and create a symbolic link.
wget "https://julialang-s3.julialang.org/bin/linux/${ARCH_SHORT}/${JULIA_MINOR_VERSION}/julia-${JULIA_VERSION}-linux-${ARCH_LONG}.tar.gz"
mkdir /opt/julia
tar zxvf "julia-${JULIA_VERSION}-linux-${ARCH_LONG}.tar.gz" -C /opt/julia --strip-components 1
rm -f "julia-${JULIA_VERSION}-linux-${ARCH_LONG}.tar.gz"
ln -s /opt/julia/bin/julia /usr/local/bin/julia
julia --version
# Clean up
rm -rf /var/lib/apt/lists/*
rm -rf /tmp/downloaded_packages
## Strip binary installed lybraries from RSPM
## https://github.com/rocker-org/rocker-versioned2/issues/340
strip /usr/local/lib/R/site-library/*/libs/*.so