Patching debian packages

While upgrading my server, I had to create a new version of Cyrus-SASL packages with the crypt patch. This turned out to be more difficult as I thought as just patching the raw source would conflict with debian patches applied after that and the package building would fail. Fortunately, I learned about (dpatch)[http://www.tuxmaniac.com/blog/2008/01/25/dpatch-just-superb-a-short-how-to/], which is a standard mechanism for patching stuff in Debian.

Once I figured out how to do it, it tunred out to be very simple:

  1. Unpack the original orig.tar.gz
  2. Apply the Debian diff (this would create a debian subdirectory)
  3. Edit changelog file to add a new release (so that we can keep track of it).
  4. Run dpatch-edit-patch fixing_foo to create a patch. This will create a shell with mounted source package and any changes you make there will be included in the diff.
  5. Exit the shell without changing anything. You will change things after making sure that the patch is applied in the correct order.
  6. Edit 00list to set the patch ordering.
  7. Run dpatch-edit-patch again now, with all the previous patches applied.
  8. Make the necessary changes.
  9. Build the target package with debuild-pbuilder (this will download all the dependencies too).
  10. Install the pakcages with dpkg -i (I could also create my private apt-repository for this. I wrote about in in a blog entry about pbuilder).
  11. Pin the packages so that they will not get upgraded echo "package hold" | dpkg --set-selection

Leave a Reply