[Rd] RPM support for package installation?

Jeffrey J. Hallman jhallman at frb.gov
Thu Feb 8 18:41:48 CET 2007


I feel your pain.  At my workplace, the network administrators insist that
anything that is to be distributed across the network be packaged up in an
RPM.  I have my own library of packages accessible to my section members, but
when I want to make something available to everyone, I have to create an RPM.

After many trials and tribulations, here is the rpm spec file I created for
Prof. Ripley's RODBC package. A few things to note:

1. R-2.4.0 was installed in /opt/r-2.4.0 by an RPM called R-arc
2. I create /opt/r-2.4.0/lib/R/src and unpack the source package there, so
   my users can look at the original code if they want to.
3. The rpm does R CMD INSTALL pkg  twice: once when it is installing the rpm,
   and again in the post-install step. The reason for the second pass is to
   insure that the help index files get rebuilt with all of the packages that
   are installed in the production directory.

My other rpms are similar to this one.  With that, here is the spec file:

-- 
Jeff



%define rversion 2.4.0
%define rtopdir /opt/r-%{rversion}
%define rhome %{rtopdir}/lib/R
%define rbin %{rhome}/bin/R
%define rSourcePackageDir %{rhome}/src
%define rBinaryPackageDir %{rhome}/library
%define arcrel 9

Name: R-rodbc-arc
Version: %{rversion}
Release: 1.1.REV.%{arcrel}
Summary: Package ODBC Interface for R
License: free
Requires: R-arc >= %{rversion}
Provides: R-rodbc
Group: Applications/Engineering
Source0: %{name}-%{version}.tar.gz
Buildroot: /tmp/%{name}-%{version}
%description
CRAN version 1.1-7 of RODBC, an ODBC interface for R.
%prep
%build
%install
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
mkdir -p %{buildroot}%{rBinaryPackageDir}
mkdir -p %{buildroot}%{rSourcePackageDir}
mkdir -p %{buildroot}%{rhome}/doc/html/search
cd %{buildroot}%{rSourcePackageDir}
tar -xzf $RPM_SOURCE_DIR/%{name}-%{version}.tar.gz 
%{rbin} CMD INSTALL -c -l %{buildroot}%{rBinaryPackageDir} RODBC

%files
%defattr(-, mathadm, appgrp)
%{rSourcePackageDir}/*
%{rBinaryPackageDir}/*

%clean
rm -rf %{buildroot}

%post
cd %{rSourcePackageDir}
pwd
%{rbin} CMD INSTALL -c RODBC
chown -R mathadm:appgrp %{rBinaryPackageDir}/RODBC
chown mathadm:appgrp %{rhome}/doc/html/packages.html
chown mathadm:appgrp %{rhome}/doc/html/search/index.txt

%preun



More information about the R-devel mailing list