Patches

Patches record modifications to source code. Patches can come in many forms, including but not limited to:

  • Upstream features or bug-fixes not present in the current release.

  • Ubuntu specific changes, such as custom defaults and theming.

  • CVE fixes and other security-related updates.

All changes to a source package in the 3.0 (quilt) format (see explanation) to the source files (all files inside the orig tarball / outside the debian/ directory) must be applied in the form of a patch.

Changes to a source package in the 3.0 (native) format (see explanation) get applied directly and will not be further discussed in this article.

It is important to treat patches with care, and ensure the format and headers follow best practices. This makes it easier to maintain a package long-term. In Ubuntu, we try to follow the DEP 3 specification, which details a standard format for patch headers.

The source package stores the patches in the debian/patches/ directory. These patches get applied from top to bottom in the order they are listed in debian/patches/series, excluding empty lines and lines starting with #.

Sending patches upstream

Changes to the upstream source code which are not Ubuntu specific should be sent to the upstream authors in whatever form they prefer. This allows the upstream authors to include the patch in the upstream version of the package.

When you should (not) rewrite a patch header to follow DEP 3

You should rewrite a patch header to follow DEP 3 if:

  • You are introducing a new patch altogether.

  • You are making substantive modifications to an existing patch.

  • More information is known about the patch, and a DEP 3 header would contain updated information.

You should not rewrite a patch header to follow DEP 3 if:

  • You are preparing a non-micro-release exception SRU and changing the patch header is not directly related to the bug being fixed.

  • You intend on keeping only the modifications to the header as part of the Ubuntu delta without making substantive changes to the diff contents, and have no plans to forward it to Debian.

  • The team claiming responsibility for this package in Ubuntu explicitly disagrees with the usage of DEP 3 headers. (This should be brought up on the ubuntu-devel mailing list.)

Resources