[[singlepkg]]
=== Single binary package

For the case of creating a single binary Debian package from the *$(DESTDIR)* and Filesystem Hierarchy Standard (FHS) supporting source, the packaging process can be practically automatic if you only wish to make it for your local use and do not worry about details of the Debian Policy.

Let's assume you have a simple upstream source tarball *hello-c-1.0.tar.gz*.

----
include::../hello-c-1.0/ref/step001.log[]
----

Let's untar it.

----
include::../hello-c-1.0/ref/step100.log[]
----

Let's inspect files.

----
include::../hello-c-1.0/ref/step101.log[]
----

*Makefile* supports *$(DESTDIR)*.

----
include::../hello-c-1.0/ref/step102.log[]
----

The C source *hello.c* is a very simple one.

----
include::../hello-c-1.0/ref/step110.log[]
----

You create a non-native Debian package source tree from this upstream example using the *debmake* command.

----
include::../hello-c-1.0/ref/step200.log[]
----

Let’s inspect generated template files.

.*debian/rules*:
----
include::../hello-c-1.0/ref/step201.log[]
----

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

TIP: Configuration files used by the *dh_** commands from the *debhelper* package usually treat *#* as the start of the comment line.

.*debian/control*:
----
include::../hello-c-1.0/ref/step202.log[]
----

Please note that the *debmake* command is run with the *-x1* option as the default for the new single binary package.

Since this is the ELF binary executable package ('type'=*bin*), it is set to "*Architecture: any*" and "*Multi-Arch: foreign*".  Also, required *substvar* parameters are set as "*Depends: $\{shlibs:Depends}, $\{misc:Depends}*" by the *debmake* command.

NOTE: Please note this *debian/control* file uses the RFC-822 style as documented in the ``Debian Policy Manual: 5.2 Source package control files -- debian/control''. The use of the empty line and the leading space are significant.

There are several other template files under the *debian/* directory.

.The source tree after the basic *debmake* execution.
----
include::../hello-c-1.0/ref/step400.log[]
----

For the proper packaging, you are required to make further modification here. 

For learning purpose, let's leave such details and move on. You can create a non-native Debian package using the *debuild* command (or its equivalents) in this source tree.

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

Let’s inspect the result.

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

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

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

