October 3, 2012

How to generate RPMs from R modules

Today I was setting up a CentOS server with some packages including R and a couple of R modules. R is generally available from third-party repositories like EPEL but its modules must be compiled locally, which requires a lot of dependencies like R-devel and GCC.

As I wanted to keep the number of installed packages as low as possible there was the need to generate RPMs from the R modules allowing me to just install them in the very secure and lightweight server.

After some searching I came across R2spec which is a tool just for what I need. It worked like a charm, but not at first.

For instance, lets see what we need to do in order to generate the randomForest RPM.

# install packages (from the EPEL repository)
yum install R-devel R2spec rpm-build
# create environment
rm -Rf ~/rpmbuild
mkdir -p ~/rpmbuild/SPECS
mkdir -p ~/rpmbuild/SOURCES/
# download and generate spec and rpm
R2rpm -p randomForest --no-suggest --no-check --verbose
# the generated rpm may be found at
ls ~/rpmbuild/RPMS/x86_64/R-randomForest-4.6.6-1.el6.x86_64.rpm
# install rpm in the final machine
rpm -i R-randomForest-4.6.6-1.el6.x86_64.rpm

© Rafael Marmelo 2017