[[multipkg]]
=== Multi binary package

Let's consider an upstream package *hello-1.1.tar.gz* and untar it to inspect files.

----
include::../hello-1.1/ref/step101.log[]
----

This is similar to the previously shown *hello-c-1.0.tar.gz*  but with a few additional files and changes.

The C source *hello.c* is the same one.

*Makefile* is updated to support *$(DESTDIR)* for all files.

----
include::../hello-1.1/ref/step102.log[]
----

There is an additional simple shell script *hello-sh*.

----
include::../hello-1.1/ref/step112.log[]
----

The *hello.data* file is a dummy data for this training.

Let's create a set of the following non-native binary Debian packages.

* *hello-c* : 'type'=*bin*, This package contains an ELF executable *hello* file compiled from the source file *hello.c*.
* *hello-c-dbg* : 'type'=*dbg*, This package contains debug symbols data of the ELF executable file *hello*.
* *hello-sh* : 'type'=*script*, This contains the shell script *hello-sh*.
* *hello-data* : 'type'=*data*, This contains the data file *hello.data*.

Since we are splitting the generated files into multiple packages, we package this in two steps.  The first step is the "*debmake -j* ..." command (see <<testbuild>>).

.The *debmake* execution (1st stage)
----
sys::[head -n2  ../hello-1.1/ref/step200.log]
 ...
 ... (snip)
 ...
sys::[tail -n5  ../hello-1.1/ref/step200.log]
----

.The parent directory after the "*debmake -j* ..." execution.
----
include::../hello-1.1/ref/step400.log[]
----

There are 2 log files in the parent directory.

.*hello.build-dep.log* generated by the *dpkg-depcheck* command
----
include::../hello-1.1/ref/step401.log[]
----

The build dependency to the *debhelper* package is always implemented by the *debmake* command.

The dependency to other packages (*libfakeroot:amd64*, *liblocale-gettext-perl*, *perl-modules*) seems to be false positives caused by the build tools used such as the *pdebuild* command.

For this packaging case, there is no additional package required be listed as the build dependency.

.*hello.install.log* listing files under the *debian/tmp* directory
----
include::../hello-1.1/ref/step402.log[]
----

Now we know what files are generated in the *debian/tmp* directory.

Let's start with the fresh source tree and build package from there.

.The *debmake* execution (2nd stage)
----
sys::[head -n5  ../hello-1.1/ref/step410.log]
 ...
sys::[grep -A 4 -e '^I: parse binary package settings:' ../hello-1.1/ref/step410.log]
 ...
sys::[grep -e '^I: debmake -x' ../hello-1.1/ref/step410.log]
 ...
sys::[tail -n4  ../hello-1.1/ref/step410.log]
----

Please note that the *debmake* command is run with the *-x2* option as the default for the new multi binary packages.

----
include::../hello-1.1/ref/step420.log[]
----

Let’s inspect generated template files.

.*debian/rules*:
----
include::../hello-1.1/ref/step421.log[]
----

This is essentially the standard *debian/rules* file with the *dh* command with *override_dh_strip* to create a debug package. (There are some commented out contents for you to customize it.)

.*debian/control*:
----
sys::[sed -n -e '1,/^ This package contains the compiled binary executable./p' ../hello-1.1/ref/step422.log]
 ...
 ... (snip)
 ...

sys::[sed -n -e '/^Package: hello-c-dbg/,$p' ../hello-1.1/ref/step422.log]
----

It is nice to see that the template files are generated with reasonable contents.

There are several template files under the *debian/* directory.  Let's customize them and erase unnecessary ones. (Here, we are skipping details required by the best practice.)

.Manual adjustments of *debian/**
----
include::../hello-1.1/ref/step430.log[]
----

You can create a non-native Debian package using the *debuild* command (or its equivalents) in this source tree.

----
sys::[head -n3  ../hello-1.1/ref/step500.log]
 ...
sys::[grep -B 1 -A 1 -e '^ fakeroot debian/rules clean' ../hello-1.1/ref/step500.log]
 ...
sys::[grep -A 1 -e '^ debian/rules build' ../hello-1.1/ref/step500.log]
 ...
sys::[grep -A 1 -e '^ fakeroot debian/rules binary' ../hello-1.1/ref/step500.log]
 ...
sys::[tail -n1  ../hello-1.1/ref/step500.log]
----

Let’s inspect the result.

.The generated files of version 1.0 by the *debuild* command:
----
include::../hello-1.1/ref/step600.log[]
----

.The source package contents of version 1.0:
----
include::../hello-1.1/ref/step701.log[]
----

.The binary package contents of version 1.0:
----
include::../hello-1.1/ref/step700.log[]
----

NOTE: For the normal multi binary package case, you must provide 'binarypackage'*.install* files for all binary packages (excluding *dbg* type ones).  The build result is split into the binary packages by moving files from the *debian/tmp/* directory to the directories named after the binary packages.
