Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

If I want to make minor changes to the source code of a Debian package, how do I go about downloading, incrementing the package version, building the (modified) source, and installing it on my computer?

share|improve this question

1 Answer 1

up vote 21 down vote accepted

There's basically two ways to do it, the first one is the classic form, you'll get the source with:


 $ apt-get source package

Then you'll be able to modify it:

 $ cd package
 $ vim some_file

Rebuild it:

$ sudo apt-get build-dep package
$ dch -i (which will open your editor to edit the changefile, here's where you can increment the package version)

$ debuild -us -uc -b

And install it:

$ sudo dpkg -i ../package.deb

New Ubuntu Approach

The new way (the Ubuntu way) is by using bzr branches, you'll get the code by using:

$ bzr branch lp:ubuntu/package #which will download the latest ubuntu package (the precise one)

$ bzr branch lp:ubuntu/oneiric/package #to get the package in oneiric

You can also get the code using:

$ lp-source package #lp-source is part of the ubuntu-dev-tools pkg

Then you'll be able to edit it:

$ cd package 
$ vim some_file

Rebuild it:

$ dch -i 
$ debcommit
$ bzr bd -- -b -us -uc

And install it:

$ sudo dpkg -i ../package.deb

I recommend that you check the Ubuntu packaging guide out to know the details.

Also you might enconter problems if the package depends of others

share|improve this answer
Using apt-get source openjdk-7 took around 2 minutes for me, while using bzr branch took over an hour and I decided to kill the process. I'm wondering what would be the usefulness of this "new approach". –  Andrea Lazzarotto Oct 7 '14 at 10:19
many thanks I did it, just need to install before: apt-get install dpkg-dev apt-get install dchroot devscripts apt-get install fakeroot –  Sérgio Jan 14 at 18:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.