Created
December 26, 2017 13:36
-
-
Save tommarute/60c57f4175a3732636d506ea5fd2e689 to your computer and use it in GitHub Desktop.
Build script for Renv & R 3.3.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
renv_repo_url=https://github.com/viking/Renv.git | |
renv_dir=$HOME/.Renv | |
if [ ! -d "$renv_dir" ]; then | |
git clone $renv_repo_url $renv_dir | |
fi | |
rbuild_repo_url=https://github.com/viking/R-build.git | |
rbuild_dir=$renv_dir/plugins | |
if [ ! -d "$rbuild_dir" ]; then | |
git clone $rbuild_repo_url $rbuild_dir | |
fi | |
cat << 'EOF' >> $HOME/.bash_profile | |
export PATH="$HOME/.Renv/bin:$PATH" | |
eval "$(Renv init -)" | |
export CPPFLAGS="-I$HOME/local/include" | |
export LDFLAGS="-L$HOME/local/lib" | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/local/lib | |
EOF | |
download_dest=$HOME/src | |
install_dest=$HOME/local | |
if [ ! -d "$download_dest" ]; then | |
mkdir $download_dest | |
fi | |
if [ ! -d "$install_dest" ]; then | |
mkdir $install_dest | |
fi | |
pkg_urls=( | |
'https://jaist.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz' \ | |
'http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz' \ | |
'https://tukaani.org/xz/xz-5.2.3.tar.gz' \ | |
'https://jaist.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz' \ | |
'https://curl.haxx.se/download/curl-7.52.1.tar.gz' \ | |
'http://cran.r-project.org/src/base/R-3/R-3.3.2.tar.gz' \ | |
) | |
for url in "${pkg_urls[@]}" | |
do | |
wget $url -P $download_dest | |
done | |
( | |
cd $HOME/src | |
ls | xargs -n 1 -IFILE tar xzvf FILE | |
) | |
cpus=$(cat /proc/cpuinfo | grep processor | wc -l) | |
( | |
cd $download_dest/zlib-1.2.11 | |
./configure --prefix=$install_dest | tee configure.log | |
make -j $cpus | tee make.log | |
make install -j $cpus | tee make-install.log | |
) | |
( | |
cd $download_dest/bzip2-1.0.6 | |
cp Makefile Makefile.org | |
sed -i 's/CFLAGS=-Wall/CFLAGS=-fPIC -Wall/' Makefile | |
make clean | |
make -j $cpus | tee make.log | |
make install -j $cpus PREFIX=$install_dest | tee make-install.log | |
) | |
( | |
cd $download_dest/xz-5.2.3 | |
./configure --prefix=$install_dest | tee configure.log | |
make -j $cpus | tee make.log | |
make install -j $cpus | tee make-install.log | |
) | |
( | |
cd $download_dest/pcre-8.40 | |
./configure --prefix=$install_dest --enable-utf8 | tee configure.log | |
make -j $cpus | tee make.log | |
make install -j $cpus | tee make-install.log | |
) | |
( | |
cd $download_dest/curl-7.52.1 | |
./configure --prefix=$install_dest | tee configure.log | |
make -j $cpus | tee make.log | |
make install -j $cpus | tee make-install.log | |
) | |
source $HOME/.bash_profile | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment