Hints for building GNU R packages
This page assembles some hints about GNU R packages.
An upstream R package FooBar in CRAN can be packaged as the debian package r-cran-foobar (or r-bioc-foobar for a package in Bioconductor). Note the change of case (debian package names are all-lowercase).
Debian-packaged R libraries are installed into /usr/lib/R/site-library. They can be imported and used as normal in R (library("FooBar")), except that they are read-only, and hence cannot be updated by the user using R's built-in mechanisms.
Libraries installed in a user's home directory will take precedence over debian-packaged libraries in site-library by default.
Debhelper packaging
`dh-r`
The package dh-r provides a scripts for creating and building Debian packages from R packages. The script prepare_missing_cran_package retrieves a CRAN or Bioconductor source package and generates a suitable git repository including a debian/ directory and the necessary files. Manually checking and slight adjustments are required.
Create Debian package git repo with `prepare_missing_cran_package`
Prior to running prepare_missing_cran_package in a Debian unstable environment, a few steps are required.
Set the environment variables DEBEMAIL and DEBFULLNAME for example by editing ~\.bashrc and adding the following lines:
DEBEMAIL="your@email.you" DEBFULLNAME="Full Name"
- Ensure git is configured, at a minimum with your name and e-mail address:
sudo git config --global user.email "your@email.you" sudo git config --global user.name "Full Name"
- Ensure the owner privileges of the /home/CRAN_prospective directory is for your user, e.g.
mkdir /home/CRAN_prospective sudo chown user:user /home/CRAN_prospective
Then, you can run:
prepare_missing_cran_package FooBar
Inspect the results, including the contents of the debian directory. Instances "FIXME" need manual intervention. In particular, verify that debian/copyright is accurate by comparing to the R package's DESCRIPTION file.
dh-r generates substitution variables for R dependencies, so your binary package stanza in debian/control should use ${R:Depends}, ${R:Recommends} and ${R:Suggests}. These will be generated at build-time based on the available package list (warnings will be shown for R package names which do not appear to have a corresponding debian package).
File an ITP bug
Prior to uploading a new package to Debian, an Intent to Package needs to be reported. This can be done manually in the usual way, or with the itp_from_debian_dir script provided with dh-r. Run this from the R package directory created by prepare_missing_cran_package (the directory that contains the debian directory).
Add to Debian Salsa
Once the Debian source package repository is created, it needs to be uploaded to Salsa. You will need to be granted permission, which you can request from the debian-r mailing list.
A helper script to automate the upload to Salsa can be used.
Specifics of GNU R packages
RData files (*.rda) in source packages
It seems to be a frequently discussed topic between R package maintainers and ftpmaster that several R packages are containing RData files which somehow are looking like binary files without source for people not familiar with R. However, for people who are working with R this is a non-issue because these so called serialized R objects can be input and manipulated in R by humans, I guess in the same way that png files can be edited using image manipulation programs.
There is some decision on R datasets from ftpmaster that adds some requirements the maintainer needs to check in case the upstream source contains RDate files.
Relevant hint: Since GNU R upstream sources are usually quite good documented in very many cases the according RData files are documented inside the docs. It is a very good idea to grep for the file name of the files and check the according hits whether all questions you need to answer are just answered there.
Usage of the ${R:Depends} variable
In 659163 the ${R:Depends} variable was used to simplify the versioned dependency in R packages. It seems that the current implementation which contains a hardcoded dependency to the version of the r-base-dev package:
dpkg-query -W -f='$${Version}' r-base-devunder some circumstances creates to strict dependencies which in turn requires a rebuild of packages that could be avoided if the variable would simply regard an R API version like it was originally suggested:
R --version | head -n1 | perl -ne 'print / +([0-9]\.[0-9]+\.[0-9])/'
In dh-r, ${R:Depends} will include both a dependency on R and any R packages listed in DESCRIPTION as dependencies.
