[CentOS] creating RPMs from CRAN tarballs

Fri Jun 5 07:09:57 UTC 2015
Peter <peter at pajamian.dhs.org>

On 06/04/2015 07:49 AM, Tony Schreiner wrote:
> I run R2spec -s tarball  to create a spec file, and most of the time it
> works ok, but sometimes (RPostgresSQL, Rcpp for example) the package has
> test or example programs that  start with
> 
> #!/usr/bin/r
> 
> with lower case r, and the resulting package then winds up with a
> dependency on /usr/bin/r, which can't be resolved.
> 
> So far I have solved it by editing all the files and replacing with
> /usr/bin/R, recreating the tarball and going through the process again, but
> I have to believe there is an easier way.

Kind of.  This is an obvious error in the packaged scripts in the
tarballs.  I generally don't recommend modifying the original tarball as
I like it to be a true representation of the tarball source that you get
from upstream.  What I do instead is patch it in the spec file.

In this case it would probably be easier to do one line of perl or awk
that patches the shebang line in all the scripts at build time than it
would be to generate individual patch files for each source tarball.
You would add this to the %prep stage of the spec files, something like
this after the initial %setup macro:

perl -pi -e 's:^#!/usr/bin/r:#!/usr/bin/R: unless $i++'
path/to/R/scripts/*.R


Peter