Whitespace-only fixes, translators please ignore.

This commit is contained in:
Warren Block 2014-02-09 04:05:25 +00:00
parent c943775a5b
commit ab87e4711c
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=43850

View file

@ -5,127 +5,121 @@
$FreeBSD$ $FreeBSD$
--> -->
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="plist"> <chapter xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"
xml:id="plist">
<title>Advanced <filename>pkg-plist</filename> Practices</title> <title>Advanced <filename>pkg-plist</filename> Practices</title>
<sect1 xml:id="plist-sub"> <sect1 xml:id="plist-sub">
<title>Changing <filename>pkg-plist</filename> Based on Make <title>Changing <filename>pkg-plist</filename> Based on Make
Variables</title> Variables</title>
<para>Some ports, particularly the <literal>p5-</literal> ports, <para>Some ports, particularly the <literal>p5-</literal> ports,
need to change their <filename>pkg-plist</filename> depending need to change their <filename>pkg-plist</filename> depending on
on what options they are configured with (or version of what options they are configured with (or version of
<literal>perl</literal>, in the case of <literal>p5-</literal> <literal>perl</literal>, in the case of <literal>p5-</literal>
ports). To make this easy, any instances in the ports). To make this easy, any instances in the
<filename>pkg-plist</filename> of <filename>pkg-plist</filename> of <literal>%%OSREL%%</literal>,
<literal>%%OSREL%%</literal>, <literal>%%PERL_VER%%</literal>, <literal>%%PERL_VER%%</literal>, and
and <literal>%%PERL_VERSION%%</literal> will be substituted <literal>%%PERL_VERSION%%</literal> will be substituted for
for appropriately. The value of <literal>%%OSREL%%</literal> appropriately. The value of <literal>%%OSREL%%</literal> is the
is the numeric revision of the operating system (e.g., numeric revision of the operating system (e.g.,
<literal>4.9</literal>). <literal>%%PERL_VERSION%%</literal> <literal>4.9</literal>). <literal>%%PERL_VERSION%%</literal>
and <literal>%%PERL_VER%%</literal> is the full version number and <literal>%%PERL_VER%%</literal> is the full version number
of <command>perl</command> (e.g., <literal>5.8.9</literal>). of <command>perl</command> (e.g., <literal>5.8.9</literal>).
Several other Several other <literal>%%VARS%%</literal> related to port's
<literal>%%VARS%%</literal> related documentation files are described in
to port's documentation files are described in <link linkend="install-documentation">the relevant
<link linkend="install-documentation">the relevant section</link>.</para>
section</link>.</para>
<para>If you need to make other substitutions, you can set the <para>If you need to make other substitutions, you can set the
<varname>PLIST_SUB</varname> variable with a list of <varname>PLIST_SUB</varname> variable with a list of
<literal>VAR=VALUE</literal> <literal>VAR=VALUE</literal> pairs and instances of
pairs and instances of <literal>%%VAR%%</literal> will be substituted with
<literal>%%VAR%%</literal> will be <replaceable>VALUE</replaceable> in the
substituted with <replaceable>VALUE</replaceable> in the <filename>pkg-plist</filename>.</para>
<filename>pkg-plist</filename>.</para>
<para>For instance, if you have a port that installs many files <para>For instance, if you have a port that installs many files
in a version-specific subdirectory, you can put something in a version-specific subdirectory, you can put something
like</para> like</para>
<programlisting>OCTAVE_VERSION= 2.0.13 <programlisting>OCTAVE_VERSION= 2.0.13
PLIST_SUB= OCTAVE_VERSION=${OCTAVE_VERSION}</programlisting> PLIST_SUB= OCTAVE_VERSION=${OCTAVE_VERSION}</programlisting>
<para>in the <filename>Makefile</filename> and use <para>in the <filename>Makefile</filename> and use
<literal>%%OCTAVE_VERSION%%</literal> wherever the version <literal>%%OCTAVE_VERSION%%</literal> wherever the version shows
shows up in <filename>pkg-plist</filename>. That way, when up in <filename>pkg-plist</filename>. That way, when you
you upgrade the port, you will not have to change dozens (or upgrade the port, you will not have to change dozens (or in some
in some cases, hundreds) of lines in the cases, hundreds) of lines in the
<filename>pkg-plist</filename>.</para> <filename>pkg-plist</filename>.</para>
<para>If your port installs files conditionally on the options <para>If your port installs files conditionally on the options
set in the port, the usual way of handling it is prefixing the set in the port, the usual way of handling it is prefixing the
<filename>pkg-plist</filename> lines with a <filename>pkg-plist</filename> lines with a
<literal>%%TAG%%</literal> and adding that <literal>%%TAG%%</literal> and adding that
<literal>TAG</literal> to the <varname>PLIST_SUB</varname> <literal>TAG</literal> to the <varname>PLIST_SUB</varname>
variable inside the <filename>Makefile</filename> with a variable inside the <filename>Makefile</filename> with a special
special value of <literal>@comment</literal>, which makes value of <literal>@comment</literal>, which makes package tools
package tools to ignore the line:</para> to ignore the line:</para>
<programlisting>.if defined(WITH_X11) <programlisting>.if defined(WITH_X11)
PLIST_SUB+= X11="" PLIST_SUB+= X11=""
.else .else
PLIST_SUB+= X11="@comment " PLIST_SUB+= X11="@comment "
.endif</programlisting> .endif</programlisting>
<para>and in the <filename>pkg-plist</filename>:</para> <para>and in the <filename>pkg-plist</filename>:</para>
<programlisting>%%X11%%bin/foo-gui</programlisting> <programlisting>%%X11%%bin/foo-gui</programlisting>
<para>This substitution <para>This substitution will be done between the
will be <buildtarget>pre-install</buildtarget> and
done between the <buildtarget>pre-install</buildtarget> and <buildtarget>do-install</buildtarget> targets, by reading from
<buildtarget>do-install</buildtarget> targets, by reading from <filename>PLIST</filename> and writing to
<filename>PLIST</filename> and writing to <filename>TMPPLIST</filename> (default:
<filename>TMPPLIST</filename> (default: <filename>WRKDIR/.PLIST.mktmp</filename>). So if your port
<filename>WRKDIR/.PLIST.mktmp</filename>). builds <filename>PLIST</filename> on the fly, do so in or before
So if your port builds <buildtarget>pre-install</buildtarget>. Also, if your port
<filename>PLIST</filename> on the fly, do needs to edit the resulting file, do so in
so in or before <buildtarget>pre-install</buildtarget>. Also, <buildtarget>post-install</buildtarget> to a file named
if your port needs to edit the resulting file, do so in <filename>TMPPLIST</filename>.</para>
<buildtarget>post-install</buildtarget> to a file named
<filename>TMPPLIST</filename>.</para>
<para>Another way of modifying a port's packing list is based <para>Another way of modifying a port's packing list is based on
on setting the variables <varname>PLIST_FILES</varname>, setting the variables <varname>PLIST_FILES</varname>,
<varname>PLIST_DIRS</varname>, and <varname>PLIST_DIRS</varname>, and
<varname>PLIST_DIRSTRY</varname>. The value of each variable <varname>PLIST_DIRSTRY</varname>. The value of each variable is
is regarded as a list of pathnames to write to regarded as a list of pathnames to write to
<filename>TMPPLIST</filename> along with <filename>TMPPLIST</filename> along with
<filename>PLIST</filename> contents. Names <filename>PLIST</filename> contents. Names listed in
listed in <varname>PLIST_FILES</varname>, <varname>PLIST_FILES</varname>, <varname>PLIST_DIRS</varname>,
<varname>PLIST_DIRS</varname>, and and <varname>PLIST_DIRSTRY</varname> are subject to
<varname>PLIST_DIRSTRY</varname> are subject to <literal>%%VAR%%</literal> substitution as described above.
<literal>%%VAR%%</literal> Except for that, names from <varname>PLIST_FILES</varname> will
substitution as described above. Except for that, names from appear in the final packing list unchanged, while
<varname>PLIST_FILES</varname> will appear in the final <literal>@dirrm</literal> and <literal>@dirrmtry</literal> will
packing list unchanged, while <literal>@dirrm</literal> and be prepended to names from <varname>PLIST_DIRS</varname> and
<literal>@dirrmtry</literal> will <varname>PLIST_DIRSTRY</varname>, respectively. To take effect,
be prepended to names from <varname>PLIST_DIRS</varname> <varname>PLIST_FILES</varname>, <varname>PLIST_DIRS</varname>,
and <varname>PLIST_DIRSTRY</varname>, respectively. To and <varname>PLIST_DIRSTRY</varname> must be set before
take effect, <varname>PLIST_FILES</varname>, <filename>TMPPLIST</filename> is written, i.e., in
<varname>PLIST_DIRS</varname>, and <buildtarget>pre-install</buildtarget> or earlier.</para>
<varname>PLIST_DIRSTRY</varname> must be set before </sect1>
<filename>TMPPLIST</filename> is written,
i.e., in <buildtarget>pre-install</buildtarget> or
earlier.</para>
</sect1>
<sect1 xml:id="plist-cleaning"> <sect1 xml:id="plist-cleaning">
<title>Empty Directories</title> <title>Empty Directories</title>
<sect2 xml:id="plist-dir-cleaning"> <sect2 xml:id="plist-dir-cleaning">
<title>Cleaning Up Empty Directories</title> <title>Cleaning Up Empty Directories</title>
<para>Do make your ports remove empty directories when they <para>Do make your ports remove empty directories when they are
are de-installed. This is usually accomplished by adding de-installed. This is usually accomplished by adding
<literal>@dirrm</literal> lines for all directories that are <literal>@dirrm</literal> lines for all directories that are
specifically created by the port. You need to delete specifically created by the port. You need to delete
subdirectories before you can delete parent subdirectories before you can delete parent
directories.</para> directories.</para>
<programlisting> : <programlisting> :
lib/X11/oneko/pixmaps/cat.xpm lib/X11/oneko/pixmaps/cat.xpm
lib/X11/oneko/sounds/cat.au lib/X11/oneko/sounds/cat.au
: :
@ -133,156 +127,151 @@ lib/X11/oneko/sounds/cat.au
@dirrm lib/X11/oneko/sounds @dirrm lib/X11/oneko/sounds
@dirrm lib/X11/oneko</programlisting> @dirrm lib/X11/oneko</programlisting>
<para>However, sometimes <literal>@dirrm</literal> will give <para>However, sometimes <literal>@dirrm</literal> will give
you errors because other ports share the same directory. you errors because other ports share the same directory. You
You can use <literal>@dirrmtry</literal> to remove only can use <literal>@dirrmtry</literal> to remove only empty
empty directories without warning.</para> directories without warning.</para>
<programlisting>@dirrmtry share/doc/gimp</programlisting> <programlisting>@dirrmtry share/doc/gimp</programlisting>
<para>This will neither print any error messages nor cause <para>This will neither print any error messages nor cause
<command>pkg delete</command> (see &man.pkg-delete.8;) to <command>pkg delete</command> (see &man.pkg-delete.8;) to
exit abnormally even if exit abnormally even if
<filename>${PREFIX}/share/doc/gimp</filename> is not empty <filename>${PREFIX}/share/doc/gimp</filename> is not empty
due to other ports installing some files in there.</para> due to other ports installing some files in there.</para>
</sect2> </sect2>
<sect2 xml:id="plist-dir-empty"> <sect2 xml:id="plist-dir-empty">
<title>Creating Empty Directories</title> <title>Creating Empty Directories</title>
<para>Empty directories created during port installation need <para>Empty directories created during port installation need
special attention. They will not get created when special attention. They will not get created when installing
installing the package, because packages only store the the package, because packages only store the files, and both
files, and both <command>pkg add</command> and <command>pkg <command>pkg add</command> and <command>pkg install</command>
install</command> creates directories for them as needed. creates directories for them as needed. To make sure the
To make sure the empty directory is created when installing empty directory is created when installing the package, add
the package, add this line to <filename>pkg-plist</filename> this line to <filename>pkg-plist</filename> above the
above the corresponding <literal>@dirrm</literal> corresponding <literal>@dirrm</literal> line:</para>
line:</para>
<programlisting>@exec mkdir -p %D/share/foo/templates</programlisting> <programlisting>@exec mkdir -p %D/share/foo/templates</programlisting>
</sect2> </sect2>
</sect1> </sect1>
<sect1 xml:id="plist-config"> <sect1 xml:id="plist-config">
<title>Configuration Files</title> <title>Configuration Files</title>
<para>If your port installs configuration files to <para>If your port installs configuration files to
<filename>PREFIX/etc</filename> (or <filename>PREFIX/etc</filename> (or elsewhere) do
elsewhere) do <emphasis>not</emphasis> simply list them in the <emphasis>not</emphasis> simply list them in the
<filename>pkg-plist</filename>. That will cause <command>pkg <filename>pkg-plist</filename>. That will cause
delete</command> to remove the files carefully edited by the <command>pkg delete</command> to remove the files carefully
user, and a re-installation will wipe them out.</para> edited by the user, and a re-installation will wipe them
out.</para>
<para>Instead, install sample file(s) with a <para>Instead, install sample file(s) with a
<filename>filename.sample</filename> <filename>filename.sample</filename> suffix. Then copy the
suffix. Then copy the sample file to the real configuration sample file to the real configuration file name, if it does not
file name, if it does not already exist. On deinstall already exist. On deinstall delete the configuration file, but
delete the configuration file, but only if it is identical only if it is identical to the <filename>.sample</filename>
to the <filename>.sample</filename> file. file. You need to handle this both in the port
You need to handle this both in the port <filename>Makefile</filename>, and in the
<filename>Makefile</filename>, and in the <filename>pkg-plist</filename> (for installation from the
<filename>pkg-plist</filename> (for installation from the package).</para>
package).</para>
<para>Example of the <filename>Makefile</filename> part:</para> <para>Example of the <filename>Makefile</filename> part:</para>
<programlisting>post-install: <programlisting>post-install:
@if [ ! -f ${PREFIX}/etc/orbit.conf ]; then \ @if [ ! -f ${PREFIX}/etc/orbit.conf ]; then \
${CP} -p ${PREFIX}/etc/orbit.conf.sample ${STAGEDIR}${PREFIX}/etc/orbit.conf ; \ ${CP} -p ${PREFIX}/etc/orbit.conf.sample ${STAGEDIR}${PREFIX}/etc/orbit.conf ; \
fi</programlisting> fi</programlisting>
<para>For each configuration file, create the following three <para>For each configuration file, create the following three
lines in <filename>pkg-plist</filename>:</para> lines in <filename>pkg-plist</filename>:</para>
<programlisting>@unexec if cmp -s %D/etc/orbit.conf.sample %D/etc/orbit.conf; then rm -f %D/etc/orbit.conf; fi <programlisting>@unexec if cmp -s %D/etc/orbit.conf.sample %D/etc/orbit.conf; then rm -f %D/etc/orbit.conf; fi
etc/orbit.conf.sample etc/orbit.conf.sample
@exec if [ ! -f %D/etc/orbit.conf ] ; then cp -p %D/%F %B/orbit.conf; fi</programlisting> @exec if [ ! -f %D/etc/orbit.conf ] ; then cp -p %D/%F %B/orbit.conf; fi</programlisting>
<para>The order of these lines is important. On deinstallation, <para>The order of these lines is important. On deinstallation,
the sample file is compared to the actual configuration file. the sample file is compared to the actual configuration file.
If these files are identical, no changes have been made by the If these files are identical, no changes have been made by the
user and the actual file can be safely deleted. Because the user and the actual file can be safely deleted. Because the
sample file must still exist for the comparison, the sample file must still exist for the comparison, the
<literal>@unexec</literal> line comes before the sample <literal>@unexec</literal> line comes before the sample
configuration file name. On installation, if an actual configuration file name. On installation, if an actual
configuration file is not already present, the sample file is configuration file is not already present, the sample file is
copied to the actual file. The sample file must be present copied to the actual file. The sample file must be present
before it can be copied, so the <literal>@exec</literal> line before it can be copied, so the <literal>@exec</literal> line
comes after the sample configuration file name.</para> comes after the sample configuration file name.</para>
<para>To debug any issues, temporarily remove the <para>To debug any issues, temporarily remove the
<literal>-s</literal> flag to &man.cmp.1; for more <literal>-s</literal> flag to &man.cmp.1; for more
output.</para> output.</para>
<para>See &man.pkg-create.8; for more information on <para>See &man.pkg-create.8; for more information on
<literal>%D</literal> and related substitution markers.</para> <literal>%D</literal> and related substitution markers.</para>
<para>If there is a very good reason not to install a working <para>If there is a very good reason not to install a working
configuration file by default, leave the configuration file by default, leave the
<literal>@exec</literal> line out of <literal>@exec</literal> line out of
<filename>pkg-plist</filename> and add a <filename>pkg-plist</filename> and add a
<link linkend="porting-message">message</link> pointing out <link linkend="porting-message">message</link> pointing out that
that the user must copy and edit the file before the software the user must copy and edit the file before the software will
will work.</para> work.</para>
</sect1> </sect1>
<sect1 xml:id="plist-dynamic"> <sect1 xml:id="plist-dynamic">
<title>Dynamic Versus Static Package List</title> <title>Dynamic Versus Static Package List</title>
<para>A <emphasis>static package list</emphasis> is a package <para>A <emphasis>static package list</emphasis> is a package
list which is available in the Ports Collection either as a list which is available in the Ports Collection either as a
<filename>pkg-plist</filename> file (with or without variable <filename>pkg-plist</filename> file (with or without variable
substitution), or embedded into the substitution), or embedded into the
<filename>Makefile</filename> via <filename>Makefile</filename> via
<varname>PLIST_FILES</varname>, <varname>PLIST_FILES</varname>, <varname>PLIST_DIRS</varname>,
<varname>PLIST_DIRS</varname>, and and <varname>PLIST_DIRSTRY</varname>. Even if the contents are
<varname>PLIST_DIRSTRY</varname>. Even if the contents are auto-generated by a tool or a target in the Makefile
auto-generated by a tool or a target in the Makefile <emphasis>before</emphasis> the inclusion into the Ports
<emphasis>before</emphasis> the inclusion into the Ports Collection by a committer, this is still considered a static
Collection by a committer, this is still considered a static list, since it is possible to examine it without having to
list, since it is possible to examine it without having to download or compile the distfile.</para>
download or compile the distfile.</para>
<para>A <emphasis>dynamic package list</emphasis> is a package <para>A <emphasis>dynamic package list</emphasis> is a package
list which is generated at the time the port is compiled based list which is generated at the time the port is compiled based
upon the files and directories which are installed. It is not upon the files and directories which are installed. It is not
possible to examine it before the source code of the ported possible to examine it before the source code of the ported
application is downloaded and compiled, or after running a application is downloaded and compiled, or after running a
<literal>make clean</literal>.</para> <literal>make clean</literal>.</para>
<para>While the use of dynamic package lists is not forbidden, <para>While the use of dynamic package lists is not forbidden,
maintainers should use static package lists wherever possible, maintainers should use static package lists wherever possible,
as it enables users to &man.grep.1; through available ports to as it enables users to &man.grep.1; through available ports to
discover, for example, which port installs a certain file. discover, for example, which port installs a certain file.
Dynamic lists should be primarily used for complex ports where Dynamic lists should be primarily used for complex ports where
the package list changes drastically based upon optional the package list changes drastically based upon optional
features of the port (and thus maintaining a static package features of the port (and thus maintaining a static package list
list is infeasible), or ports which change the package list is infeasible), or ports which change the package list based
based upon the version of dependent software used (e.g., ports upon the version of dependent software used (e.g., ports which
which generate docs with generate docs with <application>Javadoc</application>).</para>
<application>Javadoc</application>).</para> </sect1>
</sect1>
<sect1 xml:id="plist-autoplist"> <sect1 xml:id="plist-autoplist">
<title>Automated Package List Creation</title> <title>Automated Package List Creation</title>
<para>First, make sure your port is almost complete, with only <para>First, make sure your port is almost complete, with only
<filename>pkg-plist</filename> missing. You may then run <filename>pkg-plist</filename> missing. You may then run
<command>make makeplist</command> to <command>make makeplist</command> to generate a
generate a <filename>pkg-plist</filename> automatically. This <filename>pkg-plist</filename> automatically. This file must be
file must be double checked for correctness.</para> double checked for correctness.</para>
<para>User configuration files should be
removed, or installed as
<filename>filename.sample</filename>.
The <filename>info/dir</filename> file should not be listed
and appropriate <filename>install-info</filename> lines should
be added as noted in the
<link linkend="makefile-info">info files</link> section. Any
libraries installed by the port should be listed as specified
in the <link linkend="porting-shlibs">shared libraries</link>
section.</para>
</sect1>
</chapter>
<para>User configuration files should be removed, or installed as
<filename>filename.sample</filename>. The
<filename>info/dir</filename> file should not be listed and
appropriate <filename>install-info</filename> lines should be
added as noted in the
<link linkend="makefile-info">info files</link> section. Any
libraries installed by the port should be listed as specified in
the <link linkend="porting-shlibs">shared libraries</link>
section.</para>
</sect1>
</chapter>