<?xml version="1.0" encoding="UTF-8"?>
<!-- **************************************************************************
.... For copyright and licensing terms, see the file named COPYING.
.... **************************************************************************
.-->
<?xml-stylesheet href="docbook-xml.css" type="text/css"?>

<refentry id="pkg-buildpackage">

<refmeta xmlns:xi="http://www.w3.org/2001/XInclude">
<refentrytitle>pkg-buildpackage</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="manual">user commands</refmiscinfo>
<refmiscinfo class="source">redo</refmiscinfo>
<xi:include href="version.xml" />
</refmeta>

<refnamediv>
<refname>pkg-buildpackage</refname>
<refpurpose>helper utility for building package suites</refpurpose>
</refnamediv>

<refsynopsisdiv>
<cmdsynopsis>
<command>pkg-buildpackage</command>
<arg choice='opt'>-b</arg>
<arg choice='opt'>--uc</arg>
<group choice='opt'>
<arg choice='plain'>--nc</arg>
<arg choice='plain'>--no-pre-clean</arg>
</group>
<arg choice='opt'>--pre-clean</arg>
<group choice='opt'>
<arg choice='plain'>--rules-file</arg>
<arg choice='plain'>-R </arg>
<replaceable>rules-command</replaceable>
</group>
</cmdsynopsis>
</refsynopsisdiv>

<refsection><title>Description</title>

<para>
<command>pkg-buildpackage</command> uses <command><replaceable>rules-command</replaceable></command> to create a suite of packages.
What packages to create as part of the package suite, and how to create them, is entirely the private realm of <command><replaceable>rules-command</replaceable></command>.
</para>

<para>
<command><replaceable>rules-command</replaceable></command> defaults to <command>debian/rules</command> on Linux-based operating systems, and <command>bsd/rules</command> everywhere else.
If a substitute <command><replaceable>rules-command</replaceable></command> is given that unlike those does not contain a <quote>/</quote> character, then the value of the <envar>PATH</envar> environment variable is used to locate the command in the usual manner.
</para>

<para>
The <arg choice='plain'>-b</arg> and <arg choice='plain'>--uc</arg> options are compatibility options and are ignored.
<command>pkg-buildpackage</command> only builds binary packages; not source packages, which are not even a concept with some packaging systems.
It also has no direct involvement in package metadata, such as manifests, build info, description, and suchlike; and no mechanism for signing them.
</para>

<para>
Normally, <command>pkg-buildpackage</command> invokes <command><replaceable>rules-command</replaceable></command> three times:
</para>
<orderedlist>
<listitem><para>
<command><replaceable>rules-command</replaceable></command> <arg choice='plain'>clean</arg>
</para></listitem>
<listitem><para>
<command><replaceable>rules-command</replaceable></command> <arg choice='plain'>build</arg>
</para></listitem>
<listitem><para>
<command><replaceable>rules-command</replaceable></command> <arg choice='plain'>binary</arg>
</para></listitem>
</orderedlist>

<para>
The <arg choice='plain'>--nc</arg> and <arg choice='plain'>--no-pre-clean</arg> options cause the first invocation to be skipped.
The <arg choice='plain'>--pre-clean</arg> option is a compatibility option that is ignored, as cleaning is the default behaviour.
</para>

</refsection>

<refsection><title>The rules command</title>

<refsynopsisdiv>
<cmdsynopsis>
<command><replaceable>rules-command</replaceable></command>
<group choice='req'>
<arg choice='plain'>clean</arg>
<arg choice='plain'>build</arg>
<arg choice='plain'>binary</arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>

<para>
<command><replaceable>rules-command</replaceable></command> is an executable program that is invoked with subcommands:
</para>
<variablelist>
<varlistentry>
<term><arg choice='plain'>clean</arg></term>
<listitem><para>
Clean the staging areas for all packages, and any associated temporary areas.
</para></listitem>
</varlistentry>
<varlistentry>
<term><arg choice='plain'>build</arg></term>
<listitem><para>
Build the package contents from source into some work area.
</para></listitem>
</varlistentry>
<varlistentry>
<term><arg choice='plain'>binary</arg></term>
<listitem><para>
Copy the built package contents from the work area into the actual binary package staging areas, and run tools to build the binary packages from those staging areas.
</para></listitem>
</varlistentry>
</variablelist>

<para>
No shell is involved in executing <command><replaceable>rules-command</replaceable></command>.
It cannot be a shell function or alias, but it need not be a compiled program.
Indeed, the usual (but not required) implementation strategy is for it to be an executable <citerefentry><refentrytitle>Makefile</refentrytitle><manvolnum>5</manvolnum></citerefentry> beginning with an interpreter line telling the kernel to give it to <citerefentry><refentrytitle>make</refentrytitle><manvolnum>1</manvolnum></citerefentry> when executed.
</para>
<programlisting>#!/usr/bin/make -sf
</programlisting>

<para>
<command><replaceable>rules-command</replaceable></command> must not require superuser privileges when executed.
Where package file and directory contents are to be owned by <code>root</code> (the usual case) or any other specific user, <command><replaceable>rules-command</replaceable></command> must supersede any file and directory ownerships that it finds in the filesystem when it creates the manifest listings for packages and archives their contents, rather than attempt to change them.
<citerefentry><refentrytitle>pkg-gencontrol</refentrytitle><manvolnum>1</manvolnum></citerefentry> generates package manifests ignoring the actual file and directory ownerships, for example.
</para>

</refsection>

<refsection><title>See also</title>
<itemizedlist>
<listitem><para>
<citerefentry><refentrytitle>dpkg-buildpackage</refentrytitle><manvolnum>8</manvolnum></citerefentry> &#x2013; which shares the <arg choice='plain'>-R</arg> option with this command, and for which the <arg choice='plain'>-b</arg> option is an ignored compatibility option
</para></listitem>
<listitem><para>
<citerefentry><refentrytitle>deb-src-rules</refentrytitle><manvolnum>5</manvolnum></citerefentry> &#x2013; a slightly different and Debian&#x2010;specific view of a rules command
</para></listitem>
</itemizedlist>
</refsection>

<refsection><title>Author</title>
<para><author><personname><firstname>Jonathan</firstname> <surname>de Boyne Pollard</surname></personname></author></para>
</refsection>

</refentry>
