how to add upstream git patches to an existing debian package

I maintain a few personal package archives (PPAs) that I note from the launchpad stats seem to be useful for quite a few people 🙂

One of these is Rhythmbox 3.

What I like to-do from time-to-time is to get the latest upstream patches and apply them to my existing debian package.

Below are some notes for how I do this. There is probably easier and simpler ways of doing this – but heck, I’m a simple soul…

First get the latest upstream git repository:

git clone
cd rhythmbox

Now create patch files –

in this first example, I want to get the last 5 commits

git format-patch HEAD~5

This will create a series of patch files (.patch extension) in the current folder.

Alternatively in this second example, I want to get the patch files between two commits

git format-patch f21d15e1795179705^..53beafc67d3c221e314c7

where the patch numbers corresponds to the first few characters of the git commit

Now lets get the source of my PPA package

cd ..
apt-get source rhythmbox
cd rhythmbox-3.0

We now can apply two methods to patch the source:

Method 1:

copy the .patch file into the folder debian/patches.  Edit the file called series and add the patch file to the bottom of the file.  Patches are applied in order from the beginning to the end of the file

Build the package and upload it to your PPA:

debuild -S
dch -i
cd ..
dput ppa:fossfreedom/playground rhythmbox_3*.changes

Method 2:

Apply each individual patch file

patch -p1 < ../rhythmbox/0001*.patch

etc. etc.

or if I just want to apply all the patches

for i in /full_path_to_git_repository/*.patch; do patch -p1 < $i; done

Finally, rebuild the package and commit it for a rebuild on launchpad

dpkg-source --commit
dch -i
cd ..
dput ppa:fossfreedom/playground rhythmbox_3*.changes