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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
|
.\" $OpenBSD: ruby-module.5,v 1.48 2024/11/21 06:12:23 jeremy Exp $
.\"
.\" Copyright (c) 2011-2015, 2023 Jeremy Evans <jeremy@openbsd.org>
.\" Copyright (c) 2008, 2011 Marc Espie <espie@openbsd.org>
.\"
.\" 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.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 DEVELOPERS 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 $Mdocdate: November 21 2024 $
.Dt RUBY-MODULE 5
.Os
.Sh NAME
.Nm ruby-module
.Nd lang/ruby port module
.Sh DESCRIPTION
This manual page documents the behavior of setting
.Ev MODULES Ns Li =lang/ruby
in the
.Xr ports 7
tree.
.Pp
The main usage of the lang/ruby module is to allow a single Ruby gem-based
port to build packages for multiple versions of Ruby.
The lang/ruby module also simplifies ports that depend on Ruby by
automatically setting up the correct dependencies and defining commonly
needed variables.
.Pp
To allow a single Ruby gem-based port to build packages for multiple versions
of Ruby, set a specific
.Ev CONFIGURE_STYLE ,
which modifies some additional parameters:
.Bl -tag -width Ds
.It Ev CONFIGURE_STYLE Ns = Ns Qq ruby gem
For pure Ruby gems without C extensions.
This adds
.Ev PKG_ARCH
= * to the port.
.It Ev CONFIGURE_STYLE Ns = Ns Qq ruby gem ext
For Ruby gems with C extensions.
To pass additional arguments to
.Sy gem Cm install
when building the port, set
those via
.Ev CONFIGURE_ARGS .
.El
.Pp
.Ev CONFIGURE_STYLE Ns = Ns Qq ruby gem
and
.Ev CONFIGURE_STYLE Ns = Ns Qq ruby gem ext
both add ruby32 and ruby33
.Ev FLAVOR Ns s
to the port.
They also cause the
.Ev FULLPKGNAME
to use the
.Ev FLAVOR Ns \-
instead of ruby\- as the package prefix.
.Pp
The ports system defaults to using Ruby 3.3 if the version of Ruby is not
specified.
To specify a version for a gem port, use a specific
.Ev FLAVOR ,
such as ruby32 to use Ruby 3.2.
To specify the Ruby version to use for a non Ruby-gem port, set
.Ev MODRUBY_REV
to 3.2 or 3.3.
.Pp
To ensure that dependencies use the same Ruby implementation as the
current port, all Ruby gem dependencies specified in the port
should use this format:
.Pp
.Dl category/ruby\-foo,${MODRUBY_FLAVOR}
.Pp
To prevent the ports system from automatically setting up
.Ev FLAVOR Ns s
in a gem port, set
.Ev MODRUBY_HANDLE_FLAVORS
to
.Cm \&No .
Similarly, to let the ports system automatically set up
.Ev FLAVOR Ns s
in a non-gem port, set
.Ev MODRUBY_HANDLE_FLAVORS
to
.Cm Yes .
When
.Ev MODRUBY_HANDLE_FLAVORS
is
.Cm Yes ,
the ports system automatically adds the appropriate prefix to the
.Ev FULLPKGNAME
(e.g. ruby32\- for ruby 3.2, ruby33\- for ruby 3.3).
.Pp
For Ruby gem ports that can work on multiple Ruby versions, append
.Ev GEM_BIN_SUFFIX
to every binary file entry in the PLIST.
This is because the gem binaries for multiple Ruby versions are all
installed to
.Pa ${LOCALBASE}/bin ,
and the binaries all use a version-specific suffix.
Any man pages and other files that would be installed to locations not
specific to a Ruby implementation (such as under
.Pa ${LOCALBASE}/share ) ,
should use
.Ev GEM_MAN_SUFFIX
before the extension so the different
.Ev FLAVOR Ns s
do not conflict.
.Pp
make update\-plist may remove
.Ev GEM_BIN_SUFFIX
and
.Ev GEM_MAN_SUFFIX
from the PLIST, or use them in inappropriate places, so be careful when
updating gem ports with binaries or man pages.
Additionally, for gem ports with C extensions, make update\-plist will add back
files used by the specific
.Ev FLAVOR
(such as files under the extension source directory), which may
not exist for other
.Ev FLAVOR Ns s ,
so always manually check the result of make update\-plist and manually test that
all supported
.Ev FLAVOR Ns s
are buildable before committing.
Additionally, for gems with C extensions, make update\-plist may add back the
extension source files, which shouldn't be included in the files, so make sure
to double check that all files added by make update\-plist should be included
in the package.
.Pp
The lang/ruby module creates a do\-test target if
.Ev MODRUBY_TEST
is used and one is not already defined.
.Pp
The lang/ruby module appends to the following variables:
.Bl -tag -width Ds
.It Ev BUILD_DEPENDS
Adds dependency on version of Ruby in use unless
.Ev MODRUBY_BUILDDEP
is set to
.Cm \&No ,
or
.Ev NO_BUILD
is set to
.Cm Yes .
.It Ev CATEGORIES
Adds the lang/ruby category.
.It Ev RUN_DEPENDS
Adds dependency on version of Ruby in use unless
.Ev MODRUBY_RUNDEP
is set to
.Cm \&No .
.It Ev TEST_DEPENDS
Adds the rspec dependency if
.Ev MODRUBY_TEST
is set to rspec3.
.It Ev SUBST_VARS
Adds
.Ev GEM_EXTENSIONS_DIR ,
.Ev MODRUBY_RELEXAMPLEDIR ,
.Ev MODRUBY_SITEARCHDIR ,
.Ev MODRUBY_SITEDIR ,
.Ev MODRUBY_LIBREV ,
.Ev MODRUBY_ARCH ,
.Ev GEM_LIB ,
.Ev GEM_BIN ,
and
.Ev DISTNAME .
.It Ev UPDATE_PLIST_ARGS
Adds options so that
.Ev MODRUBY_RELEXAMPLEDIR ,
.Ev MODRUBY_SITEARCHDIR ,
.Ev MODRUBY_SITEDIR ,
.Ev GEM_LIB ,
and
.Ev GEM_BIN
are only substituted at the start of paths.
.El
.Pp
If using
.Ev CONFIGURE_STYLE Ns = Ns Qq ruby gem
or
.Ev CONFIGURE_STYLE Ns = Ns Qq ruby gem ext ,
it also appends to the following variables:
.Bl -tag -width Ds
.It Ev EXTRACT_CASES
Adds support for extracting .gem files.
.El
.Pp
If using
.Ev CONFIGURE_STYLE Ns = Ns Qq ruby gem ext ,
it also appends to the following variables:
.Bl -tag -width Ds
.It Ev WANTLIB
Adds libraries used by Ruby.
.It Ev LIB_DEPENDS
Adds
.Ev MODRUBY_LIB_DEPENDS .
.It Ev PKG_ARGS
Adds additional PLIST so that loading native extensions will not attempt to
rebuild them at runtime.
.It Ev SUBST_VARS
Adds
.Ev GEM_EXTENSIONS_DIR .
.El
.Pp
If using
.Ev MODRUBY_HANDLE_FLAVORS Ns = Ns Yes ,
it also appends to the following variables:
.Bl -tag -width Ds
.It Ev SUBST_VARS
Adds
.Ev GEM_BIN_SUFFIX
and
.Ev GEM_MAN_SUFFIX
to
.Ev SUBST_VARS
so that the PLISTs work on multiple Ruby versions.
.El
.Pp
The lang/ruby module sets the following variables:
.Bl -tag -width Ds
.It Ev GEM
The path to the appropriate
.Sy gem
binary for the current Ruby version (/usr/local/bin/gem${MODRUBY_BINREV}).
.It Ev GEM_BASE_BIN
The absolute path where the
.Sy gem
program will install the executable
files provided by the gem (if any) during the fake target.
.It Ev GEM_BASE_LIB
The absolute path where the
.Sy gem
program will install library files
provided by the gem during the fake target.
.It Ev GEM_BIN
The relative path under
.Ev PREFIX
where the package installs the gem's executable files.
.It Ev GEM_BIN_SUFFIX
The suffix to use for the gem's executable files, so that separate
.Ev FLAVOR Ns s
of the port do not conflict.
.It Ev GEM_EXTENSIONS_DIR
The relative path under
.Ev PREFIX
where the package installs Ruby-version specific files for Ruby gems
with C extensions.
.It Ev GEM_FLAGS
Option flags for
.Sy gem Cm install
when building the port.
.It Ev GEM_LIB
The relative path under
.Ev PREFIX
where Ruby gem files are stored for the Ruby version in use.
.It Ev GEM_MAN_SUFFIX
The suffix to use for the gem's manual pages, so that separate
.Ev FLAVOR Ns s
of the port do not conflict.
.It Ev MODRUBY_ADJ_FILES
A list of filename patterns that will automatically have
.Ev MODRUBY_RUBY_ADJ
called on them during pre\-configure.
.It Ev MODRUBY_ARCH
The platform-specific string used by Ruby for files installed
into platform-specific directories.
.It Ev MODRUBY_BINREV
The same as
.Ev MODRUBY_REV
except without the dot
.Pq Ql \&. ,
reflecting the suffix used by the
programs for the Ruby version in use.
.It Ev MODRUBY_BIN_RSPEC
The path to the rspec (rspec 3) binaries for the Ruby
version in use.
.It Ev MODRUBY_BUILD_DEPENDS
The same as
.Ev MODRUBY_RUN_DEPENDS .
It is designed to be used in
.Ev BUILD_DEPENDS
values for other ports depending on Ruby.
.It Ev MODRUBY_BUILDDEP
If Ruby does not need to be installed
while building the package(s), set to
.Cm \&No .
The default is
.Cm Yes .
.It Ev MODRUBY_FLAVOR
The FLAVOR to use for Ruby dependencies to ensure that
they use the same version of Ruby as the current port.
.It Ev MODRUBY_HANDLE_FLAVORS
Determines whether the port allows building with multiple
.Ev FLAVOR Ns s,
with each
.Ev FLAVOR
supporting a separate Ruby version.
.It Ev MODRUBY_LIBREV
The same as
.Ev MODRUBY_REV .
.It Ev MODRUBY_LIB_DEPENDS
The same as
.Ev MODRUBY_RUN_DEPENDS .
It is designed to be used in
.Ev LIB_DEPENDS
values for other ports depending on Ruby.
.It Ev MODRUBY_PKG_PREFIX
The prefix to use for packages built using the lang/ruby module,
if the port support building with multiple Ruby versions.
.It Ev MODRUBY_RELEXAMPLEDIR
The relative path under
.Ev PREFIX
where the package installs example files for non-Ruby gem ports.
.It Ev MODRUBY_REV
Includes the major and minor versions of the version of Ruby in use,
separated by a dot
.Pq Ql \&. .
The port can override the value to specify which Ruby version to use,
if the port sets or defaults to
.Ev MODRUBY_HANDLE_FLAVORS Ns =Yes .
.It Ev MODRUBY_RUBY_ADJ
A command that takes filename arguments and replaces
the
.Pa /usr/bin/env
ruby shebang lines with
.Ev RUBY .
.It Ev MODRUBY_RUN_DEPENDS
The port path for the Ruby version in use.
It is designed to be used in
.Ev RUN_DEPENDS
values for other ports depending on Ruby.
.It Ev MODRUBY_RUNDEP
If the packages do not depend on Ruby at runtime, set to
.Cm \&No .
The default is
.Cm Yes .
.It Ev MODRUBY_SITEARCHDIR
The relative path under
.Ev PREFIX
where the package installs platform-specific library files for non-Ruby gem
ports.
.It Ev MODRUBY_SITEDIR
The relative path under
.Ev PREFIX
where the package installs non-platform-specific library files for non-Ruby
gem ports.
.It Ev MODRUBY_TEST
Set to
.Cm ruby ,
.Cm rake ,
.Cm rspec3 ,
or
.Cm testrb
to choose the appropriate program to run the regress tests, if the port
includes tests.
.It Ev MODRUBY_TEST_ENV
Sets environment variables for the regress tests.
.It Ev MODRUBY_TEST_TARGET
Sets the argument to the regress test program.
.It Ev MODRUBY_WANTLIB
Includes the library-specs for the Ruby version in use.
.It Ev RAKE
The path to the
.Sy rake
program for the Ruby version in use (/usr/local/bin/rake${MODRUBY_BINREV}).
.It Ev RUBY
The path to the
.Xr ruby 1
program for the Ruby version in use (/usr/local/bin/ruby${MODRUBY_BINREV}).
.El
.Sh SEE ALSO
.Xr bsd.port.mk 5 ,
.Xr port-modules 5
|