[aur-general] Packaging all CRAN packages for R

Alex Branham alex.branham at gmail.com
Sun May 27 14:03:03 UTC 2018

On Sat 26 May 2018 at 21:24, Eli Schwartz via aur-general <aur-general at archlinux.org> wrote:

> On 05/26/2018 12:04 PM, Alex Branham via aur-general wrote:
>> Hi all -
>> I'd like to use pacman to manage R packages, similar to how you can for
>> other languages (e.g. the python packages are all named python-*). There
>> are some packages available already, but not many (I count about 130
>> currently). I wrote a script[1] that generates PKGBUILDS for all the
>> packages on the Comprehensive R Archive Network (CRAN). There's 12,593
>> packages on CRAN as of today.
>> If you evaluate the script, then call write_all_pkgbuilds(), R will put
>> each PKGBUILD into PKGBUILDS/r-cran-<pkgname>/PKGBUILD. Here's an
>> example of the output.[2] It doesn't generate .SRCINFO or setup a git
>> repo (yet). It also doesn't take into account (yet) that there are
>> already 130ish R packages on the AUR. I named them r-cran-* rather than
>> r-* because 1) it's clearer where the packages are coming from and 2)
>> it's a pain to search for r-*
>> Is this something people would like to have in the AUR? I figured I
>> should ask before adding ~12.5k packages.
>> Any and all comments/feedback appreciated!
>> Thanks,
>> Alex
> If you're generating PKGBUILDs for upload to the AUR, they should be
> well-written. As observed, injecting "cran" into the name is confusing,
> I think anyone looking for an R package will know how to find it based
> on the rest of the name component.

Yes, I think everyone prefers r-* to r-cran-*. That's easy enough to change.

> I doubt anyone is just looking randomly to see which R packages are
> available, but if they are, the most effective way would be to download
> https://aur.archlinux.org/packages.gz and use regular expressions to
> find packages matching the pattern ^r-

It would be nice if the web search interface supported things like this.

> This would find the regardless of whether they mentioned cran, and in a
> highly effective manner.
>> Footnotes:
>> [1]  https://github.com/jabranham/r-cran-pkgbuilds/blob/master/gen-R-PKGBUILDS.R
>> [2]
>> # Maintainer: Alex Branham <email-address-removed>
>> _cranname=A3
>> _cranver=1.0.0
>> pkgname=r-cran-a3
>> pkgver=1.0.0
> Why is cryanver different from pkgver?

CRAN versions can contain characters that aren't allowed in PKGBUILDS such as hyphens.

>> pkgrel=1
>> pkgdesc="Supplies tools for tabulating and analyzing the results of predictive models. The methods employed are applicable to virtually any predictive model and make comparisons between different methodologies straightforward."
> pkgdesc should be 80 chars, not 218

Thanks. I'll work on shortening the pkgdesc to around 80 characters.

>> url="https://cran.r-project.org/web/packages/${_cranname}/index.html"
>> arch=('x86_64')
>> license=('GPL')
>> depends=('r-cran-xtable' 'r-cran-pbapply')
>> optdepends=('r-cran-randomforest' 'r-cran-e1071')
>> source=("https://cran.r-project.org/src/contrib/${_cranname}_${_cranver}.tar.gz")
>> md5sums=('027ebdd8affce8f0effaecfcd5f5ade2')
>> package() {
>>   mkdir -p ${pkgdir}/usr/lib/R/library
>>   cd ${srcdir}
>>   R CMD INSTALL ${_cranname} -l ${pkgdir}/usr/lib/R/library
>> }
> This compiles source code into x86_64 ELF executable code, in the
> package() step?

Is your question here about the architecture? It automatically detects
that during R CMD INSTALL.

> Also ${srcdir} without quotes will guaranteedly break on at least some
> users who build from directories which contain spaces. You carefully
> quote array assignments, which do *not* contain spaces (note, I'm not
> saying this was the wrong decision!) then neglect to do so for the only
> two variables which contain content not under your control!

Fixed, thanks!

Thank you very much for the feedback, Eli. I don't have a ton of
experience writing PKGBUILDs so this was very helpful!


More information about the aur-general mailing list