Updating a pre-existing Debian package

This article was first written in December 2005 for the BeezNest technical
website (http://glasnost.beeznest.org/articles/314).
From time to time, you would like to have a more recent version of an application than what is currently packaged in Debian  [1]. This is basically the same process as backporting anyway. There has been the introduction in Debian of a new set of tools called Debian External Health Status (dehs) which proved really useful for QA. This set of tools involve a file called debian/watch in the source package, and when this file is present (and working), the utility uscan [2] may be used to serve our current purpose. So, we'll download the sources of the latest version available (you need of course to have the right deb-src line in your sources.list ):
$ apt-get source packagename
It will download and extract the sources package in a directory whose name will be packagename-X.X.X and apply the Debian packaging patch [3] to it. Then go into the newly-created directory and issue the following command:
~/packagename-X.X.X$ uscan --verbose
It will try to get the latest upstream tarball and extract it in ../packagename-Y.Y.Y/ [4] and will try to apply the old Debian packaging patch to it (while trying to automate some stuff like the release version in debian/changelog). If everything went well, go to the newly-created directory ../packagename-Y.Y.Y/ and issue the following command (if you want to modify something in the packaging, this is the good time to do it):
~/packagename-Y.Y.Y$ debuild
No doubt it will ask you to install some build-dependencies. Just read the output and install them accordingly. Relaunch debuild if needed, and enjoy your new package!
[1] I'm talking here about Unstable, because otherwise it's probably just plain backport, and don't forget Experimental exists, and may already host the application you miss so much [2] part of package devscripts for some time already, and I suggest you install package fakeroot too [3] packagename_X.X.X.diff.gz [4] it will tell you exactly