forked from btubbs/heroku-buildpack-r
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-r
executable file
·74 lines (49 loc) · 1.9 KB
/
build-r
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
#!/bin/bash
# NOTE: Heroku Cedar stack on Ubuntu 10.04
# gcc needs to be 4.3
# See http://cran.r-project.org/doc/manuals/R-admin.html for details on building R
set -e
rversion="3.0.2"
basedir="$( cd -P "$( dirname "$0" )" && pwd )"
vendordir=/app/vendor
prefix=$vendordir/R
# download dependancies
curl http://gfortran.com/download/x86_64/snapshots/gcc-4.3.tar.xz -o gcc-4.3.tar.xz
# curl http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/glibc_2.7.orig.tar.gz -o glibc_2.7.tar.gz
# download R sources and unpack
curl http://cran.r-project.org/src/base/R-3/R-$rversion.tar.gz -o R-$rversion.tar.gz
tar xzf R-$rversion.tar.gz
# create output directories
mkdir -p $vendordir
mkdir -p $prefix
cd $vendordir
# unpack dependancies (into vendor)
tar xJf $basedir/gcc-4.3.tar.xz
# patch gcc features.h file
# See http://permalink.gmane.org/gmane.comp.gcc.help/40166
cp $basedir/features.h $vendordir/gcc-4.3/lib/gcc/x86_64-unknown-linux-gnu/4.3.6/include-fixed/features.h
# tar xzf $basedir/glibc_2.7.tar.gz && tar xjf $vendordir/glibc-2.7/glibc-2.7.tar.bz2
# R needs to know where gfortran and glibc header files are
export PATH=$vendordir/gcc-4.3/bin:$PATH
export LDFLAGS="-L$vendordir/gcc-4.3/lib64/"
# export CPPFLAGS="-I$vendordir/glibc-2.7/string/ -I$vendordir/glibc-2.7/time"
echo GCC Version: 4.3
echo PATH: $PATH
echo LDFLAGS: $LDFLAGS
# echo CPPFLAGS: $CPPFLAGS
# configure and make R
cd $basedir/R-$rversion/
# Shiny apparently requires X, so we can't --without-x as we might like.
./configure --prefix=$prefix --enable-R-shlib && make && make install
# remove unneeded files to make the output smaller
cd $vendordir
shopt -s extglob
# pushd glibc-2.7 && rm -rf !(string|time) && popd
rm -rf gcc-4.3/info
rm -rf gcc-4.3/man
rm -rf R/lib64/R/doc
rm R/lib64/R/COPYING*
rm R/lib64/R/NEWS*
rm R/lib64/R/SVN-REVISION
# TODO: remove other unneeded files
tar -czf $basedir/R-heroku-$rversion.tar.gz gcc-4.3 R