pkg
Subdirectorypkg
SubdirectoryThere are some tricks we haven't mentioned yet about the
pkg
subdirectory that come in handy sometimes.
MESSAGE
If you need to display a
message to the installer, you may place the message in
pkg/MESSAGE
. This capability is often useful to
display additional installation steps to be taken after a
pkg_add
, or to display licensing information. Note the
pkg/MESSAGE
file does not need to be added to
pkg/PLIST
. Also, it will not get automatically
printed if the user is using the port, not the package, so
you should probably display it from the post-install
target by yourself.
INSTALL
If your port needs to execute commands when the binary package
is installed with pkg_add
you can do this via the pkg/INSTALL
script. This script will automatically be added to the
package, and will be run twice by pkg_add. The first time
will as `INSTALL ${PKGNAME} PRE-INSTALL
'
and the second time as `INSTALL ${PKGNAME} POST-INSTALL
'.
`$2
' can be tested to determine which mode
the script is being run in.
The `PKG_PREFIX
' environmental variable will be set to
the package installation directory. See man pkg_add(1)
for additional information.
Note, that this script is not run automatically if you install
the port with `make install
'. If you are depending
on it being run, you will have to explicitly call it from your
port's Makefile.
REQ
If your port needs to determine if it should install or
not, you can create a pkg/REQ
``requirements''
script. It will be invoked automatically at
installation/deinstallation time to determine whether or not
installation/deinstallation should proceed.
PLIST
based on make variablesSome ports, particularly the p5- ports, need to change
their 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 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., `2.2.7'). %%PERL_VERSION%%
is
the full version number of perl (e.g., `5.00502') and
%%PERL_VER%%
is the perl version number minus the
patchlevel (e.g., `5.005').
If you need to make other substitutions, you
can set the PLIST_SUB
variable with a list of
VAR=VALUE
pairs and instances of `%%VAR%%
'
will be substituted with `VALUE
' in the 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 PLIST
. That way, when
you upgrade the port, you will not have to change dozens (or
in some cases, hundreds) of lines in the PLIST
.
This substitution (as well as addition of any
man pages) will be done
between the do-install
and post-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 do-install
. Also, if your port needs to edit
the resulting file, do so in post-install
to a file
named ${TMPPLIST}
.
pkg
subdirectoryAll the filenames in the pkg
subdirectory are defined
using variables so you can change them in your Makefile if
need be. This is especially useful when you are sharing the
same pkg
subdirectory among several ports or have to
write to one of the above files (see
writing to places other than WRKDIR for why it is a bad idea to write directly into the
pkg
subdirectory).
Here is a list of variable names and their default values.
COMMENT ${PKGDIR}/COMMENT
DESCR ${PKGDIR}/DESCR
PLIST ${PKGDIR}/PLIST
PKGINSTALL ${PKGDIR}/INSTALL
PKGDEINSTALL ${PKGDIR}/DEINSTALL
PKGREQ ${PKGDIR}/REQ
PKGMESSAGE ${PKGDIR}/MESSAGE
Please change these variables rather than overriding
PKG_ARGS
. If you change PKG_ARGS
, those
files will not correctly be installed in
/var/db/pkg
upon install from a port.
pkg
Subdirectory