[[librarypkg]]
=== Library package

Let's consider an upstream package *libkkc-0.3.2.tar.gz*.

.Step 0: Untar ...
----
sys::[head -n8  ../remote-lib_a/ref/step100.log]
 ...
 ... (snip)
 ...
sys::[tail -n6  ../remote-lib_a/ref/step100.log]
----

Let's make a test build this with the *-j* option (see <<testbuild>>).

.Step 1: *debmake -j*
----
sys::[head -n8  ../remote-lib_a/ref/step200.log]
 ...
 ... (snip)
 ...
sys::[tail -n7  ../remote-lib_a/ref/step200.log]
----

Let's inspect the package dependency.

.*libkkc.build-dep.log*
----
include::../remote-lib_a/ref/step201.log[]
----

Let's inspect the generated files.

.*libkkc.install.log*
----
sys::[head -n9  ../remote-lib_a/ref/step202.log]
 ...
 ... (snip)
 ...
sys::[tail -n5  ../remote-lib_a/ref/step202.log]
----

Let's clean the source tree first.
----
sys::[head -n5  ../remote-lib_a/ref/step203.log]
 ...
 ... (snip)
 ...
sys::[tail -n3  ../remote-lib_a/ref/step203.log]
----

Let's create the fresh source tree with the following package split plan.

|====
|'binarypackage'    |'type' |*-b* option
|*libkkc2*          |*lib*  |*libkkc2*
|*libkkc-utils*     |*bin*  |*-utils*
|*libkkc2-dbg*      |*dbg*  |*libkkc2-dbg*
|*libkkc-utils-dbg* |*dbg*  |*-utils-dbg*
|*libkkc-dev*       |*dev*  |*-dev*
|*libkkc-common*    |*data* |*-common:data*
|====

----
sys::[head -n10  ../remote-lib_a/ref/step210.log]
 ...
 ... (snip)
 ...
sys::[tail -n7  ../remote-lib_a/ref/step210.log]
----

Let's commit this result.

----
sys::[head -n5  ../remote-lib_a/ref/step220.log]
 ...
 ... (snip)
 ...
----

This generates the following source tree. (Too large to list here.)

----
sys::[head -n15  ../remote-lib_a/ref/step400.log]
 ...
 ... (snip)
 ...
sys::[tail -n15  ../remote-lib_a/ref/step400.log]
----

Let's make manual modifications to the files under the *debian* directory.

.*changelog*
----
include::../remote-lib_a/ref/step401.log[]
----

.*compat*
----
include::../remote-lib_a/ref/step402.log[]
----

.*control*
----
include::../remote-lib_a/ref/step403.log[]
----

.*copyright*
----
sys::[head -n25  ../remote-lib_a/ref/step404.log]
 ...
 ... (snip)
 ...
sys::[tail -n8  ../remote-lib_a/ref/step404.log]
----

.*kkc.1*
----
include::../remote-lib_a/ref/step405.log[]
----

.*install* files
----
include::../remote-lib_a/ref/step406.log[]
----

.*rules*
----
include::../remote-lib_a/ref/step407.log[]
----

.Remove unused template files
----
include::../remote-lib_a/ref/step408.log[]
----

Let's record packaging result into VCS.

(Hmmm.... importing upstream with pristine-tar first is better but let's not worry now.)

----
sys::[head -n15  ../remote-lib_a/ref/step410.log]
 ...
 ... (snip)
 ...
sys::[tail -n5  ../remote-lib_a/ref/step410.log]
----

Let's build this package under the *pdebuild* command.

.The first *pdebuild*
----
sys::[head -n3  ../remote-lib_a/ref/step500.log]
 ...
sys::[grep -B 1 -A 1 -e '^ fakeroot debian/rules clean' ../remote-lib_a/ref/step500.log]
 ...
sys::[grep -A 1 -e '^ debian/rules build' ../remote-lib_a/ref/step500.log]
 ...
sys::[grep -A 1 -e '^ fakeroot debian/rules binary' ../remote-lib_a/ref/step500.log]
 ...
sys::[grep -A10 -e 'dpkg-gensymbols: warning' ../remote-lib_a/ref/step500.log]
 ...
sys::[tail -n1  ../remote-lib_a/ref/step500.log]
----

.Restore source tree using VCS
----
sys::[head -n10  ../remote-lib_a/ref/step501.log]
 ...
 ... (snip)
 ...
----

Using *mc*, copy *DEBIAN/symbols* from the *libkkc2_0.3.2-1_amd64.deb* package to *debian/libkkc2.symbols*. (Of course, you can manually use the *dpkg-deb* command.)

.Update *debian/libkkc2.symbols*
----
sys::[head -n10  ../remote-lib_a/ref/step510.log]
 ...
 ... (snip)
 ...
----

.The second *pdebuild*
----
sys::[head -n3  ../remote-lib_a/ref/step520.log]
 ...
sys::[grep -B 1 -A 1 -e '^ fakeroot debian/rules clean' ../remote-lib_a/ref/step520.log]
 ...
sys::[grep -A 1 -e '^ debian/rules build' ../remote-lib_a/ref/step520.log]
 ...
sys::[grep -A 1 -e '^ fakeroot debian/rules binary' ../remote-lib_a/ref/step520.log]
 ...
sys::[tail -n1  ../remote-lib_a/ref/step520.log]
----

.The build result
----
include::../remote-lib_a/ref/step600.log[]
----

Let’s inspect the result.

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

.The source package contents:
----
sys::[grep -A 10 -e '^ \$ tar -tJf' ../remote-lib_a/ref/step701.log]
 ...
sys::[grep -A 10 -e '^ \$ tar -tzf' ../remote-lib_a/ref/step701.log]
 ...
----

.The binary package contents:
----
sys::[head -n40  ../remote-lib_a/ref/step700.log]
 ...
 ... (snip)
 ...
sys::[tail -n60  ../remote-lib_a/ref/step700.log]
----



