[[adv-pkg]]
=== Advanced packaging

Hints for the following can be found in the *debhelper*(7) manpage:

* differences of the debhelper tool behavior under ``*compat* \<= 8''
* building several binary packages with several different build conditions
** making multiple copies of the upstream source
** invoking multiple ``*dh_auto_configure -S ...*'' commands in the *override_dh_auto_configure* target
** invoking multiple ``*dh_auto_build -S ...*'' commands in the *override_dh_auto_build* target
** invoking multiple ``*dh_auto_install -S ...*'' commands in the *override_dh_auto_install* target
* building *udeb* packages with ``*Package-Type: udeb*'' in *debian/control* (see https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Package-Type[Package-Type])
* excluding some packages for the bootstrapping (see also https://wiki.debian.org/BuildProfileSpec[BuildProfileSpec])
** adding the *Build-Profiles* fields in binary package stanzas in *debian/control*
** building packages with the *DEB_BUILD_PROFILES* environment variable set to the pertinent profile name

Hints for the following can be found in the *dpkg-source*(1) manpage:

* naming convention for the multiple upstream source tarballs
** 'packagename_version'**.orig.tar.gz**
** 'packagename_version'**.orig-**'componentname'**.tar.gz**
* recording the Debian changes to the upstream binary file
**  *dpkg-source --commit*

[[other-distro]]
=== Other distros

Although the upstream tarball has all the information to build the Debian package, it is not always easy to figure out which combination of options to use.

Also, the upstream may be more focused on the feature enhancements and may be less eager for backward compatibilities etc. which are important aspect of the Debian packaging practice.

The leveraging of information from other distributions is an option to address above issues.

If the other distribution in interest is a Debian derivative one, it is trivial to reuse it.

If the other distribution in interest is a http://en.wikipedia.org/wiki/RPM_Package_Manager[RPM] based distribution, see https://wiki.debian.org/Repackage_srcrpm[Repackage src.rpm].

Downloading and opening of the *src.rpm* file can be done with the *rget* command.  (Place the *rget* script in your PATH.)

.rget script
----
#!/bin/sh
FCSRPM=$(basename $1)
mkdir ${FCSRPM}; cd ${FCSRPM}/
wget $1
rpm2cpio ${FCSRPM} | cpio -dium
----

Many upstream tarballs contain the SPEC file named as 'packagename'.*spec* or 'packagename'.*spec.in* used by the RPM system.  This can be used as the baseline for the Debian package, too.
