R package guidelines

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.

Arch package guidelines

32-bitCLRCMakeCrossDKMSEclipseElectronFontFree PascalGNOMEGoHaskellJavaKDEKernelLispMesonMinGWNode.jsNonfreeOCamlPerlPHPPythonRRubyRustShellVCSWebWine

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 should be listed as optdepends.

Some packages require external tools, these are listed under .

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 where is the name of the package on CRAN and cranversion the cran version.

R packages avalable on Bioconductor are available at the website or where 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 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

R packakges check

To quickly check if any of your (or another user) R packages in AUR has become outdated you can use tool (replace username with desired value):

$ aurrpkgs username

This tool will show you all outdated packages and new available versions for them.

Bioconductor repository

To access the bioconductor packages easily, you can add BioArchLinux Repository.

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.