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
214
215
216
217
218
219
220
221
222
223
224
225
|
.\" $NetBSD: R2pkg.8,v 1.5 2019/06/24 13:46:04 brook Exp $
.\"
.\" Copyright (c) 2014,2015,2016,2017,2018,2019
.\" Brook Milligan. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the author nor the names of any contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"
.Dd February 23, 2017
.Dt R2PKG 8
.Os
.Sh NAME
.Nm R2pkg
.Nd create a pkgsrc package for an R package
.Sh SYNOPSIS
.Nm
.Op Fl DehqruVv
.Op Fl E Ar editor
.Op Fl M Ar maintainer_email
.Op Fl R Ar dependency_file
.Op Ar package
.Sh DESCRIPTION
.Nm
takes the name of an R
.Ar package
that should be turned into a
.Xr pkgsrc 7
package in the current directory.
The generated package includes a
.Pa Makefile
and a mostly complete set of files to get the package going.
However,
the files should be reviewed and perhaps adjusted manually after
.Nm
has finished its job.
To help with this, the original versions of files created by
.Nm
are preserved for reference.
.Pp
.Nm
is intended to help the process of creating a package but is not
intended to fly on autopilot.
.Pp
The
.Pa Makefile
contains all of the variables required for an R package, with
information being taken from the package's
.Pa DESCRIPTION
file on CRAN, which is automatically fetched by
.Nm .
Likewise, the
.Pa DESCR
file is populated with information from the same file.
After
.Pa Makefile
and
.Pa DESCR
are completed,
.Nm
fetches the package and computes its checksum via the
.Ic makesum
target.
.Pp
If the user does not supply the
.Ar package
on the command line, then
.Nm
will prompt for it.
.Pp
The following options are available:
.Bl -tag -width indent
.It Fl D
Write the package's description into
.Pa DESCRIPTION .
This may be useful for verifying the information obtained from CRAN.
However, this file must be removed as it is not part of a
.Xr pkgsrc 7
package.
.It Fl E Ar editor
Use
.Ar editor
instead of the user's default editor.
.It Fl e
Do not edit Makefile and DESCR.
.It Fl h
Produce a short help message.
.It Fl M Ar maintainer_email
Set the maintainer email address for any newly created packages.
.It Fl q
Do not produce status messages along the way.
.It Fl R Ar dependency_file
Process dependency packages recursively using
.Pa dependency_file
to record dependency information.
This option is intended for
internal use only to implement recursion over dependencies.
Instead, the
.Fl r
option should be used to select recursion.
.It Fl r
Process dependency packages recursively.
A
.Pa depends
file is created that lists the dependencies in
.Xr tsort 1
order.
This is likely the best order for testing the resulting
dependency packages.
In particular, a useful strategy for creating
packages recursively is to (i) run
.Nm
with the
.Fl r
option, (ii) fix all the leaf packages, (iii) rerun
.Nm
with the
.Fl r
option, and (iv) continue until all packages are created.
Repeating runs of
.Nm
once the leaf dependencies are moved into the correct categories will
allow the program to capture the correct dependencies in each
.Pa Makefile .
.It Fl u
Update the
.Xr pkgsrc 7
package.
.Nm
must be run in an R package directory, which is assumed to be named as
.Pa R-package .
The name of the package to be updated will be taken from the directory
name and need not be given on the command line.
.It Fl V
Print the version.
.It Fl v
Generate verbose output.
This may be repeated to increase the verbosity.
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
.Nm :
.Bl -tag -width BLOCKSIZE
.It Ev PKGEDITOR , EDITOR
Editor used for editing
.Pa Makefile
and
.Pa DESCR .
.It Ev CRAN_URL
The URL to the CRAN mirror for downloading the package's DESCRIPTION
file.
By default,
.Pa ftp://cran.r-project.org .
.El
.Sh EXAMPLES
Use the following commands to create a
.Xr pkgsrc 7
package for the R package
.Ar foo :
.Dl cd pkgsrc/math
.Dl mkdir R-foo
.Dl cd R-foo
.Dl R2pkg foo
Remember to test the resulting package and remove any extra files
created by
.Nm .
Adding
.Fl r
to the command line will also recursively create all necessary
dependencies in the
.Pa wip
directory.
.Pp
Use the following commands to update a
.Xr pkgsrc 7
package (and dependencies) for the R package
.Ar foo :
.Dl cd pkgsrc/math/R-foo
.Dl R2pkg -r -u
Packages built for any new dependencies will be added to the
.Pa wip
directory.
.Sh SEE ALSO
.Xr pkgsrc 7
.Sh AUTHORS
.Nm
was written by
.An Brook Milligan Aq Mt brook@NetBSD.org .
.Sh BUGS
.Nm
does not create a finished package; instead, it facilitates the task.
However, the resulting files must be reviewed and possibly edited by
hand.
Although dependencies are included in the generated
.Pa Makefile ,
they are not fully analyzed and likely have incorrect category
information.
Packages created recursively for dependencies are placed
in a newly created, nonstandard
.Pa pkgsrc/R
category directory and must be moved to appropriate category
directories within
.Xr pkgsrc 7
and checked for correctness.
|