From 15c6b53823e57bbb7d620c1b0fd8d523238919fb Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Oct 17 2019 20:01:03 +0000 Subject: [PATCH 1/5] Modernize R spec template. This matches what is produced by R2spec more closely, namely: * Update URL to current CRAN guidelines. * Add %{rlibdir} macro. Also, removed the duplicated arch/noarch templates; there are only two differences between them. --- diff --git a/guidelines/modules/ROOT/pages/R.adoc b/guidelines/modules/ROOT/pages/R.adoc index b2c2a6d..946d790 100644 --- a/guidelines/modules/ROOT/pages/R.adoc +++ b/guidelines/modules/ROOT/pages/R.adoc @@ -27,73 +27,24 @@ If you are interested in packaging R modules, or if you are looking for R librar == Spec Templates for R packages There are two types of R packages: arch-specific and noarch. - -=== Arch specific R packaging spec template +The following template shows how to package an arch-specific R package; +there are very minor differences for noarch packages, which are noted below the template. .... %global packname foo -%global packrel 1 +%global rlibdir %{_libdir}/R/library Name: R-%{packname} Version: 1.6.6 Release: 1%{?dist} -Source0: ftp://cran.r-project.org/pub/R/contrib/main/%{packname}_%{version}-%{packrel}.tar.gz -License: GPLv2+ -URL: https://cran.r-project.org/src/contrib Summary: Adds foo functionality for R -BuildRequires: R-devel, tex(latex) - -%description -R Interface to foo, enables bar! - -%prep -%setup -q -c -n %{packname} - -%build - -%install -mkdir -p %{buildroot}%{_libdir}/R/library -%{_bindir}/R CMD INSTALL -l %{buildroot}%{_libdir}/R/library %{packname} -test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so) -rm -rf %{buildroot}%{_libdir}/R/library/R.css - -%check -%{_bindir}/R CMD check %{packname} -%files -%dir %{_libdir}/R/library/%{packname} -%doc %{_libdir}/R/library/%{packname}/doc -%doc %{_libdir}/R/library/%{packname}/html -%doc %{_libdir}/R/library/%{packname}/NEWS -%{_libdir}/R/library/%{packname}/DESCRIPTION -%{_libdir}/R/library/%{packname}/INDEX -%{_libdir}/R/library/%{packname}/NAMESPACE -%{_libdir}/R/library/%{packname}/Meta -%{_libdir}/R/library/%{packname}/R -%{_libdir}/R/library/%{packname}/R-ex -%{_libdir}/R/library/%{packname}/help - -%changelog -* Fri Jul 6 2007 Tom "spot" Callaway - 1.6.6-1 -- Initial package creation -.... - -=== Noarch R packaging spec template - -.... -%global packname foo -%global packrel 1 - -Name: R-%{packname} -Version: 1.6.6 -Release: 1%{?dist} -Source0: ftp://cran.r-project.org/pub/R/contrib/main/%{packname}_%{version}-%{packrel}.tar.gz License: GPLv2+ -URL: https://cran.r-project.org/src/contrib -Summary: Adds foo functionality for R -BuildRequires: R-devel, tex(latex) -BuildArch: noarch -Requires: R-core +URL: https://CRAN.R-project.org/package=%{packname} +Source0: https://cran.r-project.org/src/contrib/%{packname}_%{version}.tar.gz + +BuildRequires: R-devel +BuildRequires: tex(latex) %description R Interface to foo, enables bar! @@ -104,36 +55,38 @@ R Interface to foo, enables bar! %build %install -mkdir -p %{buildroot}%{_datadir}/R/library -%{_bindir}/R CMD INSTALL -l %{buildroot}%{_datadir}/R/library %{packname} +mkdir -p %{buildroot}%{rlibdir} +%{_bindir}/R CMD INSTALL -l %{buildroot}%{rlibdir} %{packname} test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so) -rm -rf %{buildroot}%{_datadir}/R/library/R.css +rm -f %{buildroot}%{rlibdir}/R.css %check %{_bindir}/R CMD check %{packname} %files -%dir %{_datadir}/R/library/%{packname} -%doc %{_datadir}/R/library/%{packname}/doc -%doc %{_datadir}/R/library/%{packname}/html -%doc %{_datadir}/R/library/%{packname}/NEWS -%{_datadir}/R/library/%{packname}/DESCRIPTION -%{_datadir}/R/library/%{packname}/INDEX -%{_datadir}/R/library/%{packname}/NAMESPACE -%{_datadir}/R/library/%{packname}/Meta -%{_datadir}/R/library/%{packname}/R -%{_datadir}/R/library/%{packname}/R-ex -%{_datadir}/R/library/%{packname}/help +%dir %{rlibdir}/%{packname} +%doc %{rlibdir}/%{packname}/doc +%doc %{rlibdir}/%{packname}/html +%{rlibdir}/%{packname}/DESCRIPTION +%doc %{rlibdir}/%{packname}/NEWS +%{rlibdir}/%{packname}/INDEX +%{rlibdir}/%{packname}/NAMESPACE +%{rlibdir}/%{packname}/Meta +%{rlibdir}/%{packname}/R +%{rlibdir}/%{packname}/R-ex +%{rlibdir}/%{packname}/help %changelog * Fri Jul 6 2007 Tom "spot" Callaway - 1.6.6-1 - Initial package creation .... -=== Summary of differences between arch-specific and noarch R packages +=== Differences between arch-specific and noarch R packages * Noarch packages set `+BuildArch: noarch+`. -* Noarch packages install into `+%{_datadir}/R/library/%{packname}+`; arch-specific packages install into `+%{_libdir}/R/library/%{packname}+`. +* Noarch packages install into `+%{_datadir}/R/library/%{packname}+`; + 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}+`. * Noarch packages have `+Requires: R-core+`. For arch-specific packages, RPM will automatically add an appropriate dependency on the needed shared libraries but noarch packages need this added manually. === R2spec From 6a91f724d5914302de33cd5fd8676cf2daac688e Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Oct 17 2019 20:01:03 +0000 Subject: [PATCH 2/5] Fix formatting of R examples. --- diff --git a/guidelines/modules/ROOT/pages/R.adoc b/guidelines/modules/ROOT/pages/R.adoc index 946d790..3a2e1b0 100644 --- a/guidelines/modules/ROOT/pages/R.adoc +++ b/guidelines/modules/ROOT/pages/R.adoc @@ -100,7 +100,7 @@ More information here : https://pagure.io/r2spec/ Packages of R modules (thus they rely on R as a parent) have their own naming scheme. They should take into account the upstream name of the R module. This makes a package name format of `+R-$NAME+`. When in doubt, use the name of the module that you type to import it in R. -'''Examples: ''' +==== Examples .... R-mAr (R module named mAr) @@ -114,7 +114,7 @@ Many R packages contain '-' in their version. Usually, the versioning used is a To be consistent with the versioning system used in Fedora, you should simply replace dashes with dots. -Example: +==== Example .... Upstream tarball: Rfoo-0.5-8.tar.gz @@ -131,7 +131,10 @@ Instead of calling make install, to install the R addon components, you need to === Deleting the R.css file -Most R addon modules generate a new `+R.css file+`, but it would conflict with the master `+R.css+` file, included in the main R package. You must delete this file, and do not include it in your package. +Most R addon modules generate a new `+R.css+` file, +but it would conflict with the master `+R.css+` file, +included in the main R package. +You must delete this file, and do not include it in your package. === Cleaning the R directory of binaries From bdd773313b8d0eef9d0a80fee36eea210482b2a4 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Oct 17 2019 20:01:03 +0000 Subject: [PATCH 3/5] Add information on automatic R dependencies. --- diff --git a/guidelines/modules/ROOT/pages/R.adoc b/guidelines/modules/ROOT/pages/R.adoc index 3a2e1b0..8103dfc 100644 --- a/guidelines/modules/ROOT/pages/R.adoc +++ b/guidelines/modules/ROOT/pages/R.adoc @@ -87,13 +87,36 @@ rm -f %{buildroot}%{rlibdir}/R.css * Noarch packages install into `+%{_datadir}/R/library/%{packname}+`; 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}+`. -* Noarch packages have `+Requires: R-core+`. For arch-specific packages, RPM will automatically add an appropriate dependency on the needed shared libraries but noarch packages need this added manually. === 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+`. +This generator uses upstream metadata in `+DESCRIPTION+` files to determine what the package should depend on. + +=== Provides with a standardized name + +The generator adds run time Provides in the form of `+R(foo) = packageVersion+`. + +No mangling will be performed on the version from the metadata +(as specified in <<_r_version>> for package versioning). + +=== Dependencies on standardized names + +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. + +Unwanted dependencies may be removed by editing the installed `+DESCRIPTION+` file +or using https://rpm.org/user_doc/dependency_generators.html#tweaking-dependency-generators[rpm's `+%__requires_exclude+`] +(substitute `+suggests+` or `+enhances+` if necessary). + == R packaging tips === Naming of R packages From 267df475da8a35bc1cd4f8c7aa6b937da60fb611 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Oct 17 2019 20:01:03 +0000 Subject: [PATCH 4/5] Add example of filtering out R auto-Suggests. --- diff --git a/guidelines/modules/ROOT/pages/R.adoc b/guidelines/modules/ROOT/pages/R.adoc index 8103dfc..f00e02d 100644 --- a/guidelines/modules/ROOT/pages/R.adoc +++ b/guidelines/modules/ROOT/pages/R.adoc @@ -114,8 +114,22 @@ The packager MUST inspect the generated Requires for correctness. All dependencies MUST be resolvable within the targeted Fedora version. Unwanted dependencies may be removed by editing the installed `+DESCRIPTION+` file -or using https://rpm.org/user_doc/dependency_generators.html#tweaking-dependency-generators[rpm's `+%__requires_exclude+`] +or using xref:AutoProvidesAndRequiresFiltering.adoc[rpm's `+%__requires_exclude+`] (substitute `+suggests+` or `+enhances+` if necessary). +For example, to filter out `+Suggests+` on `+foo+`, use: + +.... +%global __suggests_exclude ^R\\(foo\\) +.... + +To filter out multiple packages, use: + +.... +%global __suggests_exclude ^R\\((foo\\.bar|baz)\\) +.... + +Note that you need to escape regular expression special characters with backslash +_and_ you need to escape said backslash for RPM. == R packaging tips From b11fec668ff10ce902251bb3560648de8ad91d7b Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Oct 17 2019 20:01:03 +0000 Subject: [PATCH 5/5] Add a warning that R automatic deps are F31+. --- diff --git a/guidelines/modules/ROOT/pages/R.adoc b/guidelines/modules/ROOT/pages/R.adoc index f00e02d..ac8a4f3 100644 --- a/guidelines/modules/ROOT/pages/R.adoc +++ b/guidelines/modules/ROOT/pages/R.adoc @@ -95,6 +95,9 @@ More information here : https://pagure.io/r2spec/ == Automatically generated dependencies +WARNING: Automatically generated dependencies are only enabled for Fedora 31 and later. +On older versions, you must provide the dependencies manually. + All R packages that depend on `+R-devel+` will automatically produce Provides, Requires, Suggests, and Enhances via a generator in `+R-rpm-macros+`. This generator uses upstream metadata in `+DESCRIPTION+` files to determine what the package should depend on.