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.
Links
- https://wiki.debian.org/IntroDebianPackaging
- https://wiki.debian.org/UsingQuilt
- https://www.debian.org/doc/manuals/maint-guide/modify.en.html
- https://www.debian.org/doc/manuals/packaging-tutorial/packaging-tutorial.en.pdf
- http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/
- https://packages.debian.org/search?keywords=packaging-tutorial
- http://www.debian.org/doc/debian-policy/ch-controlfields
- http://www.debian.org/doc/debian-policy/ch-source#s-debianrules
- https://wiki.debian.org/debian/patches
- https://www.debian.org/doc/manuals/maint-guide/
- https://www.debian.org/doc/manuals/developers-reference/
- https://www.debian.org/doc/debian-policy/
- http://mentors.debian.net/intro-maintainers
- https://blog.packagecloud.io/eng/2014/10/28/howto-gpg-sign-verify-deb-packages-apt-repositories/
- https://www.debian.org/doc/manuals/distribute-deb/distribute-deb.html
Quick Start
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 thedebhelpertool get the ‘compatibility level’ and should contain9./debian/control- describes the source and binary package./debian/changelog- package change log used to extract the package version number; usedchto update it, and useUNRELEASED; urgency=lowtarget and a version suffix of~my_special_suffix-YYYYMMDDHHMM./debian/rules- Makefile rules used to build packages; thedhcommand 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 usingquilt./debian/source/format- should contain3.0 (quilt)to indicate the source package format version
Some 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
Overloaded Config Files in Deb Packages
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/fileIn your debian/postrm script, revert the file back using:
dpkg-divert --remove --package $YOUR_PACKAGE_NAME --rename \
/path/to/fileSee: 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.
Architecture
See https://www.debian.org/doc/manuals/maint-guide/dreq.en.html#control.
Architecture: anyThe generated binary package is an architecture dependent one usually in a compiled language.Architecture: allThe generated binary package is an architecture independent one usually consisting of text, images, or scripts in an interpreted language. (Similar to RPMnoarch).
Deprecated Gotchas
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:
- dpatch
- cdbs
- dpkg (v2.0) - use dpkg v3.0 instead, which uses quilt
- dbs