6.1.2. Separating your patches into multiple files
Big, complex packages may have many bugs that you need to deal with. If you correct a number of bugs directly in the source, and you’re not careful, it can get hard to differentiate the various patches that you applied. It can get quite messy when you have to update the package to a new upstream version which integrates some of the fixes (but not all). You can’t take the total set of diffs (e.g., from .diff.gz
) and work out which patch sets to back out as a unit as bugs are fixed upstream.
Fortunately, with the source format “3.0 (quilt)” it is now possible to keep patches separate without having to modify debian/rules
to set up a patch system. Patches are stored in debian/patches/
and when the source package is unpacked patches listed in debian/patches/series
are automatically applied. As the name implies, patches can be managed with quilt
.
When using the older source “1.0”, it’s also possible to separate patches but a dedicated patch system must be used: the patch files are shipped within the Debian patch file (.diff.gz
), usually within the debian/
directory. The only difference is that they aren’t applied immediately by dpkg-source
, but by the build
rule of debian/rules
, through a dependency on the patch
rule. Conversely, they are reverted in the clean
rule, through a dependency on the unpatch
rule.
quilt
is the recommended tool for this. It does all of the above, and also allows one to manage patch series. See the quilt
package for more information.
There are other tools to manage patches, like dpatch
, and the patch system integrated with cdbs
.