<p>
Sometimes, unpacking one package requires that another package
be first unpacked <em>and</em> configured. In this case, the
- dependent package must specify this dependency in
+ depending package must specify this dependency in
the <tt>Pre-Depends</tt> control field.
</p>
identical behavior.
</p>
+ <p>
+ The following targets are required and must be implemented
+ by <file>debian/rules</file>: <tt>clean</tt>, <tt>binary</tt>,
+ <tt>binary-arch</tt>, <tt>binary-indep</tt>, and <tt>build</tt>.
+ These are the targets called by <prgn>dpkg-buildpackage</prgn>.
+ </p>
+
<p>
Since an interactive <file>debian/rules</file> script makes it
- impossible to auto-compile that package and also makes it
- hard for other people to reproduce the same binary
- package, all <em>required targets</em> must be
- non-interactive. At a minimum, required targets are the
- ones called by <prgn>dpkg-buildpackage</prgn>, namely,
- <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
- <em>binary-indep</em>, and <em>build</em>. It also follows
- that any target that these targets depend on must also be
+ impossible to auto-compile that package and also makes it hard
+ for other people to reproduce the same binary package, all
+ required targets must be non-interactive. It also follows that
+ any target that these targets depend on must also be
non-interactive.
</p>
<p>
- The targets are as follows (required unless stated otherwise):
+ The targets are as follows:
<taglist>
- <tag><tt>build</tt></tag>
+ <tag><tt>build</tt> (required)</tag>
<item>
<p>
The <tt>build</tt> target should perform all the
</p>
</item>
- <tag><tt>binary</tt>, <tt>binary-arch</tt>,
- <tt>binary-indep</tt>
+ <tag><tt>binary</tt> (required), <tt>binary-arch</tt>
+ (required), <tt>binary-indep</tt> (required)
</tag>
<item>
<p>
</p>
</item>
- <tag><tt>clean</tt></tag>
+ <tag><tt>clean</tt> (required)</tag>
<item>
<p>
This must undo any effects that the <tt>build</tt>
<p>
The architectures we build on and build for are determined
- by <prgn>make</prgn> variables using the utility
- <qref id="pkg-dpkg-architecture"><prgn>dpkg-architecture</prgn></qref>.
- You can determine the
- Debian architecture and the GNU style architecture
- specification string for the build machine (the machine type
- we are building on) as well as for the host machine (the
- machine type we are building for). Here is a list of
- supported <prgn>make</prgn> variables:
+ by <prgn>make</prgn> variables using the
+ utility <qref id="pkg-dpkg-architecture"><prgn>dpkg-architecture</prgn></qref>.
+ You can determine the Debian architecture and the GNU style
+ architecture specification string for the build architecture as
+ well as for the host architecture. The build architecture is
+ the architecture on which <file>debian/rules</file> is run and
+ the package build is performed. The host architecture is the
+ architecture on which the resulting package will be installed
+ and run. These are normally the same, but may be different in
+ the case of cross-compilation (building packages for one
+ architecture on machines of a different architecture).
+ </p>
+
+ <p>
+ Here is a list of supported <prgn>make</prgn> variables:
<list compact="compact">
<item>
<tt>DEB_*_ARCH</tt> (the Debian architecture)
<tt>DEB_*_GNU_TYPE</tt>)
</list>
where <tt>*</tt> is either <tt>BUILD</tt> for specification of
- the build machine or <tt>HOST</tt> for specification of the
- host machine.
+ the build architecture or <tt>HOST</tt> for specification of the
+ host architecture.
</p>
<p>
the <prgn>preinst</prgn> script cannot rely on any files
included in its package. Only essential packages and
pre-dependencies (<tt>Pre-Depends</tt>) may be assumed to be
- available. Pre-dependencies will be at least unpacked.
- They may be only unpacked or "Half-Configured", not
- completely configured, but only if a previous version of the
- pre-dependency was completely configured and the
- pre-dependency had not been removed since then.
+ available. Pre-dependencies will have been configured at
+ least once, but at the time the <prgn>preinst</prgn> is
+ called they may only be in an unpacked or "Half-Configured"
+ state if a previous version of the pre-dependency was
+ completely configured and has not been removed since then.
</item>
<tag><var>old-preinst</var> <tt>abort-upgrade</tt>
The files contained in the package will be unpacked. All
package dependencies will at least be unpacked. If there
are no circular dependencies involved, all package
- dependencies will be configured.
+ dependencies will be configured. For behavior in the case
+ of circular dependencies, see the discussion
+ in <ref id="binarydeps">.
</item>
<tag><var>old-postinst</var> <tt>abort-upgrade</tt>
foo's <tt>postinst abort-remove</tt> would be called with
bar only "Half-Installed".
</footnote>
+ The <prgn>postinst</prgn> should still attempt any actions
+ for which its dependencies are required, since they will
+ normally be available, but consider the correct error
+ handling approach if those actions fail. Aborting
+ the <prgn>postinst</prgn> action if commands or facilities
+ from the package dependencies are not available is often the
+ best approach.
</item>
</taglist>
</p>
previously been deconfigured and only be unpacked, at which
point subsequent package changes do not consider its
dependencies. Therefore, all <prgn>postrm</prgn> actions
- may only rely on essential packages and cannot assume that
- the package's dependencies are available.
+ may only rely on essential packages and must gracefully skip
+ any actions that require the package's dependencies if those
+ dependencies are unavailable.<footnote>
+ This is often done by checking whether the command or
+ facility the <prgn>postrm</prgn> intends to call is
+ available before calling it. For example:
+<example>
+if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
+ . /usr/share/debconf/confmodule
+ db_purge
+fi
+</example>
+ in <prgn>postrm</prgn> purges the <prgn>debconf</prgn>
+ configuration for the package
+ if <package>debconf</package> is installed.
+ </foonote>
</item>
<tag><var>new-postrm</var> <tt>failed-upgrade</tt>
broken at some point and the dependency requirements violated
for at least one package. Packages involved in circular
dependencies may not be able to rely on their dependencies being
- configured when being configured depending on which side of the
- break of the circular dependency loop they happen to be on. If
- one of the packages in the loop has no <prgn>postinst</prgn>
- script, then the cycle will be broken at that package; this
- ensures that all <prgn>postinst</prgn> scripts are run with
- their dependencies properly configured if this is possible.
- Otherwise the breaking point is arbitrary. Packages should
- therefore avoid circular dependencies where possible,
- particularly if they have <prgn>postinst</prgn> scripts.
+ configured before they themselves are configured, depending on
+ which side of the break of the circular dependency loop they
+ happen to be on. If one of the packages in the loop has
+ no <prgn>postinst</prgn> script, then the cycle will be broken
+ at that package; this ensures that all <prgn>postinst</prgn>
+ scripts are run with their dependencies properly configured if
+ this is possible. Otherwise the breaking point is arbitrary.
+ Packages should therefore avoid circular dependencies where
+ possible, particularly if they have <prgn>postinst</prgn>
+ scripts.
</p>
<p>
least unpacked, but they may be only "Half-Installed" if a
previous upgrade of the dependency failed.
</p>
+
+ <p>
+ Finally, the <tt>Depends</tt> field should be used if the
+ depended-on package is needed by the <prgn>postrm</prgn>
+ script to fully clean up after the package removal. There
+ is no guarantee that package dependencies will be
+ available when <prgn>postrm</prgn> is run, but the
+ depended-on package is more likely to be available if the
+ package declares a dependency (particularly in the case
+ of <tt>postrm remove</tt>). The <prgn>postrm</prgn>
+ script must gracefully skip actions that require a
+ dependency if that dependency isn't available.
+ </p>
</item>
<tag><tt>Recommends</tt></tag>