TL;DR; sudo apt-get -y install build-essential devscripts quilt
etc then sudo apt-get -y build-dep PACKAGE_NAME
then apt-get source PACKAGE_NAME
then use quilt
to patch and debuild
to build the package.
Read the packaging-tutorial.en.pdf packaging tutorial before getting bogged down reading any of the links below.
sudo apt-get -y update
sudo apt-get -y install build-essential devscripts debhelper cdbs quilt pbuilder sbuild lintian svn-buildpackage git-buildpackage dpatch fakeroot dh-make debhelper
#sudo apt-get -y install dh-make-perl dh-make-php dh-make-drupal
sudo apt-get -y build-dep PACKAGE_NAME
apt-get -y source PACKAGE_NAME
cd PACKAGE_NAME-PACKAGE_VERSION
debuild -us -uc -i -I
ls -lart ..
Everything of interest inside an unpacked Debian package source tree is contained inside the ./debian/
directory. Items of particular interest are:
./debian/compat
- used by the debhelper
tool get the 'compatibility level' and should contain 9
./debian/control
- describes the source and binary package./debian/changelog
- package change log used to extract the package version number; use dch
to update it, and use UNRELEASED; urgency=low
target and a version suffix of ~my_special_suffix-YYYYMMDDHHMM
./debian/rules
- Makefile rules used to build packages; the dh
command in the debhelper package helps to make rules easier./debian/patches/
- directory containing all diff patches (or dpatch files in some old legacy cases) to be applied to the original source./debian/patches/series
- order of which patches to apply using quilt
./debian/source/format
- should contain 3.0 (quilt)
to indicate the source package format versionSome debuild
arguments are passed to dpkg-buildpackage
and in turn dpkg-source
, so look at the man pages for those commands if you do not find the documentation you are looking for.
Use quilt
for applying patches on top of source tarballs or existing packages: http://packages.debian.org/quilt
You may want your package to provide a configuration file for another package. Ordinarily this wouldn't be possible because that configuration file belongs to that other package.
This can be solved by creating a package that uses dpkg-divert
in its maintainer scripts to move the old config file aside:
In your debian/preinst
script, divert the file away using:
dpkg-divert --add --package $YOUR_PACKAGE_NAME --rename \
--divert /path/to/file.orig \
/path/to/file
In your debian/postrm
script, revert the file back using:
dpkg-divert --remove --package $YOUR_PACKAGE_NAME --rename \
/path/to/file
See: http://www.debian.org/doc/debian-policy/ap-pkg-diversions.html.
One solution that helps abstract dpkg-divert
is the config-package-dev
package created and maintained by MIT's Debathena project. They have a thorough tutorial.
See https://www.debian.org/doc/manuals/maint-guide/dreq.en.html#control.
Architecture: any
The generated binary package is an architecture dependent one usually in a compiled language.Architecture: all
The generated binary package is an architecture independent one usually consisting of text, images, or scripts in an interpreted language. (Similar to RPMnoarch
).Do not use any of the following unless you are actively forced to; for example if the package you are maintaining is still relying on one of these tools: