Some ports, particularly the p5-
ports,
need to change their pkg-plist
depending on
what options they are configured with (or version of
perl
, in the case of p5-
ports). To make this easy, any instances in the
pkg-plist
of %%OSREL%%
,
%%PERL_VER%%
, and
%%PERL_VERSION%%
will be substituted for
appropriately. The value of %%OSREL%%
is the
numeric revision of the operating system (e.g.,
4.9
). %%PERL_VERSION%%
and %%PERL_VER%%
is the full version number
of perl
(e.g., 5.8.9
).
Several other
%%
related
to port's documentation files are described in the relevant
section.VARS
%%
If you need to make other substitutions, you can set the
PLIST_SUB
variable with a list of
pairs and instances of
VAR
=VALUE
%%
will be
substituted with VAR
%%VALUE
in the
pkg-plist
.
For instance, if you have a port that installs many files in a version-specific subdirectory, you can put something like
OCTAVE_VERSION= 2.0.13 PLIST_SUB= OCTAVE_VERSION=${OCTAVE_VERSION}
in the Makefile
and use
%%OCTAVE_VERSION%%
wherever the version shows
up in pkg-plist
. That way, when you
upgrade the port, you will not have to change dozens (or in some
cases, hundreds) of lines in the
pkg-plist
.
If your port installs files conditionally on the options
set in the port, the usual way of handling it is prefixing the
pkg-plist
lines with a
%%OPT%%
for lines needed when the option is
enabled, or %%NO_OPT%%
when the option is
disabled, and adding OPTIONS_SUB=yes
to the
Makefile
. See Section 5.12.3.1, “OPTIONS_SUB
” for more information.
For instance, if there are files that are only installed
when the X11
option is enabled, and the
Makefile
has:
OPTIONS_DEFINE= X11 OPTIONS_SUB= yes
In the pkg-plist
file, put
%%X11%%
in front of the lines only being
installed when the option is enabled, like this :
%%X11%%bin/foo-gui
This substitution will be done between the
pre-install
and
do-install
targets, by reading from
PLIST
and writing to
TMPPLIST
(default:
WRKDIR/.PLIST.mktmp
). So if your port
builds PLIST
on the fly, do so in or before
pre-install
. Also, if your port
needs to edit the resulting file, do so in
post-install
to a file named
TMPPLIST
.
Another way of modifying a port's packing list is based on
setting the variables PLIST_FILES
,
PLIST_DIRS
, and
PLIST_DIRSTRY
. The value of each variable is
regarded as a list of pathnames to write to
TMPPLIST
along with
PLIST
contents. Names listed in
PLIST_FILES
, PLIST_DIRS
,
and PLIST_DIRSTRY
are subject to
%%
substitution as described above. Except for that, names from
VAR
%%PLIST_FILES
will appear in the final packing
list unchanged, while @dirrm
and
@dirrmtry
will be prepended to names from
PLIST_DIRS
and
PLIST_DIRSTRY
, respectively. To take effect,
PLIST_FILES
, PLIST_DIRS
,
and PLIST_DIRSTRY
must be set before
TMPPLIST
is written, i.e., in
pre-install
or earlier.
From time to time, the OPTIONS_SUB
construct is not enough, in those cases, adding a specific
TAG
to the PLIST_SUB
variable inside the Makefile
with a special
value of @comment
, makes package tools to
ignore the line. For instance, if some files are only installed
when the X11
option is on and the
architecture is i386
:
.include <bsd.port.pre.mk> .if ${PORT_OPTIONS:MX11} && ${ARCH} == "i386" PLIST_SUB+= X11I386="" .else PLIST_SUB+= X11I386="@comment " .endif
All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.