- are invoked in order using <filename>/bin/sh</filename>, should any fail APT
- will abort. APT will pass to the commands on standard input the
- filenames of all .deb files it is going to install, one per line.</para>
-
- <para>Version 2 of this protocol dumps more information, including the
- protocol version, the APT configuration space and the packages, files
- and versions being changed. Version 2 is enabled by setting
- <literal>DPkg::Tools::options::cmd::Version</literal> to 2. <literal>cmd</literal> is a
- command given to <literal>Pre-Install-Pkgs</literal>.</para></listitem>
+ are invoked in order using <filename>/bin/sh</filename>; should any fail APT
+ will abort. APT will pass the filenames of all .deb files it is going to
+ install to the commands, one per line on the requested file descriptor, defaulting
+ to standard input.</para>
+
+ <para>Version 2 of this protocol sends more information through the requested
+ file descriptor: a line with the text <literal>VERSION 2</literal>,
+ the APT configuration space, and a list of package actions with filename
+ and version information.</para>
+
+ <para>Each configuration directive line has the form
+ <literal>key=value</literal>. Special characters (equal signs, newlines,
+ nonprintable characters, quotation marks, and percent signs in
+ <literal>key</literal> and newlines, nonprintable characters, and percent
+ signs in <literal>value</literal>) are %-encoded. Lists are represented
+ by multiple <literal>key::=value</literal> lines with the same key. The
+ configuration section ends with a blank line.</para>
+
+ <para>Package action lines consist of five fields in Version 2: old version, direction
+ of version change (< for upgrades, > for downgrades, = for no
+ change), new version, action. The version fields are "-" for no version
+ at all (for example when installing a package for the first time; no
+ version is treated as earlier than any real version, so that is an
+ upgrade, indicated as <literal>- < 1.23.4</literal>). The action field
+ is "**CONFIGURE**" if the package is being configured, "**REMOVE**" if it
+ is being removed, or the filename of a .deb file if it is being
+ unpacked.</para>
+
+ <para>In Version 3 after each version field follows the architecture
+ of this version, which is "-" if there is no version, and a field showing
+ the MultiArch type "same", foreign", "allowed" or "none". Note that "none"
+ is an incorrect typename which is just kept to remain compatible, it
+ should be read as "no" and users are encouraged to support both.</para>
+
+ <para>The version of the protocol to be used for the command
+ <literal><replaceable>cmd</replaceable></literal> can be chosen by setting
+ <literal>DPkg::Tools::options::<replaceable>cmd</replaceable>::Version</literal>
+ accordingly, the default being version 1. If APT isn't supporting the requested
+ version it will send the information in the highest version it has support for instead.
+ </para>
+
+ <para>The file descriptor to be used to send the information can be requested with
+ <literal>DPkg::Tools::options::<replaceable>cmd</replaceable>::InfoFD</literal>
+ which defaults to <literal>0</literal> for standard input and is available since
+ version 0.9.11. Support for the option can be detected by looking for the environment
+ variable <envar>APT_HOOK_INFO_FD</envar> which contains the number of the used
+ file descriptor as a confirmation.</para>
+ </listitem>