From 3e34d0325ba8945ed72ffaa5c2beb2baddd9eba5 Mon Sep 17 00:00:00 2001 From: Iñaki Úcar Date: Oct 17 2025 20:02:54 +0000 Subject: adapt R guidelines to current practices --- diff --git a/guidelines/modules/ROOT/pages/R.adoc b/guidelines/modules/ROOT/pages/R.adoc index 2b470b2..fcab8e5 100644 --- a/guidelines/modules/ROOT/pages/R.adoc +++ b/guidelines/modules/ROOT/pages/R.adoc @@ -18,10 +18,8 @@ If you are looking for more information on R, you can go to: If you are interested in packaging R modules, or if you are looking for R libraries, you should check here for upstream sources: -* https://www.bioconductor.org/[The bioconductor website] * https://cran.r-project.org/[The CRAN website] -* https://r-forge.r-project.org/[The R-forge from the R-Project website] -* https://www.rforge.net/[The RForge website] +* https://www.bioconductor.org/[The Bioconductor website] == Spec Templates for R packages @@ -35,7 +33,7 @@ there are very minor differences for noarch packages, which are noted below the Name: R-%{packname} Version: 1.6.6 -Release: 1%{?dist} +Release: %autorelease Summary: Adds foo functionality for R License: GPL-2.0-or-later @@ -43,7 +41,8 @@ URL: https://CRAN.R-project.org/package=%{packname} Source: %{url}&version=%{version}#/%{packname}_%{version}.tar.gz BuildRequires: R-devel -BuildRequires: tex(latex) +BuildRequires: R() +BuildRequires: ... %description R Interface to foo, enables bar! @@ -60,24 +59,25 @@ test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so) rm -f %{buildroot}%{rlibdir}/R.css %check -%{_bindir}/R CMD check %{packname} +export LANG=C.UTF-8 +export _R_CHECK_FORCE_SUGGESTS_=0 +%{_bindir}/R CMD check --no-manual --ignore-vignettes %{packname} %files %dir %{rlibdir}/%{packname} %doc %{rlibdir}/%{packname}/doc %doc %{rlibdir}/%{packname}/html -%{rlibdir}/%{packname}/DESCRIPTION %doc %{rlibdir}/%{packname}/NEWS +%{rlibdir}/%{packname}/DESCRIPTION %{rlibdir}/%{packname}/INDEX %{rlibdir}/%{packname}/NAMESPACE %{rlibdir}/%{packname}/Meta %{rlibdir}/%{packname}/R -%{rlibdir}/%{packname}/R-ex %{rlibdir}/%{packname}/help +%{rlibdir}/%{packname}/libs %changelog -* Fri Jul 6 2007 Tom "spot" Callaway - 1.6.6-1 -- Initial package creation +%autochangelog .... === Differences between arch-specific and noarch R packages @@ -87,11 +87,6 @@ rm -f %{buildroot}%{rlibdir}/R.css arch-specific packages install into `+%{_libdir}/R/library/%{packname}+`. + Change the `+%global rlibdir+` at the top of the file to use `+%{_datadir}+` instead of `+%{_libdir}+`. -=== R2spec - -R2spec is an excellent little tool to assist in creating Fedora-compliant packages for R libraries. Using it as a starting point is recommended (but certainly not mandated). -More information here : https://pagure.io/r2spec/ - == Automatically generated dependencies All R packages that depend on `+R-devel+` will automatically produce Provides, Requires, Suggests, and Enhances via a generator in `+R-rpm-macros+`. @@ -110,7 +105,7 @@ The generator adds run time requires in the form of `+R(foo)+` (with versions as specified in the metadata if supplied.) The packager MUST inspect the generated Requires for correctness. -All dependencies MUST be resolvable within the targeted Fedora version. +All hard dependencies (R's `+LinkingTo+`, `+Depends+`, `+Imports+`) MUST be resolvable within the targeted Fedora version. Unwanted dependencies may be removed by editing the installed `+DESCRIPTION+` file or using xref:AutoProvidesAndRequiresFiltering.adoc[rpm's `+%__requires_exclude+`] @@ -182,16 +177,32 @@ test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so) This is demonstrated in the spec templates. -=== Running %check +=== Running %check and Suggests -Most (if not all) R addon modules come with a built-in check. This can be triggered by running `+R CMD check+`. In Fedora, the check should be run in the `+%check+` section. Here is an example `+%check+` section for a Fedora R package: +R addon modules come with a built-in check that can be triggered by running `+R CMD check+`. +In Fedora, the check should be run in the `+%check+` section. -.... -%check -%{_bindir}/R CMD check %{packname} -.... +Packages in `+Suggests+` are often used in examples, tests, and vignettes, sometimes even in functions exported by the package. +However, according to CRAN's guidelines, R addons MUST work without the dependencies listed in `+Suggests+`. +This means that they MUST check for the presence of a suggested package before running anything that requires it (in code, examples, tests, or vignettes). +According to this, Fedora packages MUST drop from `+BuildRequires+` all packages in R's `+Suggests+` to avoid circular dependency loops. +As a exception to this rule, R addons that are mandatory for running unit tests in the first place (e.g. `+testthat+`, `+tinytest+`, and few more) SHOULD be kept in `+BuildRequires+` for the `+%check+` section. -Note that frequently, R packages have circular dependency loops when running `+R CMD check+`. If you hit such a case, you can comment out the check to break the dependency loop, and leave a comment explaining the circular dependency problem. +By default, `+R CMD check+` checks for the presence of suggested packages, so `+export _R_CHECK_FORCE_SUGGESTS_=0+` MUST be added to disable this check. +Additionally, recreation of manual pages and vignettes, which usually use suggested packages, MUST be disabled with `+--no-manual+` and `+--ignore-vignettes+` respectively. +Putting everything together, the `+%check+` section should look like the one in the example spec above. + +If this default `+%check+` fails due to some missing suggested package, then it is a bug in the package. +This SHOULD be reported upstream, and a workaround MUST be put in place: + +* If the failure happens in an example, the `+--no-examples+` flag MAY be added. +* If the failure happens in a test, a `+skip()+` call MAY be added in the proper place, or even the `+--no-tests+` flag for more complicated situations. + +=== License + +Typically, R extensions do not contain license files per CRAN policy. +R allows a set of open source licenses and R extensions just declare which one they adhere to. +Following this policy, we do not require upstream R extensions to add license files. === Documentation files @@ -211,3 +222,9 @@ R packages inherit their optimization flags from the main R package, which store R packages usually expect to find their header files in `+%{_libdir}/R/library/*/+`. rpmlint will complain that these files are misplaced, but this is safe to ignore. You should still separate these header files into a -devel subpackage. + +=== R2spec + +R2spec is an excellent little tool to assist in creating Fedora-compliant packages for R libraries. +Using it as a starting point is recommended (but certainly not mandated). +More information here : https://pagure.io/r2spec/