R package guidelines
32-bit – CLR – CMake – Cross – DKMS – Eclipse – Electron – Font – Free Pascal – GNOME – Go – Haskell – Java – KDE – Kernel – Lisp – Meson – MinGW – Node.js – Nonfree – OCaml – Perl – PHP – Python – R – Ruby – Rust – Shell – VCS – Web – Wine
This document covers standards and guidelines on writing PKGBUILDs for R packages. Most information can be obtained by looking at the package's DESCRIPTION
file. You can get most of this from inside R by running tools::CRAN_package_db()
. You could also visit CRAN, Bioconductor link1, and Bioconductor link2 for all the R packages' information.
Package naming
Packages should be named r-pkgname
, where pkgname is taken from the Package
field from the DESCRIPTION
file.
The package name should be lowercase.
Package Version
Take it from the Version
field. R allows packages to have colons and hyphens in their version, this is disallowed in PKGBUILDs. Convert these to a period or underscore.
Arch
See PKGBUILD#arch. If the package's CRAN webpage has NeedsCompilation: yes
it is likely architecture-specific. Otherwise, it is likely not.
Dependencies
R packages listed in Depends
, Imports
, or the LinkingTo
fields in a package's DESCRIPTION
file should be listed under depends.
R packages listed in Suggests
should be listed as optdepends.
Some packages require external tools, these are listed under SystemRequirements
.
gcc-fortran is needed as depends for some packages but is not always listed in the DESCRIPTION
file.
Source
All R packages available on CRAN are available at the website https://cran.r-project.org/src/contrib/cranname_cranversion.tar.gz
where cranname
is the name of the package on CRAN and cranversion
the cran version.
R packages avalable on Bioconductor are available at the website https://bioconductor.org/packages/release/bioc/src/contrib/bcname_bcname.tar.gz
or https://bioconductor.org/packages/release/data/annotation/src/contrib/bcname_bcname.tar.gz
where bcname
is the name of the package on Bioconductor and bcver
the version.
Build and Package
R has built-in support for building packages. Here are two templates of PKGBUILD
s for two repositories: CRAN and Bioconductor.
CRAN
_cranname= _cranver= pkgname=r-${_cranname,,} pkgver=${_cranver//[:-]/.} pkgrel=1 pkgdesc="" arch=() url="https://cran.r-project.org/package=${_cranname}" license=() depends=(r) makedepends=() optdepends=() source=("https://cran.r-project.org/src/contrib/${_cranname}_${_cranver}.tar.gz") sha256sums=() build() { R CMD INSTALL ${_cranname}_${_cranver}.tar.gz -l "${srcdir}" } package() { install -dm0755 "${pkgdir}/usr/lib/R/library" cp -a --no-preserve=ownership "${_cranname}" "${pkgdir}/usr/lib/R/library" }
Bioconductor
_bcname= _bcver= pkgname=r-${_bcname,,} pkgver=${_bcver//[:-]/.} pkgrel=1 pkgdesc="" arch=() url="https://bioconductor.org/packages/${_bcname}" license=() depends=(r) makedepends=() optdepends=() source=("https://bioconductor.org/packages/release/bioc/src/contrib/${_bcname}_${_bcver}.tar.gz") # or # source=("https://bioconductor.org/packages/release/data/annotation/src/contrib/${_bcname}_${_bcver}.tar.gz") sha256sums=() build() { R CMD INSTALL ${_bcname}_${_bcver}.tar.gz -l "${srcdir}" } package() { install -dm0755 "${pkgdir}/usr/lib/R/library" cp -a --no-preserve=ownership "${_bcname}" "${pkgdir}/usr/lib/R/library" }
Tips and tricks
To quickly check if any of your (or another user) R packages in AUR has become outdated you can use aurrpkgs-gitAUR tool (replace username with desired value):
$ aurrpkgs username
This tool will show you all outdated packages and new available versions for them.