1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
- = R Packaging Guidelines
- == What is R?
- The definition from https://www.r-project.org/[The R-Project website] says that R is:
- _" R is a language and environment for statistical computing and graphics."_
- R is a GNU project, very similar to the S language developed by Bell Laboratories.
- This language is heavily used in research as it provides a lot of statistical and graphical tools.
- It is also a well developed language for data manipulation.
- If you are looking for more information on R, you can go to:
- * https://www.r-project.org/[The R-Project website]
- * https://cran.r-project.org/doc/manuals/R-intro.html[An introduction to R]
- 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]
- == Spec Templates for R packages
- There are two types of R packages: arch-specific and noarch.
- 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 rlibdir %{_libdir}/R/library
- Name: R-%{packname}
- Version: 1.6.6
- Release: 1%{?dist}
- Summary: Adds foo functionality for R
- License: GPL-2.0-or-later
- URL: https://CRAN.R-project.org/package=%{packname}
- Source: %{url}&version=%{version}#/%{packname}_%{version}.tar.gz
- BuildRequires: R-devel
- BuildRequires: tex(latex)
- %description
- R Interface to foo, enables bar!
- %prep
- %setup -q -c -n %{packname}
- %build
- %install
- mkdir -p %{buildroot}%{rlibdir}
- %{_bindir}/R CMD INSTALL -l %{buildroot}%{rlibdir} %{packname}
- test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so)
- rm -f %{buildroot}%{rlibdir}/R.css
- %check
- %{_bindir}/R CMD check %{packname}
- %files
- %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 <tcallawa@redhat.com> - 1.6.6-1
- - Initial package creation
- ....
- === 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}+`. +
- 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+`.
- 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+`.
- The version from the metadata will be normalized
- (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 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
- === Naming of R packages
- 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
- ....
- R-mAr (R module named mAr)
- R-RScaLAPACK (R module named RScaLAPACK)
- R-waveslim (R module named waveslim)
- ....
- === R version
- Many R packages contain '-' in their version. Usually, the versioning used is a sequence of at least two (and usually three) non-negative integers separated by single '.' or '-' characters.
- To be consistent with the versioning system used in Fedora, you should simply replace dashes with dots.
- ==== Example
- ....
- Upstream tarball: Rfoo-0.5-8.tar.gz
- Fedora Version: 0.5.8
- ....
- === Empty %build section
- Unlike normal Fedora packages, there is normally no separate `+%build+` actions (e.g. `+%configure+`)that need to be taken for an R package. However, it is important that all R module packages include an empty `+%build+` section, as shown in the spec templates.
- === Installing the R addon bits
- Instead of calling make install, to install the R addon components, you need to run `+R CMD INSTALL -l %{buildroot}%{_datadir}/R/library %{packname}+` (noarch) or `+R CMD INSTALL -l %{buildroot}%{_libdir}/R/library %{packname}+` (arch-specific). Proper `+%install+` sections for Fedora R packages are demonstrated in the spec templates.
- === 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.
- === Cleaning the R directory of binaries
- It is important to clean the R directory of binary files (`+*.o *.so+`) before running `+R CMD CHECK+`. Otherwise, the CHECK command will throw a warning about finding binaries in the source dir. This is accomplished by running (in `+%install+`):
- ....
- test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so)
- ....
- This is demonstrated in the spec templates.
- === Running %check
- 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:
- ....
- %check
- %{_bindir}/R CMD check %{packname}
- ....
- 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.
- === Documentation files
- The `+R CMD INSTALL+` operation will install all of the files, including documentation files. The doc, html and NEWS files/directories need to be marked as `+%doc+`.
- Note that other files, such as DESCRIPTION, INDEX, NAMESPACE, and help/ are not `+%doc+`, since proper R functionality depends on their presence. Be careful not to duplicate `+%doc+` files in the package, the spec templates provide good examples on how to package the R addon files without duplications.
- ==== R documentation
- R documentation is written in TeX. rpmlint sometimes complains that these TeX files are not utf-8 files, but the encoding is normally specified in the file when needed, so this error is safe to ignore (and you should not try to re-encode the files).
- === Optimization flags
- R packages inherit their optimization flags from the main R package, which stores them in `+%{_libdir}/R/etc/Makeconf+`. The design of R is such that all R addon library modules use the same optimization flags that the main R package was built with. Accordingly, this is why R addon packages do not pass `+%{optflags}+`. Also, there is no simple way to pass special optimization flags to `+R CMD INSTALL+`.
- === R headers
- 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.
|